PDA

View Full Version : inputtext help


tyler12
03/08/2012, 01:06 PM
Hello,

Im trying to get my register system to work.
On this line, im getting many errors.

if(inputtext) == PlayerInfo[playerid][pPass])
NFT.pwn(386) : error 033: array must be indexed (variable "inputtext")
NFT.pwn(386) : error 029: invalid expression, assumed zero
NFT.pwn(386) : warning 215: expression has no effect
NFT.pwn(386) : error 001: expected token: ";", but found ")"
NFT.pwn(386) : fatal error 107: too many error messages on one line

Ive tried alot of things to try and fix it, but cant find anything

Also
INI_WriteInt(File,"Password",inputtext);
gives an error: NFT.pwn(372) : error 035: argument type mismatch (argument 3)
Im not sure what to do.

Any help would be appreciated.

- Tyler.

Sascha
03/08/2012, 01:11 PM
you can't compare 2 strings with "=="
use "strcmp"
http://wiki.sa-mp.com/wiki/Strcmp

in your case:

if(!strcmp(inputtext, PlayerInfo[playerid][pPass], false))

Johnson_boy
03/08/2012, 01:12 PM
Hello,

Im trying to get my register system to work.
On this line, im getting many errors.

if(inputtext) == PlayerInfo[playerid][pPass])
NFT.pwn(386) : error 033: array must be indexed (variable "inputtext")
NFT.pwn(386) : error 029: invalid expression, assumed zero
NFT.pwn(386) : warning 215: expression has no effect
NFT.pwn(386) : error 001: expected token: ";", but found ")"
NFT.pwn(386) : fatal error 107: too many error messages on one line


You cannot compare strings with ==, you must use strcmp. However, I still don't quite
understand what you are trying to achieve by comparing inputtext to pPass variable. Or
did you load the password of the player to the variable before this check?

But if you have the password stored in pPass variable, you should use this script then.
if(!strcmp(PlayerInfo[playerid][pPass], inputtext, false)) { // Passwords do match

And you should also hash your passwords (Whirlpool/SHA2), salting wouldn't hurt either.
Storing passwords as plain text is a great security vulnerability.

tyler12
03/08/2012, 01:21 PM
you can't compare 2 strings with "=="
use "strcmp"
http://wiki.sa-mp.com/wiki/Strcmp

in your case:

if(!strcmp(inputtext, PlayerInfo[playerid][pPass], false))


Thanks for that.
Repped.

What can i do for the 2nd? :S

Vince
03/08/2012, 01:25 PM
Sigh. I wish people would try to actually understand what a function does before trying to use it. INI_WriteInt ... Writes an INTeger to an ini file. Password is a string. You get the point?

Johnson_boy
03/08/2012, 01:25 PM
INI_WriteInt(File,"Password",inputtext);

You are using a function to set integer value, but the parameter you are giving is a string.
INI_WriteInt stands for INI_WriteInteger. I am not sure what the function is called, but my
guess is that it could be INI_Write(File, "Password", inputtext); You can check that from
your include.

EDIT: Someone is always faster :P The reply above is correct.

tyler12
03/08/2012, 01:28 PM
Sigh. I wish people would try to actually understand what a function does before trying to use it. INI_WriteInt ... Writes an INTeger to an ini file. Password is a string. You get the point?

You are using a function to set integer value, but the parameter you are giving is a string.
INI_WriteInt stands for INI_WriteInteger. I am not sure what the function is called, but my
guess is that it could be INI_Write(File, "Password", inputtext); You can check that from
your include.

EDIT: Someone is always faster :P The reply above is correct.

Thanks, both repped..

Hayden_Almeida
12/11/2015, 05:32 PM
you can't compare 2 strings with "=="
use "strcmp"
http://wiki.sa-mp.com/wiki/Strcmp

in your case:

if(!strcmp(inputtext, PlayerInfo[playerid][pPass], false))


Even typping the wrong password, the player is connecting in the account :/

Inside Dialog REGISTER:
format(PlayerInfo[playerid][pPass], 29, inputtext);
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteString(File,"Password", PlayerInfo[playerid][pPass]);

Inside DIALOG LOGIN:
if(!strcmp(inputtext, PlayerInfo[playerid][pPass], false))
{
???