STRCMP - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: STRCMP (
/showthread.php?tid=528852)
STRCMP -
venomlivno8 - 30.07.2014
When player requests class, not spawn, class.
pawn Код:
mysql_format(base_handle, query, sizeof(query), "SELECT * FROM accounts WHERE name = '%e' LIMIT 0,1", GetName(playerid));
mysql_tquery(base_handle, query, "DoesPlayerExist", "i", playerid);
DPE Callback
pawn Код:
forward DoesPlayerExist(playerid);
public DoesPlayerExist(playerid) { // Callback for MySQL check
new rows = mysql_num_rows();
new string[256];
if(!rows) {
format(string, sizeof(string), "{24B2FF}%s{FFFFFF}, welcome to {FF3636}Reloaded TDM{FFFFFF}!\nPlease type {FF3636}6-24 charachters{FFFFFF} long password to register!", GetName(playerid));
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Register", string, "Register", "Cancel");
}
else {
format(string, sizeof(string), "{24B2FF}%s{FFFFFF}, welcome back to {FF3636}Reloaded TDM{FFFFFF}!\nPlease log in using your password!", GetName(playerid));
LoadPlayer(playerid);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", string, "Login", "Cancel");
}
return 1;
}
LoadPlayer
pawn Код:
stock LoadPlayer(playerid) { // Loading player
new temp[24];
cache_get_row(0, 0, temp); PlayerInfo[playerid][pSQLID] = strval(temp);
cache_get_row(0, 1, PlayerInfo[playerid][pName]);
cache_get_row(0, 2, PlayerInfo[playerid][pPass]);
cache_get_row(0, 3, temp); SetPlayerScore(playerid, strval(temp));
printf("Loaded player %s", GetName(playerid));
return 1;
}
And now login dialog
pawn Код:
case 400: {
new string[256];
if(!response) return Kick(playerid);
if(strcmp(inputtext, PlayerInfo[playerid][pPass], false) == 0) {
ForceClassSelection(playerid);
format(string, sizeof(string), "{24B2FF}Reloaded TDM:{FFFFFF} Welcome back, %s!", GetName(playerid));
SendClientMessage(playerid, COLOR_WHITE, string);
}
else {
format(string, sizeof(string), "{24B2FF}%s{FFFFFF}, welcome back to {FF3636}Reloaded TDM{FFFFFF}!\nPlease log in using your password!\n\n{FF3636}Wrong password, try again!", GetName(playerid));
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", string, "Login", "Cancel");
}
}
But when I try to log in it accepts every string as a valid password and logs in.
What's the problem?