Login Password Check
#1

pawn Код:
tmp = gPlayerInfo[playerid][pPassword];
            if(inputtext != tmp)
I am trying to check if the input text of the login dialog matches the player's password it should work except I get this error:

pawn Код:
RPScratch.pwn(319) : error 033: array must be indexed (variable "inputtext")
Line 319 is:
pawn Код:
if(inputtext != tmp)
Thanks
Reply
#2

change this
pawn Код:
if(inputtext != tmp)
With This
pawn Код:
if(strlen(inputtext) != tmp)
Reply
#3

It saves it now without errors but it saves a number under the password in the .ini file? Like if the password is bob, it makes it 3 not bob
Reply
#4

Quote:
Originally Posted by Tommy_Mandaz
Посмотреть сообщение
It saves it now without errors but it saves a number under the password in the .ini file? Like if the password is bob, it makes it 3 not bob
cant help only by looking at that code
Reply
#5

It makes numbers instead of name? Maybe you use something to hash the password?
Reply
#6

I sent you a pm
Reply
#7

Here is my dialog response code:

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 1) //Register
    {
        if(response)
        {
            new name[MAX_PLAYER_NAME], files[256];
            GetPlayerName(playerid, name, sizeof(name));
            format(files, sizeof(files), "%s.ini", name);
            {
                new INI:file = INI_Open(files);
                INI_WriteInt(file, "Password", strlen(inputtext));
                INI_WriteInt(file, "Level", 1);
                gPlayerInfo[playerid][pLevel] = 1;
                SetPlayerScore(playerid,1);
                INI_WriteInt(file, "Money", 5000);
                gPlayerInfo[playerid][pMoney] = 5000;
                GivePlayerMoney(playerid,5000);
                INI_WriteInt(file, "Health", 100);
                gPlayerInfo[playerid][pHealth] = 100;
                SetPlayerHealth(playerid,100);
                INI_WriteInt(file, "Armour", 0);
                gPlayerInfo[playerid][pArmour] = 0;
                SetPlayerArmour(playerid,0);
                INI_WriteInt(file, "Skin", 26);
                gPlayerInfo[playerid][pSkin] = 26;
                SetPlayerSkin(playerid,26);
                INI_Close(file);
                return 1;
            }
        }
    }
    if(dialogid == 2) //Login
    {
        if(response)
        {
            new name[MAX_PLAYER_NAME], file[256];
            GetPlayerName(playerid, name, sizeof(name));
            INI_ParseFile(file, "LoadUser_%s", .bExtra = true, .extra = playerid);
            format(file, sizeof(file), "%s.ini", name);
            new tmp;
            tmp = gPlayerInfo[playerid][pPassword];
            if(strlen(inputtext) != tmp)
            {
                SendClientMessage(playerid, COLOR_LIGHTRED, "[SYSTEM]: Error Incorrect Password!");
                ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Player Login", "Please Type In Your Password Below:", "Login", "Cancle");
            }
            else
            {
                SetPlayerSkillLevel(playerid, WEAPONSKILL_SAWNOFF_SHOTGUN, 1);
                SetPlayerSkillLevel(playerid, WEAPONSKILL_MICRO_UZI, 1);
                SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL, 1);
                SetPlayerScore(playerid, gPlayerInfo[playerid][pLevel]);
                GivePlayerMoney(playerid, gPlayerInfo[playerid][pMoney]);
                SetPlayerSkin(playerid, gPlayerInfo[playerid][pSkin]);
                SetPlayerHealth(playerid, gPlayerInfo[playerid][pHealth]);
                SetPlayerArmour(playerid, gPlayerInfo[playerid][pArmour]);
            }
        }
    }
    return 1;
}
Reply
#8

Try This
pawn Код:
enum pInfo
{
    pPassword,
    pLevel,
    pMoney,
    pArmour,
    pHealth,
    pSkin
}
new gPlayerInfo[MAX_PLAYERS][pInfo];

public OnPlayerRequestClass(playerid, classid)
{
    TogglePlayerSpectating(playerid, 1);
    SpawnPlayer(playerid);
    return 1;
}

public OnPlayerConnect(playerid)
{
    new name[MAX_PLAYER_NAME], file[256];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), "%s.ini", name);
    if(fexist(file))
    {
        ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Player Login", "Please Type In Your Password Below:", "Login", "Cancle");
    }
    else
    {
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Player Registration", "Please Type In Your Desired Password Below:", "Register", "Cancle");
    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    new name[MAX_PLAYER_NAME], playerfile[256];
    GetPlayerName(playerid, name, sizeof(name));
    format(playerfile, sizeof(playerfile), "%s.ini", name);
    {
        new INI:Accfile = INI_Open(playerfile);
        INI_WriteInt(Accfile, "Level", gPlayerInfo[playerid][pLevel]);
        INI_WriteInt(Accfile, "Money", GetPlayerMoney(playerid));
        INI_WriteInt(Accfile, "Money",GetPlayerMoney(playerid));
        INI_WriteFloat(Accfile, "Health", gPlayerInfo[playerid][pHealth]);
        new Float:Armor; GetPlayerArmour(playerid, Armor);
        INI_WriteFloat(Accfile, "Armour",Armor);
        INI_WriteInt(Accfile, "Skin", gPlayerInfo[playerid][pSkin]);
        INI_Close(Accfile);
    }
    return 1;
}

