Raised This Month: $ Target: $400
 0% 

[SOLVED]client_disconnect & mysql


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
One
Veteran Member
Join Date: Oct 2008
Location: Hardstyle-eSports.de
Old 05-05-2011 , 21:06   [SOLVED]client_disconnect & mysql
Reply With Quote #1

hi,

i'm writing a plugin to put a mini live status to db.
now i have a problem to delete users stats in db when he left the server.

now i want to ask is there a way to delete users data without a loop to see who is not anymore on the server?

i tried :
on client connect
PHP Code:
public Load_SQL(id)
{
    new 
steam_id[33],Temp[512],name[33],loss,ping
    
/*team :
        0 = connecting
        1 = spectating
        2 = Catcher
        3 = Fleer
    */
    
    
get_user_ping(id,ping,loss)
    
get_user_authid(idsteam_idcharsmax(steam_id))
    
get_user_name(id,name,32)
    
    if (
equal(steam_id,"ID_PENDING"))
    {
        return 
PLUGIN_HANDLED
    
}
    
format(Temp,charsmax(Temp),"INSERT INTO `catch_live` ( `authid` , `name` , `Score` , `Deaths` , `Ping` , `speed` , `Maxspeed` , `fps` , `team` , `ag` , `map`)VALUES ('%s','%s','0','0','%d','0','0','%d','con','1','%s');",steam_id,name,ping,users_fps,map)
    
SQL_ThreadQuery(sqldb,"IgnoreHandle",Temp)
    return 
PLUGIN_HANDLED

on client_disconnect

PHP Code:
public client_disconnect(id)
{
    
/* Maybe i should delete the table or check if there are resaults for player on client_connect bacause of server crashes or such problems */
    
g_iIsSpectator[id] = 0
    
new steam_id[33],Temp[512]
    
    if (
equal(steam_id,"ID_PENDING"))
    {
        return 
PLUGIN_HANDLED
    
}
    
format(Temp,charsmax(Temp),"DELETE FROM `catch_live` WHERE `authid` = '%s'"steam_id);
    
SQL_ThreadQuery(sqldb,"IgnoreHandle",Temp)
    return 
PLUGIN_HANDLED

the problem here is that the client is not anymore on server and i have no steamid to delete his stats.
__________________
One is offline
Send a message via ICQ to One Send a message via AIM to One Send a message via MSN to One Send a message via Yahoo to One Send a message via Skype™ to One
 



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 04:22.


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