|
Junior Member
|
03-27-2023
, 13:39
Re: Need a plugin
|
#3
|
Quote:
Originally Posted by Naathy
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_sHostname, sizeof(g_sHostname));
cvarHostname.AddChangeHook(OnHostnameChange);
}
void OnHostnameChange(ConVar convar, char[] oldValue, char[] newValue)
{
strcopy(g_sHostname, sizeof(g_sHostname), newValue);
}
public Action Command_need(int client, int 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(sRequest, sizeof(sRequest), "%N is calling you to play!", client);
Embed.AddField("Need Player!", sRequest, false);
char sMap[54];
GetCurrentMap(sMap, sizeof(sMap));
Embed.AddField("Map:", sMap, false);
char buffer[264];
Format(buffer, sizeof(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
|
|
|
|