19.02.2013, 17:46
Thanks all. No errors now.
Only i have a problem with logging in.
When i enter the right password the server stops running.
OnDialogResponse:
LoginPlayer check:
How can i fix this?
Only i have a problem with logging in.
When i enter the right password the server stops running.
OnDialogResponse:
pawn Code:
case 0:
{
if(!response)return Kick(playerid);
mysql_format(gConnectionHandle, Query , "SELECT * FROM `users` WHERE `Username` = '%s' AND `Password` = md5('%s')",GetName(playerid),inputtext);
mysql_function_query(gConnectionHandle , Query , false ,"LoginPlayer" , "ii" , playerid,inputtext);
}
case 1:
{
if(!response)return Kick(playerid);
new IP[50];
GetPlayerIp(playerid,IP,sizeof (IP));
mysql_format(gConnectionHandle, Query, "INSERT INTO `users` (`Username`, `Password`, `Money`, `Score`, `Admin`, `Kills`, `Deaths`, `IP`) VALUES('%s' , md5('%s'), 5000, 0, 0, 0, 0, '%s')",GetName(playerid),inputtext,IP);
mysql_function_query(gConnectionHandle, Query, false , "OnQueryFinish", "ii",Query);
GivePlayerMoney(playerid,5000);
SetPlayerScore(playerid,0);
}
pawn Code:
public LoginPlayer(playerid,password)
{
mysql_store_result();
if(mysql_num_rows(gConnectionHandle) == 1)
{
if(mysql_retrieve_row())
{
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!");
}
}
else
{
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!");
}
mysql_free_result();
return 1;
}