Thanks Maximus, that looks like what I needed. Ill try it out later.
All I need to know now is, how do I check this value when it reaches 10, 20. I tried client_prethink, but it executed the code at least 4 times, when I only wanted it done once. I also tried a repeating set_task to check every 0.9 seconds, but for some reason that didnt work.
In the following code, the time thats printed is always 0. So what am I doing wrong?
Code:
new time[33]
public client_authorized(id){
get_user_authid(id,authid,31)
res = dbi_query(mysql,"SELECT time FROM mytime WHERE steamid = '%s'",authid)
if (res == RESULT_FAILED){ //Problem with mysql
log_amx("SQL connection failed with authorized dbi_query")
return PLUGIN_HANDLED
}
if (res == RESULT_NONE){ //not in db, set to 0
time[id] = 0 //New player, create a database entry for them
log_amx("res = RESULT_NONE, time = 0")
new playtime = get_user_time (id)
resss = dbi_query(mysql,"INSERT INTO mytime (steamid, time,date) values ('%s',%i,NOW())",authid,playtime)
dbi_free_result(resss)
}
if (res == RESULT_OK){ //get totaltime from database
dbi_nextrow(res)
time[id] = dbi_result(res,"time")
log_amx(" time > 0")
}
return PLUGIN_CONTINUE
}
public check_time(id){
new name[18]
get_user_name(id, name, 17)
new playtime = get_user_time(id)
store_time = (playtime + time[id]) //Get total time
client_print(id, print_chat,"time = %i",time[id])
if(store_time == 10){
client_print(0, print_center,"Please welcome %s to the server. May your time here be enjoyable.",name)
client_cmd(0, "spk gargr/congrats.wav")
}
return PLUGIN_CONTINUE
}
__________________