SA-MP Forums Archive
Login / Register cant retrive data - dini - 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 / Register cant retrive data - dini (/showthread.php?tid=142577)



Login / Register cant retrive data - dini - IamNotKoolllll - 18.04.2010

C:\Users\Mathew\Desktop\freeroam.pwn(919) : error 033: array must be indexed (variable "ppassword")
C:\Users\Mathew\Desktop\freeroam.pwn(925) : error 033: array must be indexed (variable "ppassword")
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


2 Errors.

dcmd_login(playerid, params[])
{
new pass;
if(sscanf(params, "s", pass)) SendClientMessage(playerid, COLOR_RED, "Usage: /login <password>");
else
{
new name[MAX_PLAYER_NAME], file[100];
GetPlayerName(playerid, name, sizeof(name));
format(file,sizeof(file),PlayerFile,name);
ppassword == dini_Get(file, "password");
// strcat(ppassword, dini_Get(file,"password"));
if(!dini_Exists(file))
{
SendClientMessage(playerid, COLOR_RED, "This name is not registered! register it with /register!");
}else{
if(pass == ppassword)
{
regged[playerid] = 1;
logged[playerid] = 1;
SendClientMessage(playerid, COLOR_GREEN, "Your now logged in!");
}else{
SendClientMessage(playerid, COLOR_RED, "Your password is incorrect!");
}
}
}
return 1;
}
wut do i do D:


Re: Login / Register cant retrive data - dini - Backwardsman97 - 19.04.2010

How did you declare ppassword?


Re: Login / Register cant retrive data - dini - Jay_ - 19.04.2010

Код:
ppassword == dini_Get(file, "password");
== is used to check if one value is equal to another. = is used to set one value to another. I would say you need to use =, but that probably won't work. Presuming dini_Get returns a string, you need to format the ppassword variable into that string (providing ppassword is a string too that is).

Код:
new ppassword[256];
format(ppassword, 256, "%s", dini_Get(file, "password"));
Additionally, it would be more efficient to check if the username is registered before getting the password.


Re: Login / Register cant retrive data - dini - Injection - 19.04.2010

Hmm.
dini_Get is used for strings, and here "if(pass == ppassword)" you checking if interger equal to string.
This is the main source of your problem.


Re: Login / Register cant retrive data - dini - IamNotKoolllll - 19.04.2010

Quote:
Originally Posted by _Jay_
Код:
ppassword == dini_Get(file, "password");
== is used to check if one value is equal to another. = is used to set one value to another. I would say you need to use =, but that probably won't work. Presuming dini_Get returns a string, you need to format the ppassword variable into that string (providing ppassword is a string too that is).

Код:
new ppassword[256];
format(ppassword, 256, "%s", dini_Get(file, "password"));
Additionally, it would be more efficient to check if the username is registered before getting the password.
il give urs a try