Mysql load/save buged
#1

hi everyone

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;
}
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
Reply


Messages In This Thread
Mysql load/save buged - by ancezas - 03.01.2013, 09:49
Re: Mysql load/save buged - by ikey07 - 03.01.2013, 10:13
Re: Mysql load/save buged - by ancezas - 03.01.2013, 10:16
Re: Mysql load/save buged - by ikey07 - 03.01.2013, 10:19
Re: Mysql load/save buged - by ancezas - 03.01.2013, 10:28
Re: Mysql load/save buged - by Roel - 03.01.2013, 10:37
Re: Mysql load/save buged - by ancezas - 03.01.2013, 12:59
Re: Mysql load/save buged - by Roel - 03.01.2013, 13:06
Re: Mysql load/save buged - by ancezas - 03.01.2013, 21:20

Forum Jump:


Users browsing this thread: 1 Guest(s)