Saving inputtext into variable.
#1

Hey.
I've got a problem with saving the inputtext (from OnDialogResponse) into a variable.
This:

Код:
Password[playerid] = inputtext;
Gives me this:

Код:
C:\Users\Viktor\Desktop\SAdmin\filterscripts\SAdmin.pwn(315) : error 006: must be assigned to an array
and this

Код:
if(inputtext == Password[playerid])
gives this

Код:
C:\Users\Viktor\Desktop\SAdmin\filterscripts\SAdmin.pwn(327) : error 033: array must be indexed (variable "inputtext")
I know I have to turn the Password[MAX_PLAYERS] into a variable, but I need to be a variable assigned to current playerid, so I can have two people registering at once... can anybody help me? Thanks.
Reply
#2

Your variable would need to be defined like this:
pawn Код:
new Password[MAX_PLAYERS][MAX PW LENGTH];
Reply
#3

Well, I actually got it like that (Password[MAX_PLAYERS][24] - max password length), but how to save the inputtext into the array now?
Reply
#4

Oh, I'm sorry.

In your case (inputtext length is not defined, hence not the same as the length of the password string), you can use format/strcat/strmid and possibly some more functions. I assume using format would be a simple solution but as far as I know, not as efficient as using strmid in this case.
pawn Код:
strmid(Password[playerid], inputtext, 0, strlen(inputtext));
Comparing strings in PAWN doesn't work as:
pawn Код:
if(string1 == string2)
You'll need to use the strcmp function (https://sampwiki.blast.hk/wiki/Strcmp):
pawn Код:
if(!strcmp(Password[playerid], inputtext, false))
Note that the false as the 3rd parameter also checks the input case.
Reply
#5

Works awesome, thank you!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)