inputtext help
#1

Hello,

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

pawn Код:
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
pawn Код:
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.
Reply
#2

you can't compare 2 strings with "=="
use "strcmp"
https://sampwiki.blast.hk/wiki/Strcmp

in your case:
pawn Код:
if(!strcmp(inputtext, PlayerInfo[playerid][pPass], false))
Reply
#3

Quote:
Originally Posted by tyler12
Посмотреть сообщение
Hello,

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

pawn Код:
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.
pawn Код:
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.
Reply
#4

Quote:
Originally Posted by Sascha
Посмотреть сообщение
you can't compare 2 strings with "=="
use "strcmp"
https://sampwiki.blast.hk/wiki/Strcmp

in your case:
pawn Код:
if(!strcmp(inputtext, PlayerInfo[playerid][pPass], false))
Thanks for that.
Repped.

What can i do for the 2nd? :S
Reply
#5

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

Quote:

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

Quote:
Originally Posted by Vince
Посмотреть сообщение
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?
Quote:
Originally Posted by Johnson_boy
Посмотреть сообщение
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..
Reply
#8

Quote:
Originally Posted by Sascha
Посмотреть сообщение
you can't compare 2 strings with "=="
use "strcmp"
https://sampwiki.blast.hk/wiki/Strcmp

in your case:
pawn Код:
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))
                {
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)