Permalink
Browse files

Prepare #54

  • Loading branch information...
Bara committed Jan 2, 2018
1 parent 48b86f7 commit 8aaa20560c3db19f1b4ea24b303648eab1a43717
Showing with 57 additions and 2 deletions.
  1. +8 −0 addons/sourcemod/scripting/ttt/core/sql.sp
  2. +49 −2 addons/sourcemod/scripting/ttt/ttt_shop.sp
@@ -6,9 +6,17 @@ public void SQL_AlterKarmaColumn(Handle owner, Handle hndl, const char[] error,
{
LogToFileEx(g_sErrorFile, "(SQL_AlterKarmaColumn) Query failed: %s", error);
}
else
{
LateLoadClients(false);
}
return;
}
else
{
LateLoadClients(false);
}
}
public void Callback_Karma(Handle owner, Handle hndl, const char[] error, any userid)
@@ -5,9 +5,10 @@
#include <sdktools>
#include <sdkhooks>
#include <cstrike>
#include <ttt>
#include <multicolors>
#include <clientprefs>
#include <ttt>
#include <ttt_sql>
#include <ttt_shop>
#define PLUGIN_NAME TTT_PLUGIN_NAME ... " - Shop"
@@ -70,6 +71,7 @@ int g_iCredits[MAXPLAYERS + 1] = { 0, ... };
bool g_bReopen[MAXPLAYERS + 1] = { true, ... };
Database g_dDB = null;
char g_sShopCMDs[][] = {
"menu",
@@ -224,6 +226,49 @@ public void OnConVarChanged(ConVar convar, const char[] oldValue, const char[] n
}
}
public void TTT_OnSQLConnect(Database db)
{
g_dDB = db;
AlterCreditsColumn();
}
void AlterCreditsColumn()
{
char sQuery[64];
Format(sQuery, sizeof(sQuery), "ALTER TABLE `ttt` ADD COLUMN `credits` INT(11) NOT NULL DEFAULT %d;", g_cStartCredits.IntValue);
if (g_dDB != null)
{
g_dDB.Query(SQL_AlterCreditsColumn, sQuery);
}
else
{
SetFailState("Database handle is invalid!");
return;
}
}
public void SQL_AlterCreditsColumn(Handle owner, Handle hndl, const char[] error, any userid)
{
if (hndl == null || strlen(error) > 0)
{
if (StrContains(error, "Duplicate column name") == -1)
{
LogError("(SQL_AlterCreditsColumn) Query failed: %s", error);
}
else
{
// LoadClientCredits(client);
}
return;
}
else
{
// LoadClientCredits(client);
}
}
public void OnClientCookiesCached(int client)
{
if (AreClientCookiesCached(client))
@@ -709,9 +754,11 @@ public Action Event_PlayerSpawn(Event event, const char[] name, bool dontBroadca
return Plugin_Continue;
}
public void OnClientPutInServer(int client)
public void OnClientPostAdminCheck(int client)
{
g_iCredits[client] = g_cStartCredits.IntValue;
// LoadClientCredits(client);
}
public Action Event_PlayerDeathPre(Event event, const char[] menu, bool dontBroadcast)

0 comments on commit 8aaa205

Please sign in to comment.