STRCMP
#1

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?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)