SA-MP Forums Archive
How to assign this to array? - 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: How to assign this to array? (/showthread.php?tid=142492)



How to assign this to array? - Torran - 18.04.2010

How do i assign this to an array?

Heres what i have

pawn Код:
PlayersInput[playerid] = inputtext;
But that brings error: Must be assigned to array


Re: How to assign this to array? - Correlli - 18.04.2010

pawn Код:
format(PlayersInput[playerid], sizeof(PlayersInput), "%s", inputtext);



Re: How to assign this to array? - ¤Adas¤ - 18.04.2010

Quote:
Originally Posted by Don Correlli
pawn Код:
format(PlayersInput[playerid], sizeof(PlayersInput), "%s", inputtext);
It is enough to do:

pawn Код:
format(PlayersInput[playerid], sizeof(PlayersInput), inputtext);



Re: How to assign this to array? - Torran - 18.04.2010

Quote:
Originally Posted by Don Correlli
pawn Код:
format(PlayersInput[playerid], sizeof(PlayersInput), "%s", inputtext);
Yeah that works, How to check if a player didnt type in anything?


Re: How to assign this to array? - Westie - 18.04.2010

It looks like PlayersInput is only an one dimensional array, so that what your problem will be. Your original example of...

Код:
PlayersInput[playerid] = inputtext;
... could actually work, if you made it correctly. Maybe make it something like this?

Код:
new PlayersInput[MAX_PLAYERS][130];



Re: How to assign this to array? - Torran - 18.04.2010

Quote:
Originally Posted by Joe Torran C
Quote:
Originally Posted by Don Correlli
pawn Код:
format(PlayersInput[playerid], sizeof(PlayersInput), "%s", inputtext);
Yeah that works, How to check if a player didnt type in anything?



Re: How to assign this to array? - Correlli - 18.04.2010

Quote:
Originally Posted by Joe Torran C
Yeah that works, How to check if a player didnt type in anything?
https://sampwiki.blast.hk/wiki/Strlen


Re: How to assign this to array? - Torran - 18.04.2010

Quote:
Originally Posted by Don Correlli
Quote:
Originally Posted by Joe Torran C
Yeah that works, How to check if a player didnt type in anything?
https://sampwiki.blast.hk/wiki/Strlen
Cool ty