Skip to content

Commit

Permalink
Push Version to 3
Browse files Browse the repository at this point in the history
Add karma file (we've a small(?) karma glitch)
  • Loading branch information
Bara committed Oct 16, 2018
1 parent 0a7928b commit 150963b
Show file tree
Hide file tree
Showing 6 changed files with 156 additions and 112 deletions.
1 change: 1 addition & 0 deletions addons/sourcemod/scripting/ttt/core/globals.sp
Expand Up @@ -6,6 +6,7 @@
char g_sRulesFile[PLATFORM_MAX_PATH + 1];
char g_sErrorFile[PLATFORM_MAX_PATH + 1];
char g_sLogFile[PLATFORM_MAX_PATH + 1];
char g_sKarmaFile[PLATFORM_MAX_PATH + 1];
char g_sTag[64];
char g_sDefaultPrimary[32];
char g_sDefaultSecondary[32];
Expand Down
73 changes: 41 additions & 32 deletions addons/sourcemod/scripting/ttt/core/sql.sp
Expand Up @@ -37,59 +37,68 @@ public void Callback_UpdatePlayer(Database db, DBResultSet results, const char[]
}
}

public void SQL_OnClientPostAdminCheck(Database db, DBResultSet results, const char[] error, int userid)
public void SQL_OnClientPutInServer(Database db, DBResultSet results, const char[] error, int userid)
{
int client = GetClientOfUserId(userid);

if (!client || !TTT_IsClientValid(client) || IsFakeClient(client))
if (!TTT_IsClientValid(client) || IsFakeClient(client))
{
return;
}

if (db == null || strlen(error) > 0)
{
LogToFileEx(g_sErrorFile, "(SQL_OnClientPostAdminCheck) Query failed: %s", error);
LogToFileEx(g_sKarmaFile, "SQL_OnClientPutInServer - 1 (%N)", client);
LogToFileEx(g_sErrorFile, "(SQL_OnClientPutInServer) Query failed: %s", error);
return;
}
else
{
if (!results.HasResults)
if (results.RowCount > 0 && results.FetchRow())
{
g_iKarma[client] = g_cstartKarma.IntValue;
UpdatePlayer(client);
}
else
{
while (results.FetchRow())
{
char sCommunityID[64];
LogToFileEx(g_sKarmaFile, "SQL_OnClientPutInServer - 2 (%N), RowCount: %d", client, results.RowCount);

if (!GetClientAuthId(client, AuthId_SteamID64, sCommunityID, sizeof(sCommunityID)))
{
LogToFileEx(g_sErrorFile, "(SQL_OnClientPostAdminCheck) Auth failed: #%d", client);
return;
}
char sCommunityID[64];

int karma = results.FetchInt(0);
if (!GetClientAuthId(client, AuthId_SteamID64, sCommunityID, sizeof(sCommunityID)))
{
LogToFileEx(g_sErrorFile, "(SQL_OnClientPutInServer) Auth failed: #%d", client);
return;
}

LogToFileEx(g_sKarmaFile, "SQL_OnClientPutInServer - 3 (%N)", client);

if (g_cDebug.BoolValue)
{
LogToFileEx(g_sLogFile, "Name: %L has %d karma", client, karma);
}
int karma = results.FetchInt(0);

if (karma == 0)
{
g_iKarma[client] = g_cstartKarma.IntValue;
}
else
{
g_iKarma[client] = karma;
}
LogToFileEx(g_sKarmaFile, "SQL_OnClientPutInServer - 4 (%N) Karma: %d", client, karma);

CS_SetClientContributionScore(client, karma);
if (g_cDebugMessages.BoolValue)
{
LogToFileEx(g_sLogFile, "Name: \"%L\" has %d karma", client, karma);
}

g_bKarma[client] = true;
if (karma == 0)
{
g_iKarma[client] = g_cstartKarma.IntValue;
}
else
{
g_iKarma[client] = karma;
}

LogToFileEx(g_sKarmaFile, "SQL_OnClientPutInServer - 5 (%N), Karma (g): %d", client, g_iKarma[client]);

CS_SetClientContributionScore(client, karma);

g_bKarma[client] = true;

LogToFileEx(g_sKarmaFile, "SQL_OnClientPutInServer - 5 (%N), Karma (gB): %d", client, g_bKarma[client]);
}
else
{
g_iKarma[client] = g_cstartKarma.IntValue;
LogToFileEx(g_sKarmaFile, "SQL_OnClientPutInServer - 1.1 (%N), Karma: %d", client, g_iKarma[client]);
UpdatePlayer(client);
}
}
}

0 comments on commit 150963b

Please sign in to comment.