03.01.2013, 09:49
hi everyone
i have this script in my mysql load/save system:
sometimes its not saving the account but log is showing nothing, sometimes saves admin/vip when player dosent have one. whear is the problem?
sorry for bad english
i have this script in my mysql load/save system:
Код:
stock MySQL_Save(playerid) { if( online[ playerid ] ) { new Query[ 512 ]; printf( "Iљsaugoma. [%s]", GetPlayerNameEx( playerid ) ); zInfo[ playerid ][ Pinigai ] = GetPlayerMoney(playerid); zInfo[ playerid ][ Patirtis ] = GetPlayerScore(playerid); format( Query, sizeof( Query ),"UPDATE `minim` SET pinigai = '%i', patirtis = '%i', admin = '%i', vip = '%i' WHERE vardas = '%s'",\ zInfo[ playerid ][ Pinigai ], zInfo[ playerid ][ Patirtis ], zInfo[ playerid ][ Admin ], zInfo[ playerid ][ Vip ], GetPlayerNameEx( playerid ) ); mysql_query( Query ); } return 1; } stock MySQL_Load(playerid) { new fetch[ 16 ], Query[ 256 ]; format(Query, sizeof(Query), "SELECT * FROM `minim` WHERE vardas = '%s'", GetPlayerNameEx(playerid)); mysql_query(Query); mysql_store_result(); mysql_retrieve_row(); mysql_fetch_field_row( fetch, "pinigai" ); zInfo[ playerid ][ Pinigai ] = strval(fetch); GivePlayerMoney(playerid, zInfo[playerid][Pinigai]); mysql_fetch_field_row( fetch, "patirtis" ); zInfo[ playerid ][ Patirtis ] = strval(fetch); SetPlayerScore(playerid, zInfo[playerid][Patirtis]); mysql_fetch_field_row( fetch, "admin" ); zInfo[ playerid ][ Admin ] = strval(fetch); mysql_fetch_field_row( fetch, "vip" ); zInfo[ playerid ][ Vip ] = strval(fetch); mysql_free_result(); printf( "Pakrautas ћaidėjas. [%s]", GetPlayerNameEx( playerid ) ); return 1; }
Код:
public OnPlayerDisconnect(playerid, reason) { if( online[ playerid ] ) { MySQL_Save( playerid ); } return 1; }
Код:
public OnFilterScriptExit() { for(new i=0; i < MAX_PLAYERS; i++) { if( IsPlayerConnected(i) && online[i] ) MySQL_Save(i); } mysql_close( ); return 1; }
sorry for bad english