Thread: Please fix code
View Single Post
naXe
BANNED
Join Date: May 2009
Location: Poland/Kwidzyn
Old 02-11-2012 , 23:04   Re: Please fix code
Reply With Quote #8

is_user_steam () must be because the server is 47 +48
save has only players with Steam

I know that you can not just some characters I did like this:

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <colorchat>
 
new gszFile[201], czas[33], szDir[64]
 
public 
plugin_init() {
        
register_plugin("Czas gry""1.0""naXe")
        
register_clcmd("say /czasgry""pokaz_czas_gry")
        
register_clcmd("say /czas""pokaz_czas_gry")
       
        
get_basedir(szDirsizeof szDir)
        
formatex(gszFile200"%s/configs/czas_gry/"szDir)
       
}
public 
client_putinserver(id) {
        if(
is_user_steam(id)) {
                new 
steam_id[35], adres[201], iLenText[32]
                
get_user_authid(idsteam_idsizeof steam_id 1)
                
replace(steam_id,charsmax(steam_id),":","-")
                
formatex(adres200"%s%s.ini"gszFilesteam_id)
                if(
file_exists(adres)) {
                        
read_file(adres0Text31iLen)
                        
trim(Text)
                        
czas[id] = str_to_num(Text)
                } else {
                        
czas[id] = 0
                
}
        }
        return 
PLUGIN_HANDLED
}
public 
pokaz_czas_gry(id) {
        new 
iCurTime get_user_time(id 1)
        new 
Time czas[id]
        if((
iCurTime Time) / 60 60) {
                
ColorChat(idGREEN"[CzasGry]^x01 Spedziles na serwerze^x03 %d^x01 min.", (iCurTime Time) / 60)
        } else {
                
ColorChat(idGREEN"[CzasGry]^x01 Spedziles na serwerze^x03 %d^x01 h ^x03%02d^x01 min.", (iCurTime Time) / 3600, ((iCurTime Time) / 60) % 60)
        }
        return 
PLUGIN_HANDLED
}
public 
client_disconnect(id) {
        if(
is_user_steam(id))  {
                new 
steam_id[35], adres[201], Text[200]
                
get_user_authid(idsteam_idsizeof steam_id 1)
                
replace(steam_id,charsmax(steam_id),":","-")
                
formatex(adres200"%s%s.ini"gszFilesteam_id)
                new 
szTime get_user_time(id 1) + czas[id]
                
num_to_str(szTimeTextcharsmax(Text))
                
write_file(adresText0)
        }
        return 
PLUGIN_HANDLED
}
 
stock bool:is_user_steam(id) {
        new 
authid[32]
        
get_user_authid(idauthid31)
        return 
contain(authid ":") != -true false

naXe is offline
Send a message via AIM to naXe