Hello, I have problem with loading data from mysql.There is a plugin who I am using:
https://forums.alliedmods.net/showthread.php?t=118796
And there are strange thing, when new player joins he got 0xp, 0lvl (how it should be) or random lvl and xp for example: 10lvl , 3650xp (how should not be).Saving data is working fine, here is a bit code of loading:
LoadData function
Spoiler
PHP Code:
public LoadData ( client ) { decl String : szQuery [ 256 ]; decl String : szKey [ 64 ]; Save_GetKey ( client , szKey , sizeof ( szKey ) ); Format ( szQuery , sizeof ( szQuery ), "SELECT `player_level`, `player_xp` FROM `gunxpmod` WHERE ( `player_id` = '%s' );" , szKey ); SQL_TQuery ( hDatabase , QuerySelectData , szQuery , client ) }
SaveGetKey
Spoiler
PHP Code:
public Save_GetKey ( client , String : szKey [], maxlen ) { switch( GetConVarInt ( CvarSaveType ) ) { case 2 : { GetClientName ( client , szKey , maxlen ); ReplaceString ( szKey , maxlen , "'" , "\'" ); } case 1 : GetClientIP ( client , szKey , maxlen ); case 0 : GetClientAuthString ( client , szKey , maxlen ); } }
QuerySelectData
Spoiler
PHP Code:
public QuerySelectData ( Handle : owner , Handle : hndl , const String : error [], any : data ) { if ( hndl != INVALID_HANDLE ) { if (! SQL_HasResultSet ( hndl )) { PlayerLevel [ data ] = 0 ; PlayerXp [ data ] = 0 ; return; } while ( SQL_FetchRow ( hndl ) ) { PlayerLevel [ data ] = SQL_FetchInt ( hndl , 0 ); PlayerXp [ data ] = SQL_FetchInt ( hndl , 1 ); } } else { LogError ( "%s" , error ); return; } }
LoadData function is called only here:
Spoiler
PHP Code:
public OnClientPutInServer ( client ) { if ( IsValidClient ( client ) && ! IsFakeClient ( client ) ) { PlayerLevel [ client ] = 0 ; PlayerXp [ client ] = 0 ; LoadData ( client ); SDKHook ( client , SDKHook_WeaponCanUse , OnWeaponCanUse ); g_remember_selection [ client ] = MAX_SECONDARY_LEVELS ; g_remember_selection_pistol [ client ] = 0 ; } }
Somehow magically LoadData loads other player data or just set random
And few people says that them experiance and level dissapears.
This plugin is enabled on my server, just click on signature image and see it for your self, but it's not happening everytime...
__________________