Get Online Time with PsychoStats
Hello,
I have a problem with the plugin, which has a get time spent on the server, and if someone has less than 5 hours may not join the team T.
The problem is that it does not get time. Table of SQL is "probably" good. Please help me.
PHP Code:
#include <amxmodx> #include <sqlx> #include <hamsandwich> #include <cstrike> #include <colorchat>
new Handle:g_SqlTuple new dane[33], czas[33] new bool:stan[33], bool:connect = true
public plugin_init() { register_plugin("Czas CT", "1.0", "OnePL") set_task(1.0, "MySql_Init")
register_cvar("amx_ps_host", "XXX") register_cvar("amx_ps_user", "XXX") register_cvar("amx_ps_pass", "XXX") register_cvar("amx_ps_db", "XXX")
register_cvar("jb_min_czas", "18000") RegisterHam(Ham_Spawn, "player", "spawn", 1) }
public MySql_Init() { new Host[32], User[32], Pass[32], DB[32];
get_cvar_string("amx_ps_host", Host, 31) get_cvar_string("amx_ps_user", User, 31) get_cvar_string("amx_ps_pass", Pass, 31) get_cvar_string("amx_ps_db", DB, 31) g_SqlTuple = SQL_MakeDbTuple(Host, User, Pass, DB) }
public spawn(id) { if(!connect) return PLUGIN_HANDLED if(stan[id] != true && is_user_connected(id) && get_user_team(id) == 2) { new informacja[2][100] cs_set_user_team(id, 1) user_silentkill(id) for(new i = 0; i < 2; ++i) { new tekst[3][15] new time2[3] if(i == 0) time2[0] = czas[id] if(i == 1) time2[0] = get_cvar_num("jb_min_czas")
while(time2[0] >= 60) { time2[0] -= 60 time2[1]++ } while(time2[1] >= 60) { time2[1] -= 60 time2[2]++ } if(time2[2] > 0) format(tekst[0], 32, "%d godz.", time2[2]) if(time2[1] > 0) format(tekst[1], 32, "%d min.", time2[1]) if(time2[0] > 0) format(tekst[2], 32, "%d sek.", time2[0])
format(informacja[i], 99, "%s %s %s", tekst[0], tekst[1], tekst[2]) } ColorChat(id, GREEN, "[JailBreak]^x01 Twoj czas gry wynosi^x03 %s", informacja[0]) ColorChat(id, GREEN, "[JailBreak]^x01 Aby byc straznikiem, musisz miec przegrane przynajmniej^x03 %s", informacja[1]) } return PLUGIN_CONTINUE }
public client_disconnect(id) stan[id] = false
public client_putinserver(id) { new Data[1] Data[0] = id new szTemp[500] new name[32]; get_user_name(id,name,31) format(szTemp, charsmax(szTemp), "SELECT * FROM `ps_plr_ids_name` WHERE (`ps_plr_ids_name`.`name` = '%s')", name) SQL_ThreadQuery(g_SqlTuple, "checkPS", szTemp, Data, 1) }
public checkPS(FailState, Handle:Query, Error[], Errcode, Data[], DataSize) { if(Errcode) log_amx("Blad w zapytaniu: %s [SaveData]", Error)
if(FailState == TQUERY_CONNECT_FAILED) { log_amx("Nie mozna polaczyc sie z baza danych. [%d] %s", Errcode, Error) connect = false return PLUGIN_HANDLED } else if(FailState == TQUERY_QUERY_FAILED) { log_amx("Zaladowanie zapytania nie powiodlo sie. [%d] %s", Errcode, Error) connect = false return PLUGIN_HANDLED } new id = Data[0] if(!(SQL_NumResults(Query) > 0)) return PLUGIN_HANDLED
dane[id] = SQL_ReadResult(Query, SQL_FieldNameToNum(Query,"plrid"))
connect = true
if(dane[id] >= 0) pobierznazwePS(id)
return PLUGIN_CONTINUE }
public pobierznazwePS(id) { new Data[1] Data[0] = id new szTemp[500] new name[32]; get_user_name(id,name,31) format(szTemp, charsmax(szTemp), "SELECT * FROM `ps_plr_data` WHERE (`ps_plr_data`.`plrid` = '%d')", dane[id]) SQL_ThreadQuery(g_SqlTuple, "checkPS2", szTemp, Data, 1) }
public checkPS2(FailState, Handle:Query, Error[], Errcode, Data[], DataSize) { if(Errcode) log_amx("Blad w zapytaniu: %s [SaveData]", Error)
if(FailState == TQUERY_CONNECT_FAILED) { log_amx("Nie mozna polaczyc sie z baza danych. [%d] %s", Errcode, Error) connect = false return PLUGIN_HANDLED } else if(FailState == TQUERY_QUERY_FAILED) { log_amx("Zaladowanie zapytania nie powiodlo sie. [%d] %s", Errcode, Error) connect = false return PLUGIN_HANDLED } if(!(SQL_NumResults(Query) > 0)) return PLUGIN_HANDLED
new id = Data[0]
czas[id] = SQL_ReadResult(Query, SQL_FieldNameToNum(Query, "onlinetime"))
if(czas[id] >= get_cvar_num("jb_min_czas")) stan[id] = true return PLUGIN_CONTINUE }
|