Approved Infects (MySQL)

Plug-ins compatibility with Zombie Escape 1.x only!


Post Reply
User avatar
Night Fury
Mod Developer
Mod Developer
Posts: 677
Joined: 7 years ago
Contact:

Infects (MySQL)

#1

Post by Night Fury » 5 years ago

| Description:
  • This plugin is going to be like infects counter for zombies only.

| Cvars:
  • Code: Select all

    ze_infects_host // Host to connect to
    ze_infects_user // User to login with
    ze_infects_pass // Password
    ze_infects_dbname // Database

| Code:
    1. #include <zombie_escape>
    2.  
    3. // Static (Change it if you need)
    4. new const g_szLogFile[] = "Zombie_Infects.log" // MySQL Errors log file
    5.  
    6. // MySQL Table
    7. new const g_szTable[] =
    8. "ALTER TABLE `zombie_escape` ADD IF NOT EXISTS `Infects` INT(10) NOT NULL DEFAULT '0';"
    9.  
    10. // Variables
    11. new g_iInfects[33],
    12.     Handle:g_hTuple
    13.  
    14. // Cvars
    15. new g_pCvarDBInfo[4]
    16.  
    17. // Database
    18. enum
    19. {
    20.     Host = 0,
    21.     User,
    22.     Pass,
    23.     DB
    24. }
    25.  
    26. // Natives
    27. public plugin_natives()
    28. {
    29.     register_native("ze_get_user_infects", "native_ze_get_user_infects", 1)
    30.     register_native("ze_set_user_infects", "native_ze_set_user_infects", 1)
    31. }
    32.  
    33. public plugin_init()
    34. {
    35.     register_plugin("[ZE] Addons: Infects (MySQL)", "1.1", "Jack GamePlay")
    36.    
    37.     // Cvars
    38.     g_pCvarDBInfo[Host] = register_cvar("ze_infects_host", "localhost")
    39.     g_pCvarDBInfo[User] = register_cvar("ze_infects_user", "user")
    40.     g_pCvarDBInfo[Pass] = register_cvar("ze_infects_pass", "pass")
    41.     g_pCvarDBInfo[DB] = register_cvar("ze_infects_dbname", "dbname")
    42.  
    43.     // Initialize MySQL - Delay 0.1 second required so we make sure that our zombie_escape.cfg already executed and cvars values loaded from it
    44.     set_task(0.1, "Delay_MySQL_Init")
    45. }
    46.  
    47. public Delay_MySQL_Init()
    48. {
    49.     MySQL_Init()
    50. }
    51.  
    52. public MySQL_Init()
    53. {
    54.     new szHost[64], szUser[32], szPass[32], szDB[128]
    55.    
    56.     get_pcvar_string(g_pCvarDBInfo[Host], szHost, charsmax(szHost))
    57.     get_pcvar_string(g_pCvarDBInfo[User], szUser, charsmax(szUser))
    58.     get_pcvar_string(g_pCvarDBInfo[Pass], szPass, charsmax(szPass))
    59.     get_pcvar_string(g_pCvarDBInfo[DB], szDB, charsmax(szDB))
    60.    
    61.     g_hTuple = SQL_MakeDbTuple(szHost, szUser, szPass, szDB)
    62.    
    63.     // Let's ensure that the g_hTuple will be valid, we will access the database to make sure
    64.     new iErrorCode, szError[512], Handle:hSQLConnection
    65.    
    66.     hSQLConnection = SQL_Connect(g_hTuple, iErrorCode, szError, charsmax(szError))
    67.    
    68.     if(hSQLConnection != Empty_Handle)
    69.     {
    70.         log_amx("[MySQL][INFECTS] Successfully connected to host: %s (ALL IS OK).", szHost)
    71.         SQL_FreeHandle(hSQLConnection)
    72.     }
    73.     else
    74.     {
    75.         // Disable plugin, and display the error
    76.         set_fail_state("[INFECTS] Failed to connect to MySQL database: %s", szError)
    77.     }
    78.    
    79.     // Create our table
    80.     SQL_ThreadQuery(g_hTuple, "QueryCreateTable", g_szTable)
    81. }
    82.  
    83. public QueryCreateTable(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
    84. {
    85.     SQL_IsFail(iFailState, iError, szError, g_szLogFile)
    86. }
    87.  
    88. public client_putinserver(id)
    89. {
    90.     if (is_user_bot(id) || is_user_hltv(id))
    91.         return
    92.    
    93.     // Just 1 second delay
    94.     set_task(1.0, "DelayLoad", id)
    95. }
    96.  
    97. public DelayLoad(id)
    98. {
    99.     LoadInfects(id)
    100. }
    101.  
    102. public plugin_end()
    103. {
    104.     if (g_hTuple != Empty_Handle)
    105.     {
    106.         SQL_FreeHandle(g_hTuple)
    107.     }
    108. }
    109.  
    110. public ze_user_infected(iVictim, iInfector)
    111. {
    112.     if (iInfector == 0) // Server ID
    113.         return
    114.  
    115.     g_iInfects[iInfector] ++
    116.     SaveInfects(iInfector)
    117. }
    118.  
    119. LoadInfects(id)
    120. {
    121.     new szAuthID[35], szQuery[128], szData[5]
    122.     get_user_authid(id, szAuthID, charsmax(szAuthID))
    123.     formatex(szQuery, charsmax(szQuery), "SELECT `Infects` FROM `zombie_escape` WHERE ( `SteamID` = '%s' );", szAuthID)
    124.     num_to_str(id, szData, charsmax(szData))
    125.     SQL_ThreadQuery(g_hTuple, "QuerySelectData", szQuery, szData, charsmax(szData))
    126. }
    127.  
    128. public QuerySelectData(iFailState, Handle:hQuery, szError[], iError, szData[])
    129. {
    130.     if (SQL_IsFail(iFailState, iError, szError, g_szLogFile))
    131.         return
    132.    
    133.     new id = str_to_num(szData)
    134.    
    135.     // No results for this query means that player not saved before
    136.     if (!SQL_NumResults(hQuery))
    137.     {
    138.         // This is new player
    139.         g_iInfects[id] = 0
    140.         return
    141.     }
    142.    
    143.     g_iInfects[id] = SQL_ReadResult(hQuery, SQL_FieldNameToNum(hQuery, "Infects"))
    144. }
    145.  
    146. SaveInfects(id)
    147. {
    148.     new szAuthID[36]
    149.     get_user_authid(id, szAuthID, charsmax(szAuthID))
    150.    
    151.     new szQuery[128]
    152.     formatex(szQuery, charsmax(szQuery), "UPDATE `zombie_escape` SET `Infects` = '%d' WHERE `SteamID` = '%s';", g_iInfects[id], szAuthID)
    153.     SQL_ThreadQuery(g_hTuple, "QueryUpdateData", szQuery)
    154. }
    155.  
    156. public QueryInsertData(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
    157. {
    158.     SQL_IsFail(iFailState, iError, szError, g_szLogFile)
    159. }
    160.  
    161. public QueryUpdateData(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
    162. {
    163.     SQL_IsFail(iFailState, iError, szError, g_szLogFile)
    164. }
    165.  
    166. // Natives
    167. public native_ze_get_user_infects(id)
    168. {
    169.     if (!is_user_connected(id))
    170.     {
    171.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
    172.         return false
    173.     }
    174.    
    175.     return g_iInfects[id]
    176. }
    177.  
    178. public native_ze_set_user_infects(id, iAmount)
    179. {
    180.     if (!is_user_connected(id))
    181.     {
    182.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
    183.         return false
    184.     }
    185.    
    186.     g_iInfects[id] = iAmount
    187.     SaveInfects(id)
    188.     return true
    189. }
Want your own mod edition? PM me.
Accepting private projects.
Discord: Fury#7469
Image

Muhammet20
Veteran Member
Veteran Member
Posts: 408
Joined: 5 years ago
Contact:

#2

Post by Muhammet20 » 5 years ago

Great Work Jack

User avatar
Night Fury
Mod Developer
Mod Developer
Posts: 677
Joined: 7 years ago
Contact:

#3

Post by Night Fury » 4 years ago

Updated:
  • Updated plugin so all MySQL information will not be stored in several, instead will be stored in 1 column created by Escape Coins
Want your own mod edition? PM me.
Accepting private projects.
Discord: Fury#7469
Image

BandiT
Member
Member
Romania
Posts: 59
Joined: 4 years ago
Contact:

#4

Post by BandiT » 3 years ago

Mohamed Alaa wrote: 4 years ago Updated:
  • Updated plugin so all MySQL information will not be stored in several, instead will be stored in 1 column created by Escape Coins
Can you add nvault for this one alsoo ? :)

white1995
Member
Member
Malaysia
Posts: 1
Joined: 3 years ago
Contact:

#5

Post by white1995 » 3 years ago

BandiT wrote: 3 years ago
Mohamed Alaa wrote: 4 years ago Updated:
  • Updated plugin so all MySQL information will not be stored in several, instead will be stored in 1 column created by Escape Coins
Can you add nvault for this one alsoo ? :)
Here, try this.
  1.     #include <zombie_escape>
  2.    
  3.     new const g_szVaultName[] = "ZombieInfects"
  4.    
  5.     // Static (Change it if you need)
  6.     new const g_szLogFile[] = "Zombie_Infects.log" // MySQL Errors log file
  7.      
  8.     // MySQL Table
  9.     new const g_szTable[] =
  10.     "ALTER TABLE `zombie_escape` ADD IF NOT EXISTS `Infects` INT(10) NOT NULL DEFAULT '0';"
  11.      
  12.     // Variables
  13.     new g_iInfects[33],
  14.         Handle:g_hTuple,
  15.         g_iVaultHandle
  16.      
  17.     // Cvars
  18.     new g_pCvarDBInfo[4], g_pCvarSaveType
  19.      
  20.     // Database
  21.     enum
  22.     {
  23.         Host = 0,
  24.         User,
  25.         Pass,
  26.         DB
  27.     }
  28.      
  29.     // Natives
  30.     public plugin_natives()
  31.     {
  32.         register_native("ze_get_user_infects", "native_ze_get_user_infects", 1)
  33.         register_native("ze_set_user_infects", "native_ze_set_user_infects", 1)
  34.     }
  35.      
  36.     public plugin_init()
  37.     {
  38.         register_plugin("[ZE] Addons: Infects (MySQL)", "1.1", "Jack GamePlay")
  39.        
  40.         // Cvars
  41.         g_pCvarSaveType = register_cvar("ze_escapes_save_type", "0") // 0 =  nVault || 1 = MySQL
  42.         g_pCvarDBInfo[Host] = register_cvar("ze_infects_host", "localhost")
  43.         g_pCvarDBInfo[User] = register_cvar("ze_infects_user", "user")
  44.         g_pCvarDBInfo[Pass] = register_cvar("ze_infects_pass", "pass")
  45.         g_pCvarDBInfo[DB] = register_cvar("ze_infects_dbname", "dbname")
  46.      
  47.         // Initialize MySQL - Delay 0.1 second required so we make sure that our zombie_escape.cfg already executed and cvars values loaded from it
  48.         set_task(0.1, "Delay_MySQL_Init")
  49.     }
  50.      
  51.     public Delay_MySQL_Init()
  52.     {
  53.         MySQL_Init()
  54.     }
  55.      
  56.     public MySQL_Init()
  57.     {
  58.         if (!get_pcvar_num(g_pCvarSaveType))
  59.             return
  60.            
  61.         new szHost[64], szUser[32], szPass[32], szDB[128]
  62.        
  63.         get_pcvar_string(g_pCvarDBInfo[Host], szHost, charsmax(szHost))
  64.         get_pcvar_string(g_pCvarDBInfo[User], szUser, charsmax(szUser))
  65.         get_pcvar_string(g_pCvarDBInfo[Pass], szPass, charsmax(szPass))
  66.         get_pcvar_string(g_pCvarDBInfo[DB], szDB, charsmax(szDB))
  67.        
  68.         g_hTuple = SQL_MakeDbTuple(szHost, szUser, szPass, szDB)
  69.        
  70.         // Let's ensure that the g_hTuple will be valid, we will access the database to make sure
  71.         new iErrorCode, szError[512], Handle:hSQLConnection
  72.        
  73.         hSQLConnection = SQL_Connect(g_hTuple, iErrorCode, szError, charsmax(szError))
  74.        
  75.         if(hSQLConnection != Empty_Handle)
  76.         {
  77.             log_amx("[MySQL][INFECTS] Successfully connected to host: %s (ALL IS OK).", szHost)
  78.             SQL_FreeHandle(hSQLConnection)
  79.         }
  80.         else
  81.         {
  82.             // Disable plugin, and display the error
  83.             set_fail_state("[INFECTS] Failed to connect to MySQL database: %s", szError)
  84.         }
  85.        
  86.         // Create our table
  87.         SQL_ThreadQuery(g_hTuple, "QueryCreateTable", g_szTable)
  88.     }
  89.      
  90.     public QueryCreateTable(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
  91.     {
  92.         SQL_IsFail(iFailState, iError, szError, g_szLogFile)
  93.     }
  94.      
  95.     public client_putinserver(id)
  96.     {
  97.         if (is_user_bot(id) || is_user_hltv(id))
  98.             return
  99.        
  100.         // Just 1 second delay
  101.         set_task(1.0, "DelayLoad", id)
  102.     }
  103.      
  104.     public DelayLoad(id)
  105.     {
  106.         LoadInfects(id)
  107.     }
  108.      
  109.     public plugin_end()
  110.     {
  111.         if (!get_pcvar_num(g_pCvarSaveType))
  112.             return
  113.            
  114.         if (g_hTuple != Empty_Handle)
  115.         {
  116.             SQL_FreeHandle(g_hTuple)
  117.         }
  118.     }
  119.      
  120.     public ze_user_infected(iVictim, iInfector)
  121.     {
  122.         if (iInfector == 0) // Server ID
  123.             return
  124.      
  125.         g_iInfects[iInfector] ++
  126.         SaveInfects(iInfector)
  127.     }
  128.      
  129.     LoadInfects(id)
  130.     {
  131.         new szAuthID[35]
  132.         get_user_authid(id, szAuthID, charsmax(szAuthID))
  133.         if (!get_pcvar_num(g_pCvarSaveType))
  134.         {
  135.             // Open the Vault
  136.             g_iVaultHandle = nvault_open(g_szVaultName)
  137.            
  138.             // Get infects
  139.             new szInfects[16], iExists, iTimestamp;
  140.             iExists = nvault_lookup(g_iVaultHandle, szAuthID, szInfects, charsmax(szInfects), iTimestamp);
  141.            
  142.             // Close Vault
  143.             nvault_close(g_iVaultHandle)
  144.            
  145.             if (!iExists)
  146.             {
  147.                 SaveInfects(id)
  148.             }
  149.             else
  150.             {
  151.                 g_iInfects[id] = str_to_num(szInfects)
  152.             }
  153.         }
  154.         else
  155.         {
  156.             new szQuery[128], szData[5]
  157.             formatex(szQuery, charsmax(szQuery), "SELECT `Infects` FROM `zombie_escape` WHERE ( `SteamID` = '%s' );", szAuthID)
  158.             num_to_str(id, szData, charsmax(szData))
  159.             SQL_ThreadQuery(g_hTuple, "QuerySelectData", szQuery, szData, charsmax(szData))
  160.         }
  161.     }
  162.      
  163.     public QuerySelectData(iFailState, Handle:hQuery, szError[], iError, szData[])
  164.     {
  165.         if (SQL_IsFail(iFailState, iError, szError, g_szLogFile))
  166.             return
  167.        
  168.         new id = str_to_num(szData)
  169.        
  170.         // No results for this query means that player not saved before
  171.         if (!SQL_NumResults(hQuery))
  172.         {
  173.             // This is new player
  174.             g_iInfects[id] = 0
  175.             return
  176.         }
  177.        
  178.         g_iInfects[id] = SQL_ReadResult(hQuery, SQL_FieldNameToNum(hQuery, "Infects"))
  179.     }
  180.      
  181.     SaveInfects(id)
  182.     {
  183.         new szAuthID[36]
  184.         get_user_authid(id, szAuthID, charsmax(szAuthID))
  185.        
  186.         new szData[16]
  187.         num_to_str(g_iInfects[id], szData, charsmax(szData))
  188.        
  189.         if (!get_pcvar_num(g_pCvarSaveType))
  190.         {
  191.             // Open the Vault
  192.             g_iVaultHandle = nvault_open(g_szVaultName)
  193.      
  194.             // Save His SteamID, Escape Coins
  195.             nvault_set(g_iVaultHandle, szAuthID, szData)
  196.            
  197.             // Close Vault
  198.             nvault_close(g_iVaultHandle)
  199.         }
  200.        
  201.         else
  202.         {
  203.             new szQuery[128]
  204.             formatex(szQuery, charsmax(szQuery), "UPDATE `zombie_escape` SET `Infects` = '%d' WHERE `SteamID` = '%s';", g_iInfects[id], szAuthID)
  205.             SQL_ThreadQuery(g_hTuple, "QueryUpdateData", szQuery)
  206.         }
  207.     }
  208.      
  209.     public QueryInsertData(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
  210.     {
  211.         SQL_IsFail(iFailState, iError, szError, g_szLogFile)
  212.     }
  213.      
  214.     public QueryUpdateData(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
  215.     {
  216.         SQL_IsFail(iFailState, iError, szError, g_szLogFile)
  217.     }
  218.      
  219.     // Natives
  220.     public native_ze_get_user_infects(id)
  221.     {
  222.         if (!is_user_connected(id))
  223.         {
  224.             log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  225.             return false
  226.         }
  227.        
  228.         return g_iInfects[id]
  229.     }
  230.      
  231.     public native_ze_set_user_infects(id, iAmount)
  232.     {
  233.         if (!is_user_connected(id))
  234.         {
  235.             log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  236.             return false
  237.         }
  238.        
  239.         g_iInfects[id] = iAmount
  240.         SaveInfects(id)
  241.         return true
  242.     }

BandiT
Member
Member
Romania
Posts: 59
Joined: 4 years ago
Contact:

#6

Post by BandiT » 3 years ago

Thanks

User avatar
VicKy
Mod Tester
Mod Tester
Pakistan
Posts: 87
Joined: 3 years ago
Contact:

#7

Post by VicKy » 2 years ago

not increasing when i infect human
help me?
also escapes
Image

karan
Mod Tester
Mod Tester
India
Posts: 122
Joined: 6 years ago
Location: India
Contact:

#8

Post by karan » 2 years ago

VicKy wrote: 2 years ago not increasing when i infect human
help me?
also escapes
which version are u using?
of plugin and ze ?
also post ur code of infect nd escape counters.
Image

User avatar
VicKy
Mod Tester
Mod Tester
Pakistan
Posts: 87
Joined: 3 years ago
Contact:

#9

Post by VicKy » 2 years ago

karan wrote: 2 years ago
VicKy wrote: 2 years ago not increasing when i infect human
help me?
also escapes
which version are u using?
of plugin and ze ?
also post ur code of infect nd escape counters.
I Am Using Zombie Escape Modv1.6
The Code Of Infect Here :-
  1.     #include <zombie_escape>
  2.    
  3.     new const g_szVaultName[] = "InfectsZombie"
  4.    
  5.     // Static (Change it if you need)
  6.     new const g_szLogFile[] = "Zombie_Infects.log" // MySQL Errors log file
  7.      
  8.     // MySQL Table
  9.     new const g_szTable[] =
  10.     "ALTER TABLE `zombie_escape` ADD IF NOT EXISTS `Infects` INT(10) NOT NULL DEFAULT '0';"
  11.      
  12.     // Variables
  13.     new g_iInfects[33],
  14.         Handle:g_hTuple,
  15.         g_iVaultHandle
  16.      
  17.     // Cvars
  18.     new g_pCvarDBInfo[4], g_pCvarSaveType
  19.      
  20.     // Database
  21.     enum
  22.     {
  23.         Host = 0,
  24.         User,
  25.         Pass,
  26.         DB
  27.     }
  28.      
  29.     // Natives
  30.     public plugin_natives()
  31.     {
  32.         register_native("ze_get_user_infects", "native_ze_get_user_infects", 1)
  33.         register_native("ze_set_user_infects", "native_ze_set_user_infects", 1)
  34.     }
  35.      
  36.     public plugin_init()
  37.     {
  38.         register_plugin("[ZE] Addons: Infects (MySQL)", "1.1", "Jack GamePlay")
  39.        
  40.         // Cvars
  41.         g_pCvarSaveType = register_cvar("ze_escapes_save_type", "0") // 0 =  nVault || 1 = MySQL
  42.         g_pCvarDBInfo[Host] = register_cvar("ze_infects_host", "localhost")
  43.         g_pCvarDBInfo[User] = register_cvar("ze_infects_user", "user")
  44.         g_pCvarDBInfo[Pass] = register_cvar("ze_infects_pass", "pass")
  45.         g_pCvarDBInfo[DB] = register_cvar("ze_infects_dbname", "dbname")
  46.      
  47.         // Initialize MySQL - Delay 0.1 second required so we make sure that our zombie_escape.cfg already executed and cvars values loaded from it
  48.         set_task(0.1, "Delay_MySQL_Init")
  49.     }
  50.      
  51.     public Delay_MySQL_Init()
  52.     {
  53.         MySQL_Init()
  54.     }
  55.      
  56.     public MySQL_Init()
  57.     {
  58.         if (!get_pcvar_num(g_pCvarSaveType))
  59.             return
  60.            
  61.         new szHost[64], szUser[32], szPass[32], szDB[128]
  62.        
  63.         get_pcvar_string(g_pCvarDBInfo[Host], szHost, charsmax(szHost))
  64.         get_pcvar_string(g_pCvarDBInfo[User], szUser, charsmax(szUser))
  65.         get_pcvar_string(g_pCvarDBInfo[Pass], szPass, charsmax(szPass))
  66.         get_pcvar_string(g_pCvarDBInfo[DB], szDB, charsmax(szDB))
  67.        
  68.         g_hTuple = SQL_MakeDbTuple(szHost, szUser, szPass, szDB)
  69.        
  70.         // Let's ensure that the g_hTuple will be valid, we will access the database to make sure
  71.         new iErrorCode, szError[512], Handle:hSQLConnection
  72.        
  73.         hSQLConnection = SQL_Connect(g_hTuple, iErrorCode, szError, charsmax(szError))
  74.        
  75.         if(hSQLConnection != Empty_Handle)
  76.         {
  77.             log_amx("[MySQL][INFECTS] Successfully connected to host: %s (ALL IS OK).", szHost)
  78.             SQL_FreeHandle(hSQLConnection)
  79.         }
  80.         else
  81.         {
  82.             // Disable plugin, and display the error
  83.             set_fail_state("[INFECTS] Failed to connect to MySQL database: %s", szError)
  84.         }
  85.        
  86.         // Create our table
  87.         SQL_ThreadQuery(g_hTuple, "QueryCreateTable", g_szTable)
  88.     }
  89.      
  90.     public QueryCreateTable(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
  91.     {
  92.         SQL_IsFail(iFailState, iError, szError, g_szLogFile)
  93.     }
  94.      
  95.     public client_putinserver(id)
  96.     {
  97.         if (is_user_bot(id) || is_user_hltv(id))
  98.             return
  99.        
  100.         // Just 1 second delay
  101.         set_task(1.0, "DelayLoad", id)
  102.     }
  103.      
  104.     public DelayLoad(id)
  105.     {
  106.         LoadInfects(id)
  107.     }
  108.      
  109.     public plugin_end()
  110.     {
  111.         if (!get_pcvar_num(g_pCvarSaveType))
  112.             return
  113.            
  114.         if (g_hTuple != Empty_Handle)
  115.         {
  116.             SQL_FreeHandle(g_hTuple)
  117.         }
  118.     }
  119.      
  120.     public ze_user_infected(iVictim, iInfector)
  121.     {
  122.         if (iInfector == 0) // Server ID
  123.             return
  124.      
  125.         g_iInfects[iInfector] ++
  126.         SaveInfects(iInfector)
  127.     }
  128.      
  129.     LoadInfects(id)
  130.     {
  131.         new szAuthID[35]
  132.         get_user_authid(id, szAuthID, charsmax(szAuthID))
  133.         if (!get_pcvar_num(g_pCvarSaveType))
  134.         {
  135.             // Open the Vault
  136.             g_iVaultHandle = nvault_open(g_szVaultName)
  137.            
  138.             // Get infects
  139.             new szInfects[16], iExists, iTimestamp;
  140.             iExists = nvault_lookup(g_iVaultHandle, szAuthID, szInfects, charsmax(szInfects), iTimestamp);
  141.            
  142.             // Close Vault
  143.             nvault_close(g_iVaultHandle)
  144.            
  145.             if (!iExists)
  146.             {
  147.                 SaveInfects(id)
  148.             }
  149.             else
  150.             {
  151.                 g_iInfects[id] = str_to_num(szInfects)
  152.             }
  153.         }
  154.         else
  155.         {
  156.             new szQuery[128], szData[5]
  157.             formatex(szQuery, charsmax(szQuery), "SELECT `Infects` FROM `zombie_escape` WHERE ( `SteamID` = '%s' );", szAuthID)
  158.             num_to_str(id, szData, charsmax(szData))
  159.             SQL_ThreadQuery(g_hTuple, "QuerySelectData", szQuery, szData, charsmax(szData))
  160.         }
  161.     }
  162.      
  163.     public QuerySelectData(iFailState, Handle:hQuery, szError[], iError, szData[])
  164.     {
  165.         if (SQL_IsFail(iFailState, iError, szError, g_szLogFile))
  166.             return
  167.        
  168.         new id = str_to_num(szData)
  169.        
  170.         // No results for this query means that player not saved before
  171.         if (!SQL_NumResults(hQuery))
  172.         {
  173.             // This is new player
  174.             g_iInfects[id] = 0
  175.             return
  176.         }
  177.        
  178.         g_iInfects[id] = SQL_ReadResult(hQuery, SQL_FieldNameToNum(hQuery, "Infects"))
  179.     }
  180.      
  181.     SaveInfects(id)
  182.     {
  183.         new szAuthID[36]
  184.         get_user_authid(id, szAuthID, charsmax(szAuthID))
  185.        
  186.         new szData[16]
  187.         num_to_str(g_iInfects[id], szData, charsmax(szData))
  188.        
  189.         if (!get_pcvar_num(g_pCvarSaveType))
  190.         {
  191.             // Open the Vault
  192.             g_iVaultHandle = nvault_open(g_szVaultName)
  193.      
  194.             // Save His SteamID, Escape Coins
  195.             nvault_set(g_iVaultHandle, szAuthID, szData)
  196.            
  197.             // Close Vault
  198.             nvault_close(g_iVaultHandle)
  199.         }
  200.        
  201.         else
  202.         {
  203.             new szQuery[128]
  204.             formatex(szQuery, charsmax(szQuery), "UPDATE `zombie_escape` SET `Infects` = '%d' WHERE `SteamID` = '%s';", g_iInfects[id], szAuthID)
  205.             SQL_ThreadQuery(g_hTuple, "QueryUpdateData", szQuery)
  206.         }
  207.     }
  208.      
  209.     public QueryInsertData(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
  210.     {
  211.         SQL_IsFail(iFailState, iError, szError, g_szLogFile)
  212.     }
  213.      
  214.     public QueryUpdateData(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
  215.     {
  216.         SQL_IsFail(iFailState, iError, szError, g_szLogFile)
  217.     }
  218.      
  219.     // Natives
  220.     public native_ze_get_user_infects(id)
  221.     {
  222.         if (!is_user_connected(id))
  223.         {
  224.             log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  225.             return false
  226.         }
  227.        
  228.         return g_iInfects[id]
  229.     }
  230.      
  231.     public native_ze_set_user_infects(id, iAmount)
  232.     {
  233.         if (!is_user_connected(id))
  234.         {
  235.             log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  236.             return false
  237.         }
  238.        
  239.         g_iInfects[id] = iAmount
  240.         SaveInfects(id)
  241.         return true
  242.     }
The Code Of Escape Here :-
  1. #include <zombie_escape>
  2.  
  3. new const g_szVaultName[] = "HumanEscapes"
  4.  
  5. // Static (Change it if you need)
  6. new const g_szLogFile[] = "Human_Escapes.log" // MySQL Errors log file
  7.  
  8. // MySQL Table
  9. new const g_szTable[] =
  10. "ALTER TABLE `zombie_escape` ADD IF NOT EXISTS `Escapes` INT(10) NOT NULL DEFAULT '0';"
  11.  
  12. // Variables
  13. new g_iEscapes[33],
  14.     Handle:g_hTuple,
  15.     g_iVaultHandle
  16.  
  17. // Cvars
  18. new g_pCvarDBInfo[4], g_pCvarSaveType
  19.  
  20. // Database
  21. enum
  22. {
  23.     Host = 0,
  24.     User,
  25.     Pass,
  26.     DB
  27. }
  28.  
  29. // Natives
  30. public plugin_natives()
  31. {
  32.     register_native("ze_get_user_escapes", "native_ze_get_user_escapes", 1)
  33.     register_native("ze_set_user_escapes", "native_ze_set_user_escapes", 1)
  34. }
  35.  
  36. public plugin_init()
  37. {
  38.     register_plugin("[ZE] Addons: Escapes (MySQL)", "1.1", "Jack GamePlay")
  39.    
  40.     // Cvars
  41.     g_pCvarSaveType = register_cvar("ze_escapes_save_type", "0") // 0 =  nVault || 1 = MySQL
  42.     g_pCvarDBInfo[Host] = register_cvar("ze_escapes_host", "localhost")
  43.     g_pCvarDBInfo[User] = register_cvar("ze_escapes_user", "user")
  44.     g_pCvarDBInfo[Pass] = register_cvar("ze_escapes_pass", "pass")
  45.     g_pCvarDBInfo[DB] = register_cvar("ze_escapes_dbname", "dbname")
  46.  
  47.     // Initialize MySQL - Delay 0.1 second required so we make sure that our zombie_escape.cfg already executed and cvars values loaded from it
  48.     set_task(0.1, "Delay_MySQL_Init")
  49. }
  50.  
  51. public Delay_MySQL_Init()
  52. {
  53.     MySQL_Init()
  54. }
  55.  
  56. public MySQL_Init()
  57. {
  58.     if (!get_pcvar_num(g_pCvarSaveType))
  59.         return
  60.    
  61.     new szHost[64], szUser[32], szPass[32], szDB[128]
  62.    
  63.     get_pcvar_string(g_pCvarDBInfo[Host], szHost, charsmax(szHost))
  64.     get_pcvar_string(g_pCvarDBInfo[User], szUser, charsmax(szUser))
  65.     get_pcvar_string(g_pCvarDBInfo[Pass], szPass, charsmax(szPass))
  66.     get_pcvar_string(g_pCvarDBInfo[DB], szDB, charsmax(szDB))
  67.    
  68.     g_hTuple = SQL_MakeDbTuple(szHost, szUser, szPass, szDB)
  69.    
  70.     // Let's ensure that the g_hTuple will be valid, we will access the database to make sure
  71.     new iErrorCode, szError[512], Handle:hSQLConnection
  72.    
  73.     hSQLConnection = SQL_Connect(g_hTuple, iErrorCode, szError, charsmax(szError))
  74.    
  75.     if(hSQLConnection != Empty_Handle)
  76.     {
  77.         log_amx("[MySQL][ESCAPES] Successfully connected to host: %s (ALL IS OK).", szHost)
  78.         SQL_FreeHandle(hSQLConnection)
  79.     }
  80.     else
  81.     {
  82.         // Disable plugin, and display the error
  83.         set_fail_state("[ESCAPES] Failed to connect to MySQL database: %s", szError)
  84.     }
  85.    
  86.     // Create our table
  87.     SQL_ThreadQuery(g_hTuple, "QueryCreateTable", g_szTable)
  88. }
  89.  
  90. public QueryCreateTable(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
  91. {
  92.     SQL_IsFail(iFailState, iError, szError, g_szLogFile)
  93. }
  94.  
  95. public client_putinserver(id)
  96. {
  97.     if (is_user_bot(id) || is_user_hltv(id))
  98.         return
  99.    
  100.     // Just 1 second delay
  101.     set_task(1.0, "DelayLoad", id)
  102. }
  103.  
  104. public DelayLoad(id)
  105. {
  106.     LoadEscapes(id)
  107. }
  108.  
  109. public plugin_end()
  110. {
  111.     if (!get_pcvar_num(g_pCvarSaveType))
  112.         return
  113.    
  114.     if (g_hTuple != Empty_Handle)
  115.     {
  116.         SQL_FreeHandle(g_hTuple)
  117.     }
  118. }
  119.  
  120. public ze_roundend(WinTeam)
  121. {
  122.     if (WinTeam == ZE_TEAM_HUMAN)
  123.     {
  124.         for (new id = 0; id <= get_member_game(m_nMaxPlayers); id++)
  125.         {
  126.             if (!is_user_alive(id) || ze_is_user_zombie(id))
  127.                 continue
  128.  
  129.             g_iEscapes[id] ++
  130.             SaveEscapes(id)
  131.         }
  132.     }
  133. }
  134.  
  135. LoadEscapes(id)
  136. {
  137.     new szAuthID[35]
  138.     get_user_authid(id, szAuthID, charsmax(szAuthID))
  139.    
  140.     if (!get_pcvar_num(g_pCvarSaveType))
  141.     {
  142.         // Open the Vault
  143.         g_iVaultHandle = nvault_open(g_szVaultName)
  144.        
  145.         // Get escapes
  146.         new szEscapes[16], iExists, iTimestamp;
  147.         iExists = nvault_lookup(g_iVaultHandle, szAuthID, szEscapes, charsmax(szEscapes), iTimestamp);
  148.        
  149.         // Close Vault
  150.         nvault_close(g_iVaultHandle)
  151.        
  152.         if (!iExists)
  153.         {
  154.             SaveEscapes(id)
  155.         }
  156.         else
  157.         {
  158.             g_iEscapes[id] = str_to_num(szEscapes)
  159.         }
  160.     }
  161.     else
  162.     {
  163.         new szQuery[128], szData[5]
  164.  
  165.         formatex(szQuery, charsmax(szQuery), "SELECT `Escapes` FROM `zombie_escape` WHERE ( `SteamID` = '%s' );", szAuthID)
  166.         num_to_str(id, szData, charsmax(szData))
  167.         SQL_ThreadQuery(g_hTuple, "QuerySelectData", szQuery, szData, charsmax(szData))
  168.     }
  169. }
  170.  
  171. public QuerySelectData(iFailState, Handle:hQuery, szError[], iError, szData[])
  172. {
  173.     if (SQL_IsFail(iFailState, iError, szError, g_szLogFile))
  174.         return
  175.    
  176.     new id = str_to_num(szData)
  177.    
  178.     // No results for this query means that player not saved before
  179.     if (!SQL_NumResults(hQuery))
  180.     {
  181.         // This is new player
  182.         g_iEscapes[id] = 0
  183.         return
  184.     }
  185.    
  186.     g_iEscapes[id] = SQL_ReadResult(hQuery, SQL_FieldNameToNum(hQuery, "Escapes"))
  187. }
  188.  
  189. SaveEscapes(id)
  190. {
  191.     new szAuthID[35]
  192.     get_user_authid(id, szAuthID, charsmax(szAuthID))
  193.    
  194.     new szData[16]
  195.     num_to_str(g_iEscapes[id], szData, charsmax(szData))
  196.    
  197.     if (!get_pcvar_num(g_pCvarSaveType))
  198.     {
  199.         // Open the Vault
  200.         g_iVaultHandle = nvault_open(g_szVaultName)
  201.  
  202.         // Save His SteamID, Escape Coins
  203.         nvault_set(g_iVaultHandle, szAuthID, szData)
  204.        
  205.         // Close Vault
  206.         nvault_close(g_iVaultHandle)
  207.     }
  208.     else
  209.     {
  210.         new szQuery[128]
  211.        
  212.         formatex(szQuery, charsmax(szQuery), "UPDATE `zombie_escape` SET `Escapes` = '%d' WHERE `SteamID` = '%s';", g_iEscapes[id], szAuthID)
  213.         SQL_ThreadQuery(g_hTuple, "QueryUpdateData", szQuery)
  214.     }
  215. }
  216.  
  217. public QueryInsertData(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
  218. {
  219.     SQL_IsFail(iFailState, iError, szError, g_szLogFile)
  220. }
  221.  
  222. public QueryUpdateData(iFailState, Handle:hQuery, szError[], iError, szData[], iSize, Float:flQueueTime)
  223. {
  224.     SQL_IsFail(iFailState, iError, szError, g_szLogFile)
  225. }
  226.  
  227. // Natives
  228. public native_ze_get_user_escapes(id)
  229. {
  230.     if (!is_user_connected(id))
  231.     {
  232.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  233.         return false
  234.     }
  235.    
  236.     return g_iEscapes[id]
  237. }
  238.  
  239. public native_ze_set_user_escapes(id, iAmount)
  240. {
  241.     if (!is_user_connected(id))
  242.     {
  243.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  244.         return false
  245.     }
  246.    
  247.     g_iEscapes[id] = iAmount
  248.     SaveEscapes(id)
  249.     return true
  250. }
Links Using Of These Plugins :-

Escapes :- viewtopic.php?f=15&t=3560
Infects :- viewtopic.php?f=15&t=3561
Hud :- viewtopic.php?f=7&t=3563

I Am Using The Nvault Updated

The Code Of Hud_Info :-
  1. #include <zombie_escape>
  2.  
  3. // Define some natives
  4. native ze_get_user_escapes(id)
  5. native ze_get_user_infects(id)
  6.  
  7. // Defines
  8. #define TASK_SHOWHUD 100
  9. #define ID_SHOWHUD (taskid - TASK_SHOWHUD)
  10.  
  11. // Constants Change X,Y If you need (HUD & DHud)
  12. const Float:HUD_SPECT_X = 0.01
  13. const Float:HUD_SPECT_Y = 0.130
  14. const Float:HUD_STATS_X = -1.0
  15. const Float:HUD_STATS_Y = 0.86
  16.  
  17. // Colors
  18. enum
  19. {
  20.     Red = 0,
  21.     Green,
  22.     Blue
  23. }
  24.  
  25. // Variables
  26. new g_iMsgSync,
  27.     g_pCvarRankEnabled
  28.    
  29. // Cvars
  30. new g_pCvarHudInfoMode,
  31.     g_pCvarHudInfoComma,
  32.     g_pCvarZombieInfoColors[3],
  33.     g_pCvarHumanInfoColors[3],
  34.     g_pCvarSpecInfoColors[3]
  35.  
  36. public plugin_init()
  37. {
  38.     register_plugin("[ZE] Hud Information", ZE_VERSION, AUTHORS)
  39.    
  40.     // Messages
  41.     g_iMsgSync = CreateHudSyncObj()
  42.    
  43.     //Cvars
  44.     g_pCvarHudInfoMode = register_cvar("ze_hud_info_mode", "1")
  45.     g_pCvarHudInfoComma = register_cvar("ze_hud_info_commas", "1")
  46.     g_pCvarZombieInfoColors[Red] = register_cvar("ze_hud_info_zombie_red", "255")
  47.     g_pCvarZombieInfoColors[Green] = register_cvar("ze_hud_info_zombie_green", "20")
  48.     g_pCvarZombieInfoColors[Blue] = register_cvar("ze_hud_info_zombie_blue", "20")
  49.     g_pCvarHumanInfoColors[Red] = register_cvar("ze_hud_info_human_red", "20")
  50.     g_pCvarHumanInfoColors[Green] = register_cvar("ze_hud_info_human_green", "20")
  51.     g_pCvarHumanInfoColors[Blue] = register_cvar("ze_hud_info_human_blue", "255")
  52.     g_pCvarSpecInfoColors[Red] = register_cvar("ze_hud_info_spec_red", "100")
  53.     g_pCvarSpecInfoColors[Green] = register_cvar("ze_hud_info_spec_green", "100")
  54.     g_pCvarSpecInfoColors[Blue] = register_cvar("ze_hud_info_spec_blue", "100")
  55.    
  56.     // Pointer
  57.     g_pCvarRankEnabled = get_cvar_pointer("ze_speed_rank_mode")
  58. }
  59.  
  60. public client_putinserver(id)
  61. {
  62.     if(!is_user_bot(id))
  63.     {
  64.         set_task(1.0, "ShowHUD", id+TASK_SHOWHUD, _, _, "b")
  65.     }
  66. }
  67.  
  68. public client_disconnected(id)
  69. {
  70.     remove_task(id+TASK_SHOWHUD)
  71. }
  72.  
  73. public ShowHUD(taskid)
  74. {
  75.     if (get_pcvar_num(g_pCvarHudInfoMode) == 0)
  76.         return
  77.    
  78.     new iPlayer = ID_SHOWHUD
  79.    
  80.     if (!is_user_alive(iPlayer))
  81.     {
  82.         iPlayer = get_entvar(iPlayer, var_iuser2)
  83.        
  84.         if (!is_user_alive(iPlayer))
  85.             return
  86.     }
  87.    
  88.     if(iPlayer != ID_SHOWHUD)
  89.     {
  90.         new szName[32]
  91.         get_user_name(iPlayer, szName, charsmax(szName))
  92.  
  93.         if (get_pcvar_num(g_pCvarHudInfoMode) == 1)
  94.         {
  95.             set_hudmessage(get_pcvar_num(g_pCvarSpecInfoColors[Red]), get_pcvar_num(g_pCvarSpecInfoColors[Green]), get_pcvar_num(g_pCvarSpecInfoColors[Blue]), HUD_SPECT_X, HUD_SPECT_Y, 0, 1.2, 1.1, 0.5, 0.6, -1)
  96.            
  97.             if (get_pcvar_num(g_pCvarHudInfoComma) == 1)
  98.             {
  99.                 new szHealth[15]
  100.                 AddCommas(get_user_health(iPlayer), szHealth, charsmax(szHealth))
  101.                
  102.                 if (ze_is_user_zombie(iPlayer))
  103.                 {
  104.                     ShowSyncHudMsg(ID_SHOWHUD, g_iMsgSync, "%L", LANG_PLAYER, "ZOMBIE_SPEC_COMMAS", szName, szHealth, ze_get_escape_coins(iPlayer), ze_get_user_escapes(iPlayer), ze_get_user_infects(iPlayer))
  105.                 }
  106.                 else if ((iPlayer == ze_get_escape_leader_id()) && (0 < get_pcvar_num(g_pCvarRankEnabled) <= 2))
  107.                 {
  108.                     ShowSyncHudMsg(ID_SHOWHUD, g_iMsgSync, "%L", LANG_PLAYER, "HUMAN_SPEC_COMMAS_LEADER", szName, szHealth, ze_get_escape_coins(iPlayer), ze_get_user_escapes(iPlayer), ze_get_user_infects(iPlayer))
  109.                 }
  110.                 else
  111.                 {
  112.                     ShowSyncHudMsg(ID_SHOWHUD, g_iMsgSync, "%L", LANG_PLAYER, "HUMAN_SPEC_COMMAS", szName, szHealth, ze_get_escape_coins(iPlayer), ze_get_user_escapes(iPlayer), ze_get_user_infects(iPlayer))
  113.                 }
  114.             }
  115.             else
  116.             {
  117.                 if (ze_is_user_zombie(iPlayer))
  118.                 {
  119.                     ShowSyncHudMsg(ID_SHOWHUD, g_iMsgSync, "%L", LANG_PLAYER, "ZOMBIE_SPEC", szName, get_user_health(iPlayer), ze_get_escape_coins(iPlayer), ze_get_user_escapes(iPlayer), ze_get_user_infects(iPlayer))
  120.                 }
  121.                 else if ((iPlayer == ze_get_escape_leader_id()) && (0 < get_pcvar_num(g_pCvarRankEnabled) <= 2))
  122.                 {
  123.                     ShowSyncHudMsg(ID_SHOWHUD, g_iMsgSync, "%L", LANG_PLAYER, "HUMAN_SPEC_LEADER", szName, get_user_health(iPlayer), ze_get_escape_coins(iPlayer), ze_get_user_escapes(iPlayer), ze_get_user_infects(iPlayer))
  124.                 }
  125.                 else
  126.                 {
  127.                     ShowSyncHudMsg(ID_SHOWHUD, g_iMsgSync, "%L", LANG_PLAYER, "HUMAN_SPEC", szName, get_user_health(iPlayer), ze_get_escape_coins(iPlayer), ze_get_user_escapes(iPlayer), ze_get_user_infects(iPlayer))
  128.                 }
  129.             }
  130.         }
  131.         else if (get_pcvar_num(g_pCvarHudInfoMode) == 2)
  132.         {
  133.             set_dhudmessage(get_pcvar_num(g_pCvarSpecInfoColors[Red]), get_pcvar_num(g_pCvarSpecInfoColors[Green]), get_pcvar_num(g_pCvarSpecInfoColors[Blue]), HUD_SPECT_X, HUD_SPECT_Y, 0, 1.2, 1.1, 0.5, 0.6)
  134.            
  135.             if (get_pcvar_num(g_pCvarHudInfoComma) == 1)
  136.             {
  137.                 new szHealth[15]
  138.                 AddCommas(get_user_health(iPlayer), szHealth, charsmax(szHealth))
  139.                
  140.                 if (ze_is_user_zombie(iPlayer))
  141.                 {
  142.                     show_dhudmessage(ID_SHOWHUD, "%L", LANG_PLAYER, "ZOMBIE_SPEC_COMMAS", szName, szHealth, ze_get_escape_coins(iPlayer), ze_get_user_escapes(iPlayer), ze_get_user_infects(iPlayer))
  143.                 }
  144.                 else if ((iPlayer == ze_get_escape_leader_id()) && (0 < get_pcvar_num(g_pCvarRankEnabled) <= 2))
  145.                 {
  146.                     show_dhudmessage(ID_SHOWHUD, "%L", LANG_PLAYER, "HUMAN_SPEC_COMMAS_LEADER", szName, szHealth, ze_get_escape_coins(iPlayer), ze_get_user_escapes(iPlayer), ze_get_user_infects(iPlayer))
  147.                 }
  148.                 else
  149.                 {
  150.                     show_dhudmessage(ID_SHOWHUD, "%L", LANG_PLAYER, "HUMAN_SPEC_COMMAS", szName, szHealth, ze_get_escape_coins(iPlayer), ze_get_user_escapes(iPlayer), ze_get_user_infects(iPlayer))
  151.                 }
  152.             }
  153.             else
  154.             {
  155.                 if (ze_is_user_zombie(iPlayer))
  156.                 {
  157.                     show_dhudmessage(ID_SHOWHUD, "%L", LANG_PLAYER, "ZOMBIE_SPEC", szName, get_user_health(iPlayer), ze_get_escape_coins(iPlayer), ze_get_user_escapes(iPlayer), ze_get_user_infects(iPlayer))
  158.                 }
  159.                 else if ((iPlayer == ze_get_escape_leader_id()) && (0 < get_pcvar_num(g_pCvarRankEnabled) <= 2))
  160.                 {
  161.                     show_dhudmessage(ID_SHOWHUD, "%L", LANG_PLAYER, "HUMAN_SPEC_LEADER", szName, get_user_health(iPlayer), ze_get_escape_coins(iPlayer), ze_get_user_escapes(iPlayer), ze_get_user_infects(iPlayer))
  162.                 }
  163.                 else
  164.                 {
  165.                     show_dhudmessage(ID_SHOWHUD, "%L", LANG_PLAYER, "HUMAN_SPEC", szName, get_user_health(iPlayer), ze_get_escape_coins(iPlayer), ze_get_user_escapes(iPlayer), ze_get_user_infects(iPlayer))
  166.                 }
  167.             }
  168.         }
  169.     }
  170.     else if (ze_is_user_zombie(iPlayer))
  171.     {
  172.         if (get_pcvar_num(g_pCvarHudInfoMode) == 1)
  173.         {
  174.             set_hudmessage(get_pcvar_num(g_pCvarZombieInfoColors[Red]), get_pcvar_num(g_pCvarZombieInfoColors[Green]), get_pcvar_num(g_pCvarZombieInfoColors[Blue]), HUD_STATS_X, HUD_STATS_Y, 0, 1.2, 1.1, 0.5, 0.6, -1)
  175.            
  176.             if (get_pcvar_num(g_pCvarHudInfoComma) == 1)
  177.             {
  178.                 new szHealth[15]
  179.                 AddCommas(get_user_health(ID_SHOWHUD), szHealth, charsmax(szHealth))
  180.  
  181.                 ShowSyncHudMsg(ID_SHOWHUD, g_iMsgSync, "%L", LANG_PLAYER, "ZOMBIE_COMMAS", szHealth, ze_get_escape_coins(ID_SHOWHUD), ze_get_user_escapes(ID_SHOWHUD), ze_get_user_infects(ID_SHOWHUD))
  182.             }
  183.             else
  184.             {
  185.                 ShowSyncHudMsg(ID_SHOWHUD, g_iMsgSync, "%L", LANG_PLAYER, "ZOMBIE", get_user_health(ID_SHOWHUD), ze_get_escape_coins(ID_SHOWHUD), ze_get_user_escapes(ID_SHOWHUD), ze_get_user_infects(ID_SHOWHUD))
  186.             }
  187.         }
  188.         else if (get_pcvar_num(g_pCvarHudInfoMode) == 2)
  189.         {
  190.             set_dhudmessage(get_pcvar_num(g_pCvarZombieInfoColors[Red]), get_pcvar_num(g_pCvarZombieInfoColors[Green]), get_pcvar_num(g_pCvarZombieInfoColors[Blue]), HUD_STATS_X, HUD_STATS_Y, 0, 1.2, 1.1, 0.5, 0.6)
  191.            
  192.             if (get_pcvar_num(g_pCvarHudInfoComma) == 1)
  193.             {
  194.                 new szHealth[15]
  195.                 AddCommas(get_user_health(ID_SHOWHUD), szHealth, charsmax(szHealth))
  196.                
  197.                 show_dhudmessage(ID_SHOWHUD, "%L", LANG_PLAYER, "ZOMBIE_COMMAS", szHealth, ze_get_escape_coins(ID_SHOWHUD), ze_get_user_escapes(ID_SHOWHUD), ze_get_user_infects(ID_SHOWHUD))
  198.             }
  199.             else
  200.             {
  201.                 show_dhudmessage(ID_SHOWHUD, "%L", LANG_PLAYER, "ZOMBIE", get_user_health(ID_SHOWHUD), ze_get_escape_coins(ID_SHOWHUD), ze_get_user_escapes(ID_SHOWHUD), ze_get_user_infects(ID_SHOWHUD))  
  202.             }
  203.         }
  204.     }
  205.     else
  206.     {
  207.         if (get_pcvar_num(g_pCvarHudInfoMode) == 1)
  208.         {
  209.             set_hudmessage(get_pcvar_num(g_pCvarHumanInfoColors[Red]), get_pcvar_num(g_pCvarHumanInfoColors[Green]), get_pcvar_num(g_pCvarHumanInfoColors[Blue]), HUD_STATS_X, HUD_STATS_Y, 0, 1.2, 1.1, 0.5, 0.6, -1)
  210.            
  211.             if (get_pcvar_num(g_pCvarHudInfoComma) == 1)
  212.             {
  213.                 if ((ID_SHOWHUD == ze_get_escape_leader_id()) && (0 < get_pcvar_num(g_pCvarRankEnabled) <= 2))
  214.                 {
  215.                     new szHealth[15]
  216.                     AddCommas(get_user_health(ID_SHOWHUD), szHealth, charsmax(szHealth))
  217.                
  218.                     ShowSyncHudMsg(ID_SHOWHUD, g_iMsgSync, "%L", LANG_PLAYER, "HUMAN_LEADER_COMMAS", szHealth, ze_get_escape_coins(ID_SHOWHUD), ze_get_user_escapes(ID_SHOWHUD), ze_get_user_infects(ID_SHOWHUD))
  219.                 }
  220.                 else
  221.                 {
  222.                     new szHealth[15]
  223.                     AddCommas(get_user_health(ID_SHOWHUD), szHealth, charsmax(szHealth))
  224.                
  225.                     ShowSyncHudMsg(ID_SHOWHUD, g_iMsgSync, "%L", LANG_PLAYER, "HUMAN_COMMAS", szHealth, ze_get_escape_coins(ID_SHOWHUD), ze_get_user_escapes(ID_SHOWHUD), ze_get_user_infects(ID_SHOWHUD))
  226.                 }                  
  227.             }
  228.             else
  229.             {
  230.                 if ((ID_SHOWHUD == ze_get_escape_leader_id()) && (0 < get_pcvar_num(g_pCvarRankEnabled) <= 2))
  231.                 {
  232.                     ShowSyncHudMsg(ID_SHOWHUD, g_iMsgSync, "%L", LANG_PLAYER, "HUMAN_LEADER", get_user_health(ID_SHOWHUD), ze_get_escape_coins(ID_SHOWHUD), ze_get_user_escapes(ID_SHOWHUD), ze_get_user_infects(ID_SHOWHUD))
  233.                 }
  234.                 else
  235.                 {
  236.                     ShowSyncHudMsg(ID_SHOWHUD, g_iMsgSync, "%L", LANG_PLAYER, "HUMAN", get_user_health(ID_SHOWHUD), ze_get_escape_coins(ID_SHOWHUD), ze_get_user_escapes(ID_SHOWHUD), ze_get_user_infects(ID_SHOWHUD))
  237.                 }                  
  238.             }
  239.         }
  240.         else if (get_pcvar_num(g_pCvarHudInfoMode) == 2)
  241.         {
  242.             set_dhudmessage(get_pcvar_num(g_pCvarHumanInfoColors[Red]), get_pcvar_num(g_pCvarHumanInfoColors[Green]), get_pcvar_num(g_pCvarHumanInfoColors[Blue]), HUD_STATS_X, HUD_STATS_Y, 0, 1.2, 1.1, 0.5, 0.6)
  243.            
  244.             if (get_pcvar_num(g_pCvarHudInfoComma) == 1)
  245.             {
  246.                 if ((ID_SHOWHUD == ze_get_escape_leader_id()) && (0 < get_pcvar_num(g_pCvarRankEnabled) <= 2))
  247.                 {
  248.                     new szHealth[15]
  249.                     AddCommas(get_user_health(ID_SHOWHUD), szHealth, charsmax(szHealth))
  250.                
  251.                     show_dhudmessage(ID_SHOWHUD, "%L", LANG_PLAYER, "HUMAN_LEADER_COMMAS", szHealth, ze_get_escape_coins(ID_SHOWHUD), ze_get_user_escapes(ID_SHOWHUD), ze_get_user_infects(ID_SHOWHUD))
  252.                 }
  253.                 else
  254.                 {
  255.                     new szHealth[15]
  256.                     AddCommas(get_user_health(ID_SHOWHUD), szHealth, charsmax(szHealth))
  257.                
  258.                     show_dhudmessage(ID_SHOWHUD, "%L", LANG_PLAYER, "HUMAN_COMMAS", szHealth, ze_get_escape_coins(ID_SHOWHUD), ze_get_user_escapes(ID_SHOWHUD), ze_get_user_infects(ID_SHOWHUD))
  259.                 }
  260.             }
  261.             else
  262.             {
  263.                 if ((ID_SHOWHUD == ze_get_escape_leader_id()) && (0 < get_pcvar_num(g_pCvarRankEnabled) <= 2))
  264.                 {
  265.                     show_dhudmessage(ID_SHOWHUD, "%L", LANG_PLAYER, "HUMAN_LEADER", get_user_health(ID_SHOWHUD), ze_get_escape_coins(ID_SHOWHUD), ze_get_user_escapes(ID_SHOWHUD), ze_get_user_infects(ID_SHOWHUD))
  266.                 }
  267.                 else
  268.                 {
  269.                     show_dhudmessage(ID_SHOWHUD, "%L", LANG_PLAYER, "HUMAN", get_user_health(ID_SHOWHUD), ze_get_escape_coins(ID_SHOWHUD), ze_get_user_escapes(ID_SHOWHUD), ze_get_user_infects(ID_SHOWHUD))
  270.                 }
  271.             }
  272.         }
  273.     }
  274. }
Image

karan
Mod Tester
Mod Tester
India
Posts: 122
Joined: 6 years ago
Location: India
Contact:

#10

Post by karan » 2 years ago

  1. #include <zombie_escape>
  2.  
  3.  
  4. // Static (Change it if you need)
  5. new const g_szInfectsVault[] = "Infects"
  6.  
  7. // Variables
  8. new g_iInfects[33],
  9.     g_iInfectsVaultHandle
  10.  
  11.  
  12. // Natives
  13. public plugin_natives()
  14. {
  15.     register_native("ze_get_user_infects", "native_ze_get_user_infects", 1)
  16.     register_native("ze_set_user_infects", "native_ze_set_user_infects", 1)
  17. }
  18.  
  19. public plugin_init()
  20. {
  21.     register_plugin("Infect Count", "1.0", "ZE-DEV-TEAM")
  22. }
  23.  
  24. public client_putinserver(id)
  25. {
  26.     if (is_user_bot(id) || is_user_hltv(id))
  27.         return
  28.    
  29.     // Just 1 second delay
  30.     set_task(1.0, "DelayLoad", id)
  31. }
  32.  
  33. public DelayLoad(id)
  34. {
  35.     LoadInfects(id)
  36. }
  37.  
  38. public ze_user_infected(iVictim, iInfector)
  39. {
  40.     if (iInfector == 0) // Server ID
  41.         return
  42.  
  43.     g_iInfects[iInfector] ++
  44.     SaveInfects(iInfector)
  45. }
  46.  
  47. LoadInfects(id)
  48. {
  49.     new szData[256], szAuthID[35]
  50.    
  51.     get_user_authid(id, szAuthID, charsmax(szAuthID))
  52.    
  53.     // Useless Variable
  54.     new iTimestamp, iExists
  55.    
  56.     // Open the Vault
  57.     g_iInfectsVaultHandle = nvault_open(g_szInfectsVault)
  58.    
  59.     iExists = nvault_lookup(g_iInfectsVaultHandle, szAuthID, szData, charsmax(szData), iTimestamp)
  60.    
  61.     // Close Vault
  62.     nvault_close(g_iInfectsVaultHandle)
  63.    
  64.     if (!iExists)
  65.     {
  66.         g_iInfects[id] = 0
  67.         SaveInfects(id)
  68.     }
  69.     else
  70.     {
  71.         new iInfects[32]
  72.         parse(szData, iInfects, 31)
  73.        
  74.         g_iInfects[id] = str_to_num(iInfects)
  75.     }
  76. }
  77.  
  78. SaveInfects(id)
  79. {
  80.     new szAuthID[35], szName[32]
  81.     get_user_authid(id, szAuthID, charsmax(szAuthID))
  82.     get_user_name(id, szName, charsmax(szName))
  83.    
  84.     new szData[256]
  85.     formatex(szData, charsmax(szData), "%i", g_iInfects[id])
  86.    
  87.     // Open the Vaults
  88.     g_iInfectsVaultHandle = nvault_open(g_szInfectsVault)
  89.  
  90.     // Saves His Data
  91.     nvault_set(g_iInfectsVaultHandle, szAuthID, szData)
  92.  
  93.     // Close Vaults
  94.     nvault_close(g_iInfectsVaultHandle)
  95. }
  96.  
  97. // Natives
  98. public native_ze_get_user_infects(id)
  99. {
  100.     if (!is_user_connected(id))
  101.     {
  102.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  103.         return false
  104.     }
  105.    
  106.     return g_iInfects[id]
  107. }
  108.  
  109. public native_ze_set_user_infects(id, iAmount)
  110. {
  111.     if (!is_user_connected(id))
  112.     {
  113.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  114.         return false
  115.     }
  116.    
  117.     g_iInfects[id] = iAmount
  118.     SaveInfects(id)
  119.     return true
  120. }
Image

karan
Mod Tester
Mod Tester
India
Posts: 122
Joined: 6 years ago
Location: India
Contact:

#11

Post by karan » 2 years ago

  1. #include <zombie_escape>
  2.  
  3.  
  4. // Static (Change it if you need)
  5. new const g_szEscapesVault[] = "Escapes"
  6.  
  7. // Variables
  8. new g_iEscapes[33],
  9.     g_iEscapesVaultHandle
  10.  
  11.  
  12. // Natives
  13. public plugin_natives()
  14. {
  15.     register_native("ze_get_user_escapes", "native_ze_get_user_escapes", 1)
  16.     register_native("ze_set_user_escapes", "native_ze_set_user_escapes", 1)
  17. }
  18.  
  19. public plugin_init()
  20. {
  21.     register_plugin("Escapes Count", "1.0", "ze-dev-team")
  22. }
  23.  
  24. public client_putinserver(id)
  25. {
  26.     if (is_user_bot(id) || is_user_hltv(id))
  27.         return
  28.    
  29.     // Just 1 second delay
  30.     set_task(1.0, "DelayLoad", id)
  31. }
  32.  
  33. public DelayLoad(id)
  34. {
  35.     LoadEscapes(id)
  36. }
  37.  
  38. public ze_roundend(WinTeam)
  39. {
  40.     if (WinTeam == ZE_TEAM_HUMAN)
  41.     {
  42.         for (new id = 0; id <= get_member_game(m_nMaxPlayers); id++)
  43.         {
  44.             if (!is_user_alive(id) || ze_is_user_zombie(id))
  45.                 continue
  46.  
  47.             g_iEscapes[id] ++
  48.             SaveEscapes(id)
  49.         }
  50.     }
  51. }
  52.  
  53. LoadEscapes(id)
  54. {
  55.     new szData[256], szAuthID[35]
  56.    
  57.     get_user_authid(id, szAuthID, charsmax(szAuthID))
  58.    
  59.     // Useless Variable
  60.     new iTimestamp, iExists
  61.    
  62.     // Open the Vault
  63.     g_iEscapesVaultHandle = nvault_open(g_szEscapesVault)
  64.    
  65.     iExists = nvault_lookup(g_iEscapesVaultHandle, szAuthID, szData, charsmax(szData), iTimestamp)
  66.    
  67.     // Close Vault
  68.     nvault_close(g_iEscapesVaultHandle)
  69.    
  70.     if (!iExists)
  71.     {
  72.         g_iEscapes[id] = 0
  73.         SaveEscapes(id)
  74.     }
  75.     else
  76.     {
  77.         new iEscapes[32]
  78.         parse(szData, iEscapes, 31)
  79.        
  80.         g_iEscapes[id] = str_to_num(iEscapes)
  81.     }
  82. }
  83.  
  84. SaveEscapes(id)
  85. {
  86.     new szAuthID[35], szName[32]
  87.     get_user_authid(id, szAuthID, charsmax(szAuthID))
  88.     get_user_name(id, szName, charsmax(szName))
  89.    
  90.     new szData[256]
  91.     formatex(szData, charsmax(szData), "%i", g_iEscapes[id])
  92.    
  93.     // Open the Vaults
  94.     g_iEscapesVaultHandle = nvault_open(g_szEscapesVault)
  95.  
  96.     // Saves His Data
  97.     nvault_set(g_iEscapesVaultHandle, szAuthID, szData)
  98.  
  99.     // Close Vaults
  100.     nvault_close(g_iEscapesVaultHandle)
  101. }
  102.  
  103. // Natives
  104. public native_ze_get_user_escapes(id)
  105. {
  106.     if (!is_user_connected(id))
  107.     {
  108.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  109.         return false
  110.     }
  111.    
  112.     return g_iEscapes[id]
  113. }
  114.  
  115. public native_ze_set_user_escapes(id, iAmount)
  116. {
  117.     if (!is_user_connected(id))
  118.     {
  119.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  120.         return false
  121.     }
  122.    
  123.     g_iEscapes[id] = iAmount
  124.     SaveEscapes(id)
  125.     return true
  126. }
Image

karan
Mod Tester
Mod Tester
India
Posts: 122
Joined: 6 years ago
Location: India
Contact:

#12

Post by karan » 2 years ago

try them use raheem's edited hud to see infects & escapes viewtopic.php?f=7&t=3563
Image

User avatar
VicKy
Mod Tester
Mod Tester
Pakistan
Posts: 87
Joined: 3 years ago
Contact:

#13

Post by VicKy » 2 years ago

:twisted:
karan wrote: 2 years ago
  1. #include <zombie_escape>
  2.  
  3.  
  4. // Static (Change it if you need)
  5. new const g_szEscapesVault[] = "Escapes"
  6.  
  7. // Variables
  8. new g_iEscapes[33],
  9.     g_iEscapesVaultHandle
  10.  
  11.  
  12. // Natives
  13. public plugin_natives()
  14. {
  15.     register_native("ze_get_user_escapes", "native_ze_get_user_escapes", 1)
  16.     register_native("ze_set_user_escapes", "native_ze_set_user_escapes", 1)
  17. }
  18.  
  19. public plugin_init()
  20. {
  21.     register_plugin("Escapes Count", "1.0", "ze-dev-team")
  22. }
  23.  
  24. public client_putinserver(id)
  25. {
  26.     if (is_user_bot(id) || is_user_hltv(id))
  27.         return
  28.    
  29.     // Just 1 second delay
  30.     set_task(1.0, "DelayLoad", id)
  31. }
  32.  
  33. public DelayLoad(id)
  34. {
  35.     LoadEscapes(id)
  36. }
  37.  
  38. public ze_roundend(WinTeam)
  39. {
  40.     if (WinTeam == ZE_TEAM_HUMAN)
  41.     {
  42.         for (new id = 0; id <= get_member_game(m_nMaxPlayers); id++)
  43.         {
  44.             if (!is_user_alive(id) || ze_is_user_zombie(id))
  45.                 continue
  46.  
  47.             g_iEscapes[id] ++
  48.             SaveEscapes(id)
  49.         }
  50.     }
  51. }
  52.  
  53. LoadEscapes(id)
  54. {
  55.     new szData[256], szAuthID[35]
  56.    
  57.     get_user_authid(id, szAuthID, charsmax(szAuthID))
  58.    
  59.     // Useless Variable
  60.     new iTimestamp, iExists
  61.    
  62.     // Open the Vault
  63.     g_iEscapesVaultHandle = nvault_open(g_szEscapesVault)
  64.    
  65.     iExists = nvault_lookup(g_iEscapesVaultHandle, szAuthID, szData, charsmax(szData), iTimestamp)
  66.    
  67.     // Close Vault
  68.     nvault_close(g_iEscapesVaultHandle)
  69.    
  70.     if (!iExists)
  71.     {
  72.         g_iEscapes[id] = 0
  73.         SaveEscapes(id)
  74.     }
  75.     else
  76.     {
  77.         new iEscapes[32]
  78.         parse(szData, iEscapes, 31)
  79.        
  80.         g_iEscapes[id] = str_to_num(iEscapes)
  81.     }
  82. }
  83.  
  84. SaveEscapes(id)
  85. {
  86.     new szAuthID[35], szName[32]
  87.     get_user_authid(id, szAuthID, charsmax(szAuthID))
  88.     get_user_name(id, szName, charsmax(szName))
  89.    
  90.     new szData[256]
  91.     formatex(szData, charsmax(szData), "%i", g_iEscapes[id])
  92.    
  93.     // Open the Vaults
  94.     g_iEscapesVaultHandle = nvault_open(g_szEscapesVault)
  95.  
  96.     // Saves His Data
  97.     nvault_set(g_iEscapesVaultHandle, szAuthID, szData)
  98.  
  99.     // Close Vaults
  100.     nvault_close(g_iEscapesVaultHandle)
  101. }
  102.  
  103. // Natives
  104. public native_ze_get_user_escapes(id)
  105. {
  106.     if (!is_user_connected(id))
  107.     {
  108.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  109.         return false
  110.     }
  111.    
  112.     return g_iEscapes[id]
  113. }
  114.  
  115. public native_ze_set_user_escapes(id, iAmount)
  116. {
  117.     if (!is_user_connected(id))
  118.     {
  119.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  120.         return false
  121.     }
  122.    
  123.     g_iEscapes[id] = iAmount
  124.     SaveEscapes(id)
  125.     return true
  126. }
Thanks Bro it Fixed But Now I Am Using MySQL Both Are Working
Image

Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Who is online

Users browsing this forum: No registered users and 0 guests