Login Problem
#1

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
Reply
#2

if(strcmp(password, inputtext, true))
Reply
#3

Try:

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

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)
    {
        // ...
    }
}
Reply
#5

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

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

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.
Reply
#8

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. ^^
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)