Raised This Month: $ Target: $400
 0% 

Get Online Time with PsychoStats


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
OnePL
BANNED
Join Date: May 2012
Location: GB
Old 09-02-2012 , 16:09   Get Online Time with PsychoStats
Reply With Quote #1

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


Last edited by OnePL; 09-02-2012 at 16:16. Reason: PHP tag
OnePL is offline
Send a message via ICQ to OnePL Send a message via AIM to OnePL Send a message via Yahoo to OnePL Send a message via Skype™ to OnePL
pokemonmaster
princess milk
Join Date: Nov 2010
Location: Somewhere in this world
Old 09-03-2012 , 13:37   Re: Get Online Time with PsychoStats
Reply With Quote #2

Try setting the task after registering cvars....
__________________
اَشْهَدُ اَنْ لَّآ اِلٰهَ اِلَّا اللہُ وَحْدَه لَا شَرِيْكَ لَه وَ اَشْهَدُ اَنَّ مُحَمَّدًا عَبْدُه وَرَسُوْلُه
No longer active in AMXX. Sorry.
pokemonmaster is offline
OnePL
BANNED
Join Date: May 2012
Location: GB
Old 09-03-2012 , 14:58   Re: Get Online Time with PsychoStats
Reply With Quote #3

OMG ! I already did -,-
OnePL is offline
Send a message via ICQ to OnePL Send a message via AIM to OnePL Send a message via Yahoo to OnePL Send a message via Skype™ to OnePL
Old 09-04-2012, 13:53
OnePL
This message has been deleted by YamiKaitou. Reason: wait 14 days before you bump
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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