15.08.2011, 22:27
pawn Code:
if( IsPlayerConnected( playerid ) ) {
MySQLCheckConnection( );
new query[ MAX_STRING ];
format( query, MAX_STRING, "UPDATE players SET " );
MySQLUpdatePlayerStr( query, P_DATA[ playerid ][ SQLID ], "Password", P_DATA[ playerid ][ Password ] );
MySQLUpdatePlayerInt( query, P_DATA[ playerid ][ SQLID ], "AdminLevel", P_DATA[ playerid ][ AdminLevel ] );
MySQLUpdatePlayerInt( query, P_DATA[ playerid ][ SQLID ], "VIPStatus", P_DATA[ playerid ][ VIPStatus ] );
MySQLUpdatePlayerInt( query, P_DATA[ playerid ][ SQLID ], "Level", P_DATA[ playerid ][ Level ] );
MySQLUpdatePlayerInt( query, P_DATA[ playerid ][ SQLID ], "Money", GetPlayerMoney( playerid ) );
MySQLUpdatePlayerInt( query, P_DATA[ playerid ][ SQLID ], "Muted", P_DATA[ playerid ][ Muted ] );
MySQLUpdatePlayerInt( query, P_DATA[ playerid ][ SQLID ], "MuteTime", P_DATA[ playerid ][ MuteTime ] );
MySQLUpdatePlayerInt( query, P_DATA[ playerid ][ SQLID ], "Jailed", P_DATA[ playerid ][ Jailed ] );
MySQLUpdatePlayerInt( query, P_DATA[ playerid ][ SQLID ], "JailTime", P_DATA[ playerid ][ JailTime ] );
MySQLUpdatePlayerInt( query, P_DATA[ playerid ][ SQLID ], "Kills", P_DATA[ playerid ][ Kills ] );
MySQLUpdatePlayerInt( query, P_DATA[ playerid ][ SQLID ], "Deaths", P_DATA[ playerid ][ Deaths ] );
MySQLUpdatePlayerInt( query, P_DATA[ playerid ][ SQLID ], "BankPassword", P_DATA[ playerid ][ BankPassword ] );
MySQLUpdatePlayerInt( query, P_DATA[ playerid ][ SQLID ], "BankMoney", P_DATA[ playerid ][ BankMoney ] );
MySQLUpdatePlayerInt( query, P_DATA[ playerid ][ SQLID ], "Warns", P_DATA[ playerid ][ Warns ] );
MySQLUpdatePlayerInt( query, P_DATA[ playerid ][ SQLID ], "DriversLicense", P_DATA[ playerid ][ D_LIC ] );
MySQLUpdatePlayerInt( query, P_DATA[ playerid ][ SQLID ], "FishingLicense", P_DATA[ playerid ][ FI_LIC ] );
MySQLUpdatePlayerInt( query, P_DATA[ playerid ][ SQLID ], "FlyingLicense", P_DATA[ playerid ][ FL_LIC ] );
MySQLUpdatePlayerInt( query, P_DATA[ playerid ][ SQLID ], "WeaponsLicense", P_DATA[ playerid ][ W_LIC ] );
MySQLUpdatePlayerInt( query, P_DATA[ playerid ][ SQLID ], "Experience", P_DATA[ playerid ][ Exp ] );
MySQLUpdatePlayerInt( query, P_DATA[ playerid ][ SQLID ], "Materials", P_DATA[ playerid ][ Materials ] );
MySQLUpdatePlayerInt( query, P_DATA[ playerid ][ SQLID ], "Drugs", P_DATA[ playerid ][ Materials ] );
MySQLUpdatePlayerInt( query, P_DATA[ playerid ][ SQLID ], "FactionLeader", P_DATA[ playerid ][ FLeader ] );
MySQLUpdatePlayerInt( query, P_DATA[ playerid ][ SQLID ], "FactionMember", P_DATA[ playerid ][ FMember ] );
MySQLUpdatePlayerInt( query, P_DATA[ playerid ][ SQLID ], "FactionRank", P_DATA[ playerid ][ FRank ] );
MySQLUpdatePlayerInt( query, P_DATA[ playerid ][ SQLID ], "Skin", P_DATA[ playerid ][ Skin ] );
MySQLUpdatePlayerInt( query, P_DATA[ playerid ][ SQLID ], "Crimes", P_DATA[ playerid ][ Crimes ] );
MySQLUpdatePlayerInt( query, P_DATA[ playerid ][ SQLID ], "WantedLevel", P_DATA[ playerid ][ WantedLevel ] );
MySQLUpdatePlayerInt( query, P_DATA[ playerid ][ SQLID ], "FishesCatched", P_DATA[ playerid ][ FishesCatched ] );
MySQLUpdatePlayerInt( query, P_DATA[ playerid ][ SQLID ], "Age", P_DATA[ playerid ][ Age ] );
MySQLUpdatePlayerInt( query, P_DATA[ playerid ][ SQLID ], "Sex", P_DATA[ playerid ][ Sex ] );
MySQLUpdateFinish( query, P_DATA[ playerid ][ SQLID ] );
}
+
pawn Code:
public LoadAccount( playerid, password[ ] ) {
GetPlayerName( playerid, name, sizeof name );
MySQLCheckConnection( );
MySQLFetchAcctSingle( P_DATA[ playerid ][ SQLID ], "Password", P_DATA[ playerid ][ Password ] );
if( strcmp( P_DATA[ playerid ][ Password ], password, true ) == 0 )
{
new string[ 256 ];
format( string, sizeof string,"SELECT * FROM `players` WHERE Name='%s'", name );
mysql_query( string );
mysql_store_result( );
new field[ 64 ], data[ 256 ];
if( mysql_fetch_row_format( data ) )
{
mysql_fetch_field_row( field, "AdminLevel" ); P_DATA[ playerid ][ AdminLevel ] = strval( field );
mysql_fetch_field_row( field, "VIPStatus" ); P_DATA[ playerid ][ VIPStatus ] = strval( field );
mysql_fetch_field_row( field, "Level" ); P_DATA[ playerid ][ Level ] = strval( field );
mysql_fetch_field_row( field, "Money" ); GivePlayerMoney( playerid, strval( field ) );
mysql_fetch_field_row( field, "Muted" ); P_DATA[ playerid ][ Muted ] = strval( field );
mysql_fetch_field_row( field, "MuteTime" ); P_DATA[ playerid ][ MuteTime ] = strval( field );
mysql_fetch_field_row( field, "Jailed" ); P_DATA[ playerid ][ Jailed ] = strval( field );
mysql_fetch_field_row( field, "JailTime" ); P_DATA[ playerid ][ JailTime ] = strval( field );
mysql_fetch_field_row( field, "Kills" ); P_DATA[ playerid ][ Kills ] = strval( field );
mysql_fetch_field_row( field, "Deaths" ); P_DATA[ playerid ][ Deaths ] = strval( field );
mysql_fetch_field_row( field, "BankPassword" ); P_DATA[ playerid ][ BankPassword ] = strval( field );
mysql_fetch_field_row( field, "BankMoney" ); P_DATA[ playerid ][ BankMoney ] = strval( field );
mysql_fetch_field_row( field, "Warns" ); P_DATA[ playerid ][ Warns ] = strval( field );
mysql_fetch_field_row( field, "DriversLicense" ); P_DATA[ playerid ][ D_LIC ] = strval( field );
mysql_fetch_field_row( field, "FishingLicense" ); P_DATA[ playerid ][ FI_LIC ] = strval( field );
mysql_fetch_field_row( field, "FlyingLicense" ); P_DATA[ playerid ][ FL_LIC ] = strval( field );
mysql_fetch_field_row( field, "WeaponLicense" ); P_DATA[ playerid ][ W_LIC ] = strval( field );
mysql_fetch_field_row( field, "Experience" ); P_DATA[ playerid ][ Exp ] = strval( field );
mysql_fetch_field_row( field, "Materials" ); P_DATA[ playerid ][ Materials ] = strval( field );
mysql_fetch_field_row( field, "Drugs" ); P_DATA[ playerid ][ Drugs ] = strval( field );
mysql_fetch_field_row( field, "FactionLeader" ); P_DATA[ playerid ][ FLeader ] = strval( field );
mysql_fetch_field_row( field, "FactionMember" ); P_DATA[ playerid ][ FMember ] = strval( field );
mysql_fetch_field_row( field, "FactionRank" ); P_DATA[ playerid ][ FRank ] = strval( field );
mysql_fetch_field_row( field, "Skin" ); P_DATA[ playerid ][ Skin ] = strval( field );
mysql_fetch_field_row( field, "Crimes" ); P_DATA[ playerid ][ Crimes ] = strval( field );
mysql_fetch_field_row( field, "WantedLevel" ); P_DATA[ playerid ][ WantedLevel ] = strval( field );
mysql_fetch_field_row( field, "FishesCatched" ); P_DATA[ playerid ][ FishesCatched ] = strval( field );
mysql_fetch_field_row( field, "Age" ); P_DATA[ playerid ][ Age ] = strval( field );
mysql_fetch_field_row( field, "Sex" ); P_DATA[ playerid ][ Sex ] = strval( field );
}
mysql_free_result( );
}
else
{
SendClientMessage( playerid, COLOR_RED, "SERVER: You have entered a wrong password, try again." );
format( mystring,sizeof mystring, "{BECBFC}Welcome back, {95A3FF}%s{BECBFC}!\n\nPlease enter your password below to login to your account.", name );
ShowPlayerDialog( playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login step", mystring, "Login", "Exit" );
return true;
}
gPlayerLogged[ playerid ] = 1;
SetTimer( "UpdateAccount", 2000, 1 );
SpawnPlayer( playerid );
return true;
}
I think i've solved it. I've made a lil' debug and now it seems to work .
solved.