Raised This Month: $ Target: $400
 0% 

[MySQL] Connecting to database time bug


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
FEELiFE
Member
Join Date: Jul 2010
Old 11-01-2011 , 08:07   [MySQL] Connecting to database time bug
Reply With Quote #1

I have some kind of problem and I realised how it happens. So if the map changes and a user quit the server immediately after connect the his data becomes 0. (the mysql hasn't loaded the data yet, but the user quits and the server saves the data to 0) How can I prevent this "bug" or check if there is connection between the server and the MySQL database, so that I can prevent saving the zero information ?
FEELiFE is offline
Federley
Junior Member
Join Date: Jun 2011
Old 11-01-2011 , 08:24   Re: [MySQL] Connecting to database time bug
Reply With Quote #2

What plugins do you use? Tell us more about what you use!
Federley is offline
FEELiFE
Member
Join Date: Jul 2010
Old 11-01-2011 , 08:55   Re: [MySQL] Connecting to database time bug
Reply With Quote #3

Plugin which connects to the database to load and save some information.

I don't think this would be useful and I have already explained the problem in the first post.
FEELiFE is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 11-01-2011 , 15:38   Re: [MySQL] Connecting to database time bug
Reply With Quote #4

It's not a fault of mysql. It's a problem with plugin. The solution is simple:
PHP Code:
new bool:g_loaded[33]

public 
load(id){
    if(
g_loaded[id])
        return 
//don't load again if loaded
    //code...
    
SQL_ThreadQuery(tuple"load_query_handler", ...)
}

public 
load_query_handler(...){
    
//code...
    
if( user_completely_loaded )
        
g_loaded[id] = true
}

public 
save(id){
    if(!
g_loaded[id])
        return 
//don't save if not loaded
    //code...
}

public 
client_connect(id){
    
g_loaded[id] = false 
}

public 
client_disconnect(id){
    
save(id)
    
g_loaded[id] = false

__________________
Impossible is Nothing
Sylwester is offline
FEELiFE
Member
Join Date: Jul 2010
Old 11-01-2011 , 17:30   Re: [MySQL] Connecting to database time bug
Reply With Quote #5

Thank you! I think it works fine now .
FEELiFE is offline
Reply


Thread Tools
Display Modes

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 14:18.


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