19.02.2013, 20:52
(
Last edited by BlackBank; 19/02/2013 at 09:03 PM.
Reason: Overlooked the return Kick(); thanks to Gamer_Z ;)
)
pawn Code:
public LoginPlayer(playerid,password)
{
mysql_store_result(gConnectionHandle);
if(mysql_retrieve_row(gConnectionHandle) == 1)
{
mysql_fetch_field_row(mysqlstring, "Money"); GivePlayerMoney(playerid,strval(mysqlstring));
mysql_fetch_field_row(mysqlstring, "Score"); SetPlayerScore(playerid,strval(mysqlstring));
mysql_fetch_field_row(mysqlstring, "Admin"); PlayerInfo[playerid][pAdmin] = strval(mysqlstring);
mysql_fetch_field_row(mysqlstring, "Kills"); PlayerInfo[playerid][pKills] = strval(mysqlstring);
mysql_fetch_field_row(mysqlstring, "Deaths"); PlayerInfo[playerid][pDeaths] = strval(mysqlstring);
SendClientMessage(playerid,-1,"Succesfull Logged IN!");
mysql_free_result(gConnectionHandle);
}
else
{
mysql_free_result(gConnectionHandle);
SetPVarInt(playerid,"WrongPassword", GetPVarInt(playerid , "WrongPassword") + 1);
if(GetPVarInt(playerid,"WrongPassword")==3)
{
SendClientMessage(playerid,-1,"Kicked From Server , Reason : Failed Logins !");
return Kick(playerid);
}
format(mysqlstring,sizeof (mysqlstring),"Welcome %s /n Type your password below to Login on your CnR Account!",GetName(playerid));
ShowPlayerDialog(playerid, 0 , DIALOG_STYLE_PASSWORD, "Login on your CnR Account!",mysqlstring,"OK","Cancel");
SendClientMessage(playerid,-1,"Wrong Password!");
}
return 1;
}
There is no need to check how much rows it has, you could simple fix this to add 'LIMIT 1' after your login query.
Also i have added 'gConnectionHandle' to all the mysql function, maybe this causes the crash.
