Thread: Need a plugin
View Single Post
Martinro12
Junior Member
Join Date: Apr 2021
Old 03-27-2023 , 13:39   Re: Need a plugin
Reply With Quote #3

Quote:
Originally Posted by Naathy View Post
PHP Code:
#include <sourcemod>
#include <discord>

char g_sHostname[264];

ConVar cvarHostname;

#pragma newdecls required

public Plugin myinfo =
{
    
name "Player Request in Discord",
    
author "Nathy",
    
version "1.0",
    
description "Send a message on Discord advising it need players",
    
url "https://steamcommunity.com/id/nathyzinhaa"
};

public 
void OnPluginStart()
{
    
RegConsoleCmd("sm_need"Command_need"Sends Message");
    
RegConsoleCmd("sm_players"Command_need"Sends Message");
    
cvarHostname FindConVar("hostname");
    
cvarHostname.GetString(g_sHostnamesizeof(g_sHostname));
    
    
cvarHostname.AddChangeHook(OnHostnameChange);
}

void OnHostnameChange(ConVar convarchar[] oldValuechar[] newValue)
{
    
strcopy(g_sHostnamesizeof(g_sHostname), newValue);
}

public 
Action Command_need(int clientint args)
{
    
DiscordWebHook hook = new DiscordWebHook("PUT THE WEBHOOK HERE");
    
hook.SlackMode true;
    
    
hook.SetContent("@here"); 
    
hook.SetUsername(""); // you can set this as you want or leave blank, so the plugin get the Discord Webhook name
    
    
MessageEmbed Embed = new MessageEmbed();
    
    
Embed.SetColor("#ff0000");
    
Embed.SetTitle("Looking for players!");
    
    
char sRequest[64];
    
Format(sRequestsizeof(sRequest), "%N is calling you to play!"client);
    
    
Embed.AddField("Need Player!"sRequestfalse);
    
    
char sMap[54];
    
    
GetCurrentMap(sMapsizeof(sMap));
    
    
Embed.AddField("Map:"sMapfalse);
    
    
char buffer[264];
    
Format(buffersizeof(buffer), "%s"g_sHostname);
    
    
Embed.SetFooter(buffer);
    
    
hook.Embed(Embed);
    
    
hook.Send();
    
delete hook;

Dont forget to put the webhook url there.
I try to compile It but send me error

https://ibb.co/3YpHHgz
Martinro12 is offline