SHARE
TWEET

Untitled

a guest Jul 22nd, 2019 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. new Float:g_flSqlDelay;
  4. new Handle:g_hSqlTuple, Handle:g_hSqlConnection;
  5.  
  6.  
  7. public plugin_cfg()
  8. {
  9.     InitSQL();
  10. }
  11.  
  12. public plugin_end()
  13. {
  14.     SQL_FreeHandle(g_hSqlTuple);
  15.     if(g_hSqlConnection) SQL_FreeHandle(g_hSqlConnection);
  16. }
  17.  
  18.  
  19.  
  20.  
  21.  
  22. public InitSQL()
  23. {
  24.     g_hSqlTuple = SQL_MakeDbTuple(g_Cvars[HOST], g_Cvars[USER], g_Cvars[PASS], g_Cvars[DB]);
  25.     SQL_SetCharset(g_hSqlTuple, "utf-8");
  26.  
  27.     new iError, szError[128];
  28.     g_hSqlConnection = SQL_Connect(g_hSqlTuple, iError, szError, charsmax(szError));
  29.  
  30.     if(g_hSqlConnection == Empty_Handle)
  31.     {
  32.         set_fail_state("%s %d", szError, iError);
  33.         return;
  34.     }
  35.     ExecuteForward(g_hForwards[FORWARD_CONNECTION], _, g_hSqlTuple, g_hSqlConnection);
  36.  
  37.     new szQuery[1024];
  38.     new cData[1]; cData[0] = SQL_TABLE;
  39.     formatex(szQuery, charsmax(szQuery), "\
  40.         CREATE TABLE IF NOT EXISTS `%s` \
  41.         ( \
  42.             `id`            INT(11) NOT NULL auto_increment PRIMARY KEY, \
  43.             `clan_name`     VARCHAR(16) DEFAULT 'N/A', \
  44.             `clan_slots`    SMALLINT(6) DEFAULT 1, \
  45.             `clan_maxslots` SMALLINT(10) DEFAULT 0, \
  46.             `clan_exp`      INT(10) DEFAULT 0, \
  47.             `clan_created`  TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP \
  48.         ); \
  49.         CREATE TABLE IF NOT EXISTS `%s` \
  50.         ( \
  51.             `id`               INT(11) NOT NULL auto_increment PRIMARY KEY, \
  52.             `clan_id`          INT(11) DEFAULT 0, \
  53.             `player_name`      VARCHAR(32) DEFAULT 'N/A', \
  54.             `player_steamid`   VARCHAR(32) DEFAULT 'N/A', \
  55.             `player_ip`        VARCHAR(22) DEFAULT 'N/A', \
  56.             `player_access`    SMALLINT(6) DEFAULT 0, \
  57.             `player_last_seen` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP \
  58.         );", g_Cvars[TABLE_CLANS], g_Cvars[TABLE_PLAYERS]);
  59.     g_flSqlDelay = get_gametime();
  60.     SQL_ThreadQuery(g_hSqlTuple, "QueryHandler", szQuery, cData, sizeof(cData));
  61.     SQL_Clear();
  62. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top