SA-MP Forums Archive
lil' help here - 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: lil' help here (/showthread.php?tid=190772)



lil' help here - dark_clown - 16.11.2010

hum im making a register/login system
and im struglying a bit with this freaking error
well the first one who fix's it for me when i release it ill put the person's name
in the credits
pawn Код:
dcmd_login(playerid,params[])
{
    new file[128],pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pName,sizeof(pName));
    format(file,sizeof(file),"dregister/users/%s",pName);
    if(!dini_Exists(file)) return SendClientMessage(playerid,red,"ERROR:You arnt registered");
    new temp;
    temp = dini_Int(file,"Password");
    if(params == temp)
    {
        SendClientMessage(playerid,yellow,"Welcome %s, you have been logged in");
        PInfo[playerid][Logged] = 1;
        PInfo[playerid][Score] = dini_Int(file,"Score");
        PInfo[playerid][Cash] = dini_Int(file,"Cash");
    }
    return 1;
}
Код:
C:\Users\mike\Desktop\dregister.pwn(112) : error 033: array must be indexed (variable "params")
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase
1 Error.



Re: lil' help here - Joe Staff - 16.11.2010

you cannot compare strings (text) through the control structure method (==).
You have to use the native function 'strcmp'

example
pawn Код:
dcmd_login(playerid,params[])
    {
        new file[128],pName[MAX_PLAYER_NAME];
        GetPlayerName(playerid,pName,sizeof(pName));
        format(file,sizeof(file),"dregister/users/%s",pName);
        if(!dini_Exists(file)) return SendClientMessage(playerid,red,"ERROR:You arnt registered");
        new temp;
        temp = dini_Int(file,"Password");
        if(!strcmp(params,temp))
        {
            SendClientMessage(playerid,yellow,"Welcome %s, you have been logged in");
            PInfo[playerid][Logged] = 1;
            PInfo[playerid][Score] = dini_Int(file,"Score");
            PInfo[playerid][Cash] = dini_Int(file,"Cash");
        }
        return 1;
    }



Re: lil' help here - dark_clown - 16.11.2010

sorry but :
Quote:

C:\Users\mike\Desktop\dregister.pwn(112) : error 035: argument type mismatch (argument 2)
C:\Users\mike\Desktop\dregister.pwn(111) : warning 204: symbol is assigned a value that is never used: "temp"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
1 Error.

line
pawn Код:
if(!strcmp(params,temp))



Re: lil' help here - JaTochNietDan - 16.11.2010

I believe that your password should be a string, and therefore should be retrieved using the dini_Get function rather than the dini_Int function, which also means your "temp" should be an array in order to store all of the characters.

For example:
pawn Код:
dcmd_login(playerid,params[])
{
    new file[128],pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pName,sizeof(pName));
    format(file,sizeof(file),"dregister/users/%s",pName);
    if(!dini_Exists(file)) return SendClientMessage(playerid,red,"ERROR:You arnt registered");
    new temp[128];
    temp = dini_Get(file,"Password");
    if(!strcmp(params,temp))
    {
        SendClientMessage(playerid,yellow,"Welcome %s, you have been logged in");
        PInfo[playerid][Logged] = 1;
        PInfo[playerid][Score] = dini_Int(file,"Score");
        PInfo[playerid][Cash] = dini_Int(file,"Cash");
    }
    return 1;
}



Re: lil' help here - dark_clown - 16.11.2010

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
I believe that your password should be a string, and therefore should be retrieved using the dini_Get function rather than the dini_Int function, which also means your "temp" should be an array in order to store all of the characters.

For example:
pawn Код:
dcmd_login(playerid,params[])
{
    new file[128],pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pName,sizeof(pName));
    format(file,sizeof(file),"dregister/users/%s",pName);
    if(!dini_Exists(file)) return SendClientMessage(playerid,red,"ERROR:You arnt registered");
    new temp[128];
    temp = dini_Get(file,"Password");
    if(!strcmp(params,temp))
    {
        SendClientMessage(playerid,yellow,"Welcome %s, you have been logged in");
        PInfo[playerid][Logged] = 1;
        PInfo[playerid][Score] = dini_Int(file,"Score");
        PInfo[playerid][Cash] = dini_Int(file,"Cash");
    }
    return 1;
}
still got 1 error but thanks i fixed it my self