public OnPlayerSpawn(playerid)
{
    TogglePlayerSpectating(playerid, 0);
    SetPlayerPos(playerid,-187.3777,1204.4523,19.6859);
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 1) //Register
    {
        if(response)
        {
            new name[MAX_PLAYER_NAME], files[256];
            GetPlayerName(playerid, name, sizeof(name));
            format(files, sizeof(files), "%s.ini", name);
            {
                new INI:file = INI_Open(files);
                INI_WriteString(Acc,"Password", inputtext);
                INI_WriteInt(file, "Level", 1);
                gPlayerInfo[playerid][pLevel] = 1;
                SetPlayerScore(playerid,1);
                INI_WriteInt(file, "Money", 5000);
                gPlayerInfo[playerid][pMoney] = 5000;
                GivePlayerMoney(playerid,5000);
                INI_WriteInt(file, "Health", 100);
                gPlayerInfo[playerid][pHealth] = 100;
                SetPlayerHealth(playerid,100);
                INI_WriteInt(file, "Armour", 0);
                gPlayerInfo[playerid][pArmour] = 0;
                SetPlayerArmour(playerid,0);
                INI_WriteInt(file, "Skin", 26);
                gPlayerInfo[playerid][pSkin] = 26;
                SetPlayerSkin(playerid,26);
                INI_Close(file);
                return 1;
            }
        }
    }
    if(dialogid == 2) //Login
    {
        if(response)
        {
            new name[MAX_PLAYER_NAME], file[256];
            GetPlayerName(playerid, name, sizeof(name));
            INI_ParseFile(file, "LoadUser_%s", .bExtra = true, .extra = playerid);
            format(file, sizeof(file), "%s.ini", name);
            new tmp;
            tmp = gPlayerInfo[playerid][pPassword];
            if(strlen(inputtext) != tmp)
            {
                SendClientMessage(playerid, COLOR_LIGHTRED, "[SYSTEM]: Error Incorrect Password!");
                ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Player Login", "Please Type In Your Password Below:", "Login", "Cancle");
            }
            else
            {
                SetPlayerSkillLevel(playerid, WEAPONSKILL_SAWNOFF_SHOTGUN, 1);
                SetPlayerSkillLevel(playerid, WEAPONSKILL_MICRO_UZI, 1);
                SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL, 1);
                SetPlayerScore(playerid, gPlayerInfo[playerid][pLevel]);
                GivePlayerMoney(playerid, gPlayerInfo[playerid][pMoney]);
                SetPlayerSkin(playerid, gPlayerInfo[playerid][pSkin]);
                SetPlayerHealth(playerid, gPlayerInfo[playerid][pHealth]);
                SetPlayerArmour(playerid, gPlayerInfo[playerid][pArmour]);
            }
        }
    }
    return 1;
}

public LoadUser(playerid, name[], value[])
{
    INI_Int("Password", gPlayerInfo[playerid][pPassword]);
    INI_Int("Level", gPlayerInfo[playerid][pLevel]);
    INI_Int("Money", gPlayerInfo[playerid][pMoney]);
    INI_Int("Skin", gPlayerInfo[playerid][pSkin]);
    INI_Int("Health", gPlayerInfo[playerid][pHealth]);
    INI_Int("Armour", gPlayerInfo[playerid][pArmour]);
    return 1;
}
Reply
#9

strlen(inputtext) != tmp) this says if the lenth of inputtext equal the players password log them in?

use
pawn Код:
if(strcmp(inputtext, tmp, false)){
it was the first bit of code you got that is puting you wrong
Reply
#10

pawn Код:
if(dialogid == 2) //Login
    {
        if(response)
        {
            new name[MAX_PLAYER_NAME], file[256];
            GetPlayerName(playerid, name, sizeof(name));
            INI_ParseFile(file, "LoadUser_%s", .bExtra = true, .extra = playerid);
            format(file, sizeof(file), "%s.ini", name);
            new tmp;
            tmp = gPlayerInfo[playerid][pPassword];
            if(strcmp(inputtext, tmp, false))
            {
                SendClientMessage(playerid, COLOR_LIGHTRED, "[SYSTEM]: Error Incorrect Password!");
                ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Player Login", "Please Type In Your Password Below:", "Login", "Cancle");
            }
            else
            {
                SetPlayerSkillLevel(playerid, WEAPONSKILL_SAWNOFF_SHOTGUN, 1);
                SetPlayerSkillLevel(playerid, WEAPONSKILL_MICRO_UZI, 1);
                SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL, 1);
                SetPlayerScore(playerid, gPlayerInfo[playerid][pLevel]);
                GivePlayerMoney(playerid, gPlayerInfo[playerid][pMoney]);
                SetPlayerSkin(playerid, gPlayerInfo[playerid][pSkin]);
                SetPlayerHealth(playerid, gPlayerInfo[playerid][pHealth]);
                SetPlayerArmour(playerid, gPlayerInfo[playerid][pArmour]);
            }
        }
    }
    return 1;
}
I get these error:

pawn Код:
RPScratch.pwn(321) : error 035: argument type mismatch (argument 2)
RPScratch.pwn(320) : warning 204: symbol is assigned a value that is never used: "tmp"
Line 321:
pawn Код:
if(strcmp(inputtext, tmp, false))
Line 320:
pawn Код:
tmp = gPlayerInfo[playerid][pPassword];
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)