AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Bckup mysql data (https://forums.alliedmods.net/showthread.php?t=208265)

Killer zm 02-11-2013 12:36

Bckup mysql data
 
I am using zp bank sql for saving amopacks on zombie mod and I am thinking if mysql go down in the midle of the game what can I do so player dont lose his data, because when the map will be changed and mysql is up again then will load the last data that was saved before mysql go down . what can i do for not losing data when mysql is down ...

Torge 02-11-2013 13:13

Re: Bckup mysql data
 
If ammo packs will be saved whenever they earn +1 this couldn't happen (I guess)

Killer zm 02-11-2013 13:26

Re: Bckup mysql data
 
i dont understand what you say what i want is to get another way of saving ammo packs when mysql is down how i can detect when mysql go down ? i use this http://forums.alliedmods.net/showthread.php?t=121541

and i tried to save with nvault but how can i detect if mysql go down in the midle of the game ?

Sylwester 02-11-2013 14:47

Re: Bckup mysql data
 
There is a way but you need to edit code. When mysql goes down, then your queries will fail. You can then use SQL_GetQueryString to get original query string and store it in a file. Once the connection is reestablished you can execute all saved queries.

Backstabnoob 02-11-2013 15:52

Re: Bckup mysql data
 
Quote:

Originally Posted by Torge (Post 1892500)
If ammo packs will be saved whenever they earn +1 this couldn't happen (I guess)

It can't, but it's a pretty bad idea.

TheDS1337 02-11-2013 15:59

Re: Bckup mysql data
 
use plugin_end();
it's hook when map chaned

Killer zm 02-12-2013 09:31

Re: Bckup mysql data
 
in conclusion how i check if mysql goes down, i mean if map is changed then it showing that mysql is down but if is int middle of the game is not showing so i have to check this .. how ?

Sylwester 02-12-2013 10:07

Re: Bckup mysql data
 
Quote:

Originally Posted by Sylwester (Post 1892557)
When mysql goes down, then your queries will fail.

PHP Code:

public ThreadQuery_handler(FailState,Handle:Query,Error[],Errcode,Data[],DataSize){
    if(
FailState){
        
log_amx("SQL Error: %s"Error)
        
//query failed - in most cases mysql is down, to be sure you can check Errcode
        
return
    }
    
//query did not fail ...



Killer zm 02-12-2013 10:42

Re: Bckup mysql data
 
this check will be made at start game like plugin_init ?

how do i check this with a task in the game

Torge 02-12-2013 11:19

Re: Bckup mysql data
 
Can be checked with SQL_ThreadQuery();


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

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