SA-MP Forums Archive
Login Problem - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Login Problem (/showthread.php?tid=163948)



Login Problem - Jonni8 - 29.07.2010

Hey.
I just tried to make a login system but i have an error with my array index...
Here my Code:

pawn Код:
CMD:login(playerid, params[])
{
    new pname[56];
    new file[56];
    new password[256];
   
    GetPlayerName(playerid, pname, sizeof(pname));
    format(file, sizeof(file), "//USERS//%s.ini", pname);
   
    if (sscanf(params, "", params[0]))
    {
        SendClientMessage(playerid, RED, "BENUTZE: /login [PASSWORT]");
    }  
    else
    {
        if (fexist(file))
        {
            if (GetPVarInt(playerid, "IsLogged") == 0)
            {
                password = dini_Get(file, "Passwort");
                if (udb_hash(params[0]) == password)
                {
                    SendClientMessage(playerid, YELLOW, "Erfolgreich eingeloggt.");
                   
                    Player[playerid][Kills] = dini_Int(file, "Kills");
                    Player[playerid][Tode] = dini_Int(file, "Tode");
                    Player[playerid][Money] = dini_Int(file, "Money");
                    Player[playerid][Konto] = dini_Int(file, "Konto");
                    Player[playerid][Wanted] = dini_Int(file, "Wanted");
                    Player[playerid][ALevel] = 0;
                    Player[playerid][Fraktion] = dini_Int(file, "Fraktion");
                    Player[playerid][Rank] = dini_Int(file, "Rank");
                    Player[playerid][Skin] = dini_Int(file, "Skin");
                   
                    SetPlayerSkin(playerid, Player[playerid][Skin]);
                   
                    SetPVarInt(playerid, "IsLogged", 1);
                }
                else
                {
                    SendClientMessage(playerid, RED, "SERVER: Falsches Passwort");
                    printf("%s : Failed Login", pname);
                }
            }
            else
            {
                SendClientMessage(playerid, RED, "SERVER: Du bist bereits eingeloggt.");
            }
        }
        else
        {
            SendClientMessage(playerid, RED, "SERVER: Du hast noch keinen Account.");
            SendClientMessage(playerid, RED, "SERVER: Benutze /register [PASSWORT] um einen zu erstellen.");
        }
    }
    return 1;
}
My Error:
Quote:

C:\Users\Jonni\Desktop\SA-MP Server\gamemodes\TheKillerzBeta.pwn(2140) : error 033: array must be indexed (variable "password")

The Exact Line:
pawn Код:
if (udb_hash(params[0]) == password)
Hm I really dont know what i did wrong...
Please help


Re: Login Problem - Kar - 29.07.2010

if(strcmp(password, inputtext, true))


Re: Login Problem - Jeffry - 29.07.2010

Try:

pawn Код:
if(!strcmp(udb_hash(params[0]), password, false))



Re: Login Problem - Vince - 29.07.2010

Sure, put a whole password in one cell of an array. <.<

pawn Код:
new
    tmppass[64];

if(sscanf(params, "s", tmppass))
{
    SendClientMessage(playerid, RED, "BENUTZE: /login [PASSWORT]");
}
else
{
    // ...
    if (udb_hash(tmppass) == password)
    {
        // ...
    }
}



Re: Login Problem - Jonni8 - 29.07.2010

@Vince: Doesn't work... same error
@Jeffry: Type Missmatch error


Re: Login Problem - Jeffry - 30.07.2010

Meh^^. Try:

pawn Код:
if(!strcmp(udb_hash(params), password, false))
If it wont work:
pawn Код:
new tmp[256];
format(tmp, 256, "%s", udb_hash(params));
if(!strcmp(tmp, password, false))
Is it still doesn't work:
Is the udb_hash making a number code? And is "password" a number code, or letters?



Re: Login Problem - Jonni8 - 30.07.2010

With your second suggestion I have no compiler errrors, but it doesn matter which password i type in and everytime logs in.

For your question: I want to save letters and numbers in the password.


Re: Login Problem - Jeffry - 31.07.2010

You can upload your full script at www.pastebin.com and PM me the link. Then I can try it at my PC and give you the working code.
PS: I wont steal your script, I have my own server. ^^