Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sourcemod>
- #include <shavit>
- #include <discord>
- #define PLUGIN_VERSION "1.0"
- #define WEBHOOK "https://discordapp.com/api/webhooks/376627548525953024/spv1-27XxQx92004NkZZR5JvizdCfnmy3xVt6Cb1Km5pcaCfleZ8DhllzXXUzpS4OJTR" // webhook url
- #define MAIN_MSG_COLOUR "#a3f441" // colour of embed
- #define BONUS_MSG_COLOUR "#00cbff"
- #define MIN_RECORDS 5 // minimum no. of records before discord bots posts wr
- public Plugin myinfo =
- {
- name = "[shavit] Discord WR Bot",
- author = "SlidyBat",
- description = "Makes discord bot post message when server WR is beaten",
- version = PLUGIN_VERSION,
- url = "steamcommunity.com/id/SlidyBat2"
- }
- ConVar g_cvHostname;
- char g_cHostname[128];
- char g_cCurrentMap[PLATFORM_MAX_PATH];
- public void OnPluginStart()
- {
- g_cvHostname = FindConVar("hostname");
- g_cvHostname.GetString( g_cHostname, sizeof( g_cHostname ) );
- }
- public void OnMapStart()
- {
- GetCurrentMap( g_cCurrentMap, sizeof( g_cCurrentMap ) );
- }
- public void Shavit_OnWorldRecord( int client, int style, float time, int jumps, int strafes, float sync, int track, float oldwr )
- {
- if( MIN_RECORDS > 0 && Shavit_GetRecordAmount( style, track ) < MIN_RECORDS ) // dont print if its a new record to avoid spam
- {
- return;
- }
- DiscordWebHook hook = new DiscordWebHook( WEBHOOK );
- hook.SlackMode = true;
- hook.SetUsername( "AusBHOP WR Bot" );
- MessageEmbed embed = new MessageEmbed();
- embed.SetColor( ( track == Track_Main ) ? MAIN_MSG_COLOUR : BONUS_MSG_COLOUR );
- char styleName[128];
- Shavit_GetStyleStrings( style, sStyleName, styleName, sizeof( styleName ));
- char buffer[512];
- Format( buffer, sizeof( buffer ), "__**New %s World Record**__ | **%s** - **%s**", ( track == Track_Main ) ? "" : "Bonus", g_cCurrentMap, styleName );
- embed.SetTitle( buffer );
- char steamid[65];
- GetClientAuthId( client, AuthId_SteamID64, steamid, sizeof( steamid ) );
- Format( buffer, sizeof( buffer ), "[%N](http://www.steamcommunity.com/profiles/%s)", client, steamid );
- embed.AddField( "Player", buffer, true );
- float split = time - oldwr;
- char sSplit[32];
- FormatSeconds( split, sSplit, sizeof( split ) );
- FormatSeconds( time, buffer, sizeof( buffer ) );
- Format( buffer, sizeof( buffer ), "%ss (%s)", buffer, sSplit );
- embed.AddField( "Time", buffer, true );
- Format( buffer, sizeof( buffer ), "**Strafes**: %i\t\t\t\t\t\t**Sync**: %.2f%%\t\t\t\t\t\t**Jumps**: %i", strafes, sync, jumps );
- embed.AddField( "Stats", buffer, true );
- embed.SetThumb( "http://www.guinnessworldrecords.com/images/logo.png" );
- Format( buffer, sizeof( buffer ), "Server: %s", g_cHostname );
- embed.SetFooter( buffer );
- embed.SetFooterIcon( "https://d30y9cdsu7xlg0.cloudfront.net/png/198559-200.png" );
- hook.Embed( embed );
- hook.Send();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement