Raised This Month: $32 Target: $400
 8% 

Display wins on scoreboard (CS:GO BattleRoyale)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ImScottyyy
Junior Member
Join Date: Oct 2016
Location: UK
Old 08-20-2017 , 17:02   Display wins on scoreboard (CS:GO BattleRoyale)
Reply With Quote #1

Hello,

I am looking for someone who is able to make a plugin that displays users individual wins on the scoreboard next to their name if they win the BattleRoyale, this game mode is free for all.

So it would look something like this, http://prntscr.com/gax87b

I am willing to pay if someone is able to make this.

Thank you

Last edited by ImScottyyy; 08-20-2017 at 17:04. Reason: image
ImScottyyy is offline
waylander3
Senior Member
Join Date: Sep 2015
Location: Russia, Norilsk
Old 08-21-2017 , 11:43   Re: Display wins on scoreboard (CS:GO BattleRoyale)
Reply With Quote #2

Sorry for offtopic, but what BattleRoyal mode you use?
waylander3 is offline
ImScottyyy
Junior Member
Join Date: Oct 2016
Location: UK
Old 08-21-2017 , 12:50   Re: Display wins on scoreboard (CS:GO BattleRoyale)
Reply With Quote #3

Quote:
Originally Posted by waylander3 View Post
Sorry for offtopic, but what BattleRoyal mode you use?
It's just workshop maps made for BattleRoyale.

https://steamcommunity.com/sharedfil.../?id=500852664
ImScottyyy is offline
DarkBlackOMG
Member
Join Date: Oct 2015
Old 08-21-2017 , 14:58   Re: Display wins on scoreboard (CS:GO BattleRoyale)
Reply With Quote #4

Add me and we talk http://steamcommunity.com/id/darkblackomg/
DarkBlackOMG is offline
yash1441
Senior Member
Join Date: Feb 2015
Location: Illuminati HQ
Old 08-22-2017 , 06:29   Re: Display wins on scoreboard (CS:GO BattleRoyale)
Reply With Quote #5

https://github.com/yash1441/BRTag
__________________
yash1441 is offline
Send a message via Skype™ to yash1441
Addicted.
AlliedModders Donor
Join Date: Dec 2013
Location: 0xA9D0DC
Old 08-22-2017 , 20:12   Re: Display wins on scoreboard (CS:GO BattleRoyale)
Reply With Quote #6

Quote:
Originally Posted by yash1441 View Post
Thanks for taking your time to make this for him.

Only one suggestion:
I don't think it's really necessary to recalculate every player's clan tag on every frame.

You should hook clan tag change and do it then.
Addicted. is offline
yash1441
Senior Member
Join Date: Feb 2015
Location: Illuminati HQ
Old 08-23-2017 , 02:22   Re: Display wins on scoreboard (CS:GO BattleRoyale)
Reply With Quote #7

Quote:
Originally Posted by Addicted. View Post
Thanks for taking your time to make this for him.

Only one suggestion:
I don't think it's really necessary to recalculate every player's clan tag on every frame.

You should hook clan tag change and do it then.
Updated!
I wasn't sure if the client connected and didn't do anything except playing, would OnClientSettingsChanged or OnClientCommand be called so I added round_start check.
Thanks!
__________________
yash1441 is offline
Send a message via Skype™ to yash1441
headline
SourceMod Moderator
Join Date: Mar 2015
Old 08-23-2017 , 04:19   Re: Display wins on scoreboard (CS:GO BattleRoyale)
Reply With Quote #8

Hello. Since this popped up I'll throw some code into the batch. This is what I used to run on Hunger Games/Battle Royal servers, and is probably the one you created this thread for.

Create a database entry under "hl_wincounter"
PHP Code:
#include <sourcemod>
#include <autoexecconfig>
#include <cstrike>

#define PLUGIN_VERSION "1.2"

#pragma semicolon 1

new Handle:g_hDatabaseName INVALID_HANDLE;
new 
String:g_sDatabaseName[60];

new    
Handle:g_hPluginEnabled INVALID_HANDLE;
new 
bool:g_bPluginEnabled;

new    
Handle:g_hDebug INVALID_HANDLE;
new 
bool:g_bDebug;

new 
Handle:g_hDatabase INVALID_HANDLE;
new 
bool:g_bLateLoad;

new 
bool:ga_bLoaded[MAXPLAYERS 1] = {false, ...};
new 
String:ga_sSteamID[MAXPLAYERS 1][30];
new 
ga_iClientMVP[MAXPLAYERS +1] = {0, ...};

public 
APLRes:AskPluginLoad2(Handle:hMyselfbool:bLateString:sError[], err_max)
{
    
g_bLateLoad bLate;
    
    return 
APLRes_Success;
}

public 
Plugin:myinfo =
{
    
name "Win Counter!",
    
author "Headline",
    
description "Counts the ammount of wins for each player!",
    
version PLUGIN_VERSION,
    
url "http://michaelwflaherty.com"
};

public 
OnPluginStart()
{
    
LoadTranslations("core.phrases");
    
LoadTranslations("common.phrases");
    
    
AutoExecConfig_SetFile("hl_wincounter");
    
    
AutoExecConfig_CreateConVar("hl_wincounter_version"PLUGIN_VERSION"Headline's Win Counter Plugin : Version"FCVAR_PLUGIN|FCVAR_NOTIFY|FCVAR_DONTRECORD);
    
    
g_hDatabaseName AutoExecConfig_CreateConVar("hl_wincounter_database_name""hl_wincounter""Name of the database for the plugin.");
    
HookConVarChange(g_hDatabaseNameOnCVarChange);
    
GetConVarString(g_hDatabaseNameg_sDatabaseNamesizeof(g_sDatabaseName));
    
    
g_hPluginEnabled AutoExecConfig_CreateConVar("hl_wincounter_enabled""1""Enable the plugin? (1 = Yes, 0 = No)"FCVAR_NONEtrue0.0true1.0);
    
HookConVarChange(g_hPluginEnabledOnCVarChange);
    
g_bPluginEnabled GetConVarBool(g_hPluginEnabled);
    
    
g_hDebug AutoExecConfig_CreateConVar("hl_wincounter_debug""1""Enable debug logging? (1 = Yes, 0 = No)"FCVAR_NONEtrue0.0true1.0);
    
HookConVarChange(g_hDebugOnCVarChange);
    
g_bDebug GetConVarBool(g_hDebug);
    
    
AutoExecConfig_ExecuteFile();
    
AutoExecConfig_CleanFile();
    
    
HookEvent("player_spawn"Event_PlayerSpawn);
    
HookEvent("round_end"Event_RoundEnd);
}

public 
OnCVarChange(Handle:hCVar, const String:sOldValue[], const String:sNewValue[])
{
    if (
hCVar == g_hDatabaseName)
    {
        
GetConVarString(g_hDatabaseNameg_sDatabaseNamesizeof(g_sDatabaseName));
    }
    else if (
hCVar == g_hPluginEnabled)
    {
        
g_bPluginEnabled GetConVarBool(g_hPluginEnabled);
    }
    else if (
hCVar == g_hDebug)
    {
        
g_bDebug GetConVarBool(g_hDebug);
    }
}

public 
OnConfigsExecuted()
{
    if (
g_bPluginEnabled)
    {
        if (
g_hDatabase == INVALID_HANDLE)
        {
            
SetDBHandle();
        }
        if (
g_bLateLoad)
        {
            for (new 
1<= MaxClientsi++)
            {
                if (
IsValidClient(i))
                {
                    
#if SOURCEMOD_V_MAJOR >= 1 && SOURCEMOD_V_MINOR >= 7
                        
GetClientAuthId(iAuthId_Steam2ga_sSteamID[i], sizeof(ga_sSteamID[]));
                    
#else
                        
GetClientAuthString(iga_sSteamID[i], sizeof(ga_sSteamID[]));
                    
#endif
                    
if (StrContains(ga_sSteamID[i], "STEAM_"true) != -1)
                    {
                        if (
g_bDebug)
                        {
                            
Log("hl_wincounter.log","Loading #s for %L"i);
                        }
                        
LoadMvpCount(i);
                    }
                    else
                    {
                        if (
g_bDebug)
                        {
                            
Log("hl_wincounter.log","Refreshing steam ID for client %L"i);
                        }
                        
CreateTimer(10.0RefreshSteamIDGetClientUserId(i), TIMER_FLAG_NO_MAPCHANGE);
                    }
                }
            }
        }
    }
}

