AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Get Online Time with PsychoStats (https://forums.alliedmods.net/showthread.php?t=195019)

OnePL 09-02-2012 16:09

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"Host31)
    
get_cvar_string("amx_ps_user"User31)
    
get_cvar_string("amx_ps_pass"Pass31)
    
get_cvar_string("amx_ps_db"DB31)
    
g_SqlTuple SQL_MakeDbTuple(HostUserPassDB)
}

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(id1)
        
user_silentkill(id)
        for(new 
02; ++i) {
            new 
tekst[3][15]
            new 
time2[3]
            if(
== 0time2[0] = czas[id]
            if(
== 1time2[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] > 0format(tekst[0], 32"%d godz."time2[2])
            if(
time2[1] > 0format(tekst[1], 32"%d min."time2[1])
            if(
time2[0] > 0format(tekst[2], 32"%d sek."time2[0])

            
format(informacja[i], 99"%s %s %s"tekst[0], tekst[1], tekst[2])
        }
        
ColorChat(idGREEN"[JailBreak]^x01 Twoj czas gry wynosi^x03 %s"informacja[0])
        
ColorChat(idGREEN"[JailBreak]^x01 Aby byc straznikiem, musisz miec przegrane przynajmniej^x03 %s"informacja[1])
    }
    return 
PLUGIN_CONTINUE
}

public 
client_disconnect(idstan[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(szTempcharsmax(szTemp), "SELECT * FROM `ps_plr_ids_name` WHERE (`ps_plr_ids_name`.`name` = '%s')"name)
    
SQL_ThreadQuery(g_SqlTuple"checkPS"szTempData1)
}

public 
checkPS(FailStateHandle:QueryError[], ErrcodeData[], DataSize) {
    if(
Errcodelog_amx("Blad w zapytaniu: %s [SaveData]"Error)

    if(
FailState == TQUERY_CONNECT_FAILED) {
        
log_amx("Nie mozna polaczyc sie z baza danych. [%d] %s"ErrcodeError)
        
connect false
        
return PLUGIN_HANDLED
    
}
    else if(
FailState == TQUERY_QUERY_FAILED) {
        
log_amx("Zaladowanie zapytania nie powiodlo sie. [%d] %s"ErrcodeError)
        
connect false
        
return PLUGIN_HANDLED
    
}
    new 
id Data[0]
    if(!(
SQL_NumResults(Query) > 0)) return PLUGIN_HANDLED

    dane
[id] = SQL_ReadResult(QuerySQL_FieldNameToNum(Query,"plrid"))

    
connect true

    
if(dane[id] >= 0pobierznazwePS(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(szTempcharsmax(szTemp), "SELECT * FROM `ps_plr_data` WHERE (`ps_plr_data`.`plrid` = '%d')"dane[id])
    
SQL_ThreadQuery(g_SqlTuple"checkPS2"szTempData1)
}

public 
checkPS2(FailStateHandle:QueryError[], ErrcodeData[], DataSize) {
    if(
Errcodelog_amx("Blad w zapytaniu: %s [SaveData]"Error)

    if(
FailState == TQUERY_CONNECT_FAILED) {
        
log_amx("Nie mozna polaczyc sie z baza danych. [%d] %s"ErrcodeError)
        
connect false
        
return PLUGIN_HANDLED
    
}
    else if(
FailState == TQUERY_QUERY_FAILED) {
        
log_amx("Zaladowanie zapytania nie powiodlo sie. [%d] %s"ErrcodeError)
        
connect false
        
return PLUGIN_HANDLED
    
}
    if(!(
SQL_NumResults(Query) > 0)) return PLUGIN_HANDLED

    
new id Data[0]

    
czas[id] = SQL_ReadResult(QuerySQL_FieldNameToNum(Query"onlinetime"))

    if(
czas[id] >= get_cvar_num("jb_min_czas")) stan[id] = true
    
return PLUGIN_CONTINUE



pokemonmaster 09-03-2012 13:37

Re: Get Online Time with PsychoStats
 
Try setting the task after registering cvars....

OnePL 09-03-2012 14:58

Re: Get Online Time with PsychoStats
 
OMG ! I already did -,-


All times are GMT -4. The time now is 08:20.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.