public 
Action:RefreshSteamID(Handle:hTimerany:iUserID)
{
    new 
client GetClientOfUserId(iUserID);
    if (!
IsValidClient(client))
    {
        return;
    }

    
#if SOURCEMOD_V_MAJOR >= 1 && SOURCEMOD_V_MINOR >= 7
        
GetClientAuthId(clientAuthId_Steam2ga_sSteamID[client], sizeof(ga_sSteamID[]));
    
#else
        
GetClientAuthString(clientga_sSteamID[client], sizeof(ga_sSteamID[]));
    
#endif
    
    
if (StrContains(ga_sSteamID[client], "STEAM_"true) == -1//still invalid - retry again
    
{
        if (
g_bDebug)
        {
            
Log("hl_wincounter.log","Re-refreshing steam ID for client %L"client);
        }
        
CreateTimer(10.0RefreshSteamIDGetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
    }
    else
    {
        if (
g_bDebug)
        {
            
Log("hl_wincounter.log","Loading mvpcount for client %L"client);
        }
        
LoadMvpCount(client);
    }
}

public 
OnClientConnected(client)
{
    if (
g_bPluginEnabled)
    {
        
ga_iClientMVP[client] = 0;
        
ga_sSteamID[client] = "";
        
ga_bLoaded[client] = false;
    }
}

public 
OnClientDisconnect(client)
{
    if (
g_bPluginEnabled)
    {
        
UpdateMvpStar(client);
        
ga_iClientMVP[client] = 0;
        
ga_sSteamID[client] = "";
        
ga_bLoaded[client] = false;
    }
}

UpdateMvpStar(client)
{
    if (
ga_bLoaded[client] && !StrEqual(ga_sSteamID[client], ""false))
    {
        
decl String:sQuery[300];
        
Format(sQuerysizeof(sQuery), "UPDATE hl_wincounter SET mvpcount=%i WHERE steamid=\"%s\""ga_iClientMVP[client], ga_sSteamID[client]);
        
SQL_TQuery(g_hDatabaseSQLCallback_VoidsQuery2);
    }
}

public 
Action:Event_PlayerSpawn(Handle:hEvent, const String:sName[], bool:bDontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(hEvent"userid"));
    
CreateTimer(0.5Timer_UpdateClanTagclientTIMER_FLAG_NO_MAPCHANGE);
}

public 
Action:Timer_UpdateClanTag(Handle:hTimerany:client)
{
    
SetClanTag(client);
}

SetClanTag(client)
{
    if (
IsValidClient(clientfalse))
    {
        if (
ga_iClientMVP[client] == 1)
        {
            
decl String:sString[64];
            
Format(sStringsizeof(sString), "[%i Win]"ga_iClientMVP[client]);
            
CS_SetClientClanTag(clientsString);
        }
        else
        {
            
decl String:sString[64];
            
Format(sStringsizeof(sString), "[%i Wins]"ga_iClientMVP[client]);
            
CS_SetClientClanTag(clientsString);
        }
    }
}
public 
Action:Event_RoundEnd(Handle:hEvent, const String:sName[], bool:bDontBroadcast)
{
    for (new 
1<= MaxClientsi++)
    {
        if (
IsValidClient(ifalsefalse) && GetPlayerCount() >= 4)
        {
            
ga_iClientMVP[i]++;
            
SetClanTag(i);
        }
    }
}

public 
OnClientPostAdminCheck(client)
{
    if (
g_bPluginEnabled)
    {    
        
#if SOURCEMOD_V_MAJOR >= 1 && SOURCEMOD_V_MINOR >= 7
            
GetClientAuthId(clientAuthId_Steam2ga_sSteamID[client], sizeof(ga_sSteamID[]));
        
#else
            
GetClientAuthString(clientga_sSteamID[client], sizeof(ga_sSteamID[]));
        
#endif
        
LoadMvpCount(client);
    }
}

LoadMvpCount(client)
{
    if (
g_bPluginEnabled)
    {
        if (!
IsValidClient(client))
        {
            return;
        }
        
#if SOURCEMOD_V_MAJOR >= 1 && SOURCEMOD_V_MINOR >= 7
            
GetClientAuthId(clientAuthId_Steam2ga_sSteamID[client], sizeof(ga_sSteamID[]));
        
#else
            
GetClientAuthString(clientga_sSteamID[client], sizeof(ga_sSteamID[]));
        
#endif
        
if (StrContains(ga_sSteamID[client], "STEAM_"true) == -1//if ID is invalid
        
{
            
CreateTimer(10.0RefreshSteamIDGetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
            if (
g_bDebug)
            {
                
Log("hl_wincounter.log","Refreshing Steam ID for client %L!"client);
            }
        }
        
        if (
g_hDatabase == INVALID_HANDLE//connect not loaded - retry to give it time
        
{
            
CreateTimer(1.0RepeatCheckRankGetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
            if (
g_bDebug)
            {
                
Log("hl_wincounter.log","Database connection not established yet! Delaying loading of client %L"client);
            }
        }
        else
        {
            if (
g_bDebug)
            {
                
Log("hl_wincounter.log","Sending database query to load client %L"client);
            }
            
            
decl String:sQuery[300];
            
Format(sQuerysizeof(sQuery), "SELECT `mvpcount` FROM hl_wincounter WHERE steamid=\"%s\""ga_sSteamID[client]);
            
SQL_TQuery(g_hDatabaseSQLCallback_CheckSQLsQueryGetClientUserId(client));
        }
    }
}

public 
SQLCallback_CheckSQL(Handle:hOwnerHandle:hHndl, const String:sError[], any:iUserID)
{
    if (
hHndl == INVALID_HANDLE)
    {
        
SetFailState("Error: %s"sError);
    }
    
    new 
client GetClientOfUserId(iUserID);
    if (!
IsValidClient(client))
    {
        return;
    }
    else 
    {
        if (
SQL_GetRowCount(hHndl) == 1)
        {
            
SQL_FetchRow(hHndl);
            
            
ga_iClientMVP[client] = SQL_FetchInt(hHndl0);
            
            
ga_bLoaded[client] = true;
            
            
LogToGame("Player %L has been loaded from the database!"client);
            
LogMessage("Player %L has been loaded from the database!"client);
            
            if (
g_bDebug)
            {
                
Log("hl_wincounter.log","Player %L has been loaded from the database !"client);
            }
        }
        else
        {
            if (
SQL_GetRowCount(hHndl) > 1)
            {
                
LogError("Player %L has multiple entries under their ID. Running script to clean up duplicates and keep original entry (oldest)"client);
                
DeleteDuplicates();
                
CreateTimer(20.0RepeatCheckRankGetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
            }
            else if (
g_hDatabase == INVALID_HANDLE)
            {
                
CreateTimer(2.0RepeatCheckRankGetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
            }
            else    
//new player
            
{
                
decl String:sQuery[300];
                
Format(sQuerysizeof(sQuery), "INSERT INTO hl_wincounter (steamid, mvpcount) VALUES(\"%s\", 0)"ga_sSteamID[client]);
                
SQL_TQuery(g_hDatabaseSQLCallback_VoidsQuery3);
                
ga_bLoaded[client] = true;
                
LogToGame("New player %L has been added to the database!"client);
                
LogMessage("New player %L has been added to the database!"client);
                if (
g_bDebug)
                {
                    
Log("hl_wincounter.log","New player %L has been added to the database!"client);
                }
            }
        }
    }
}

DeleteDuplicates()
{
    if (
g_hDatabase != INVALID_HANDLE)
    {
        if (
g_bDebug)
        {
            
Log("hl_ctban.log","Duplicates detected in database. Deleting duplicate Steam IDs!");
        }
        
SQL_TQuery(g_hDatabaseSQLCallback_Void"delete hl_ctban from hl_ctban inner join (select min(id) minid, steamid from hl_ctban group by steamid having count(1) > 1) as duplicates on (duplicates.steamid = hl_ctban.steamid and duplicates.minid <> hl_ctban.id)"4);
    }
}

public 
Action:RepeatCheckRank(Handle:hTimerany:iUserID)
{
    new 
client GetClientOfUserId(iUserID);
    
LoadMvpCount(client);
}

SetDBHandle()
{
    if (
g_hDatabase == INVALID_HANDLE)
    {
        
SQL_TConnect(SQLCallback_Connectg_sDatabaseName);
    }
}

public 
SQLCallback_Connect(Handle:hOwnerHandle:hHndl, const String:sError[], any:data)
{
    if (
hHndl == INVALID_HANDLE)
    {
        
SetFailState("Error connecting to database. %s"sError);
    }
    else
    {
        
g_hDatabase hHndl;
        
decl String:sDriver[64];
        
        
SQL_ReadDriver(g_hDatabasesDriver64);
        
        if (
StrEqual(sDriver"sqlite"))
        {
            
SQL_TQuery(g_hDatabaseSQLCallback_Void"CREATE TABLE IF NOT EXISTS `hl_wincounter` (`id` int(20) PRIMARY KEY, `steamid` varchar(32) NOT NULL, `mvpcount` int(32) NOT NULL)"0);
        }
        else
        {
            
SQL_TQuery(g_hDatabaseSQLCallback_Void"CREATE TABLE IF NOT EXISTS `hl_wincounter` ( `id` int(20) NOT NULL AUTO_INCREMENT, `steamid` varchar(32) NOT NULL, `mvpcount` int(32) NOT NULL, PRIMARY KEY (`id`)) DEFAULT CHARSET=latin1 AUTO_INCREMENT=1"1);
        }
        
        if (
g_bDebug)
        {
            
Log("hl_wincounter.log","Successfully connected to database!");
        }
    }
}

public 
SQLCallback_Void(Handle:hOwnerHandle:hHndl, const String:sError[], any:iData)
{
    if (
hHndl == INVALID_HANDLE)
    {
        
SetFailState("Error (%i): %s"iDatasError);
    }
}

stock Log(String:sPath[], const String:sMsg[], any:...)
{
    new 
String:sLogFilePath[PLATFORM_MAX_PATH], String:sFormattedMsg[256];
    
BuildPath(Path_SMsLogFilePathsizeof(sLogFilePath), "logs/%s"sPath);
    
VFormat(sFormattedMsgsizeof(sFormattedMsg), sMsg3);
    
LogToFileEx(sLogFilePath"%s"sFormattedMsg);
}

stock bool:IsValidClient(clientbool:bAllowBots falsebool:bAllowDead true)
{
    if (!(
<= client <= MaxClients) || !IsClientInGame(client) || (IsFakeClient(client) && !bAllowBots) || IsClientSourceTV(client) || IsClientReplay(client) || (!bAllowDead && !IsPlayerAlive(client)))
    {
        return 
false;
    }
    return 
true;
}

stock GetPlayerCount()
{
    new 
players;
    for (new 
1<= MaxClientsi++)
    {
        if (
IsClientInGame(i))
        {
            
players++;
        }
    }
    return 
players;
}

/*
    Changelog
    1.0 - Initial Release
    1.1 - ?
    1.2 - Updating Clan Tag
*/ 
headline is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 14:24.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode