SA-MP Forums Archive
Using two or more arrays. - 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: Using two or more arrays. (/showthread.php?tid=74311)



Using two or more arrays. - luxeon - 21.04.2009

The question is:

How to make a variable have two different arrays?
pawn Код:
new Variable[MAX_PLAYERS][128];
//   how to set a string into that [128] array?
//   and how to get it out from [128] array?
<never tried something like this, so got no idea, and that's why i am asking>

Luxeon


Re: Using two or more arrays. - MenaceX^ - 21.04.2009

It's already there if I understand you well.

MAX_PLAYERS is array, 128 is array, two arrays

MAX_PLAYERS = 200, if you didn't know, so you can do
new Variable[200][128];


Re: Using two or more arrays. - luxeon - 21.04.2009

Quote:
Originally Posted by MenaceX^
It's already there if I understand you well.

MAX_PLAYERS is array, 128 is array, two arrays

MAX_PLAYERS = 200, if you didn't know, so you can do
new Variable[200][128];
yea it is, but the questions were:
pawn Код:
new Variable[MAX_PLAYERS][128];
//   how to set a string into that [128] array?
//   and how to get it out from [128] array?

Luxeon


Re: Using two or more arrays. - Francis[French] - 21.04.2009

Hi there,

You can use format.
pawn Код:
format(Variable[playerid], 128, "Hai there!");
Have fun scripting.

Kind regards,

Francis Morissette
SA-MP Scripter
http://sa-mp.com


Re: Using two or more arrays. - Joe Staff - 21.04.2009

If you're using it like a string, then you act as if the second array isn't there.

Variable[50] = "BACCCOONN!"

but whenever you use sizeof() you have to get rid of the number inside of the first array and not show the second array

format(Variable[50],sizeof(Variable[]),"%s is the shizzle!","bacon");


Re: Using two or more arrays. - luxeon - 22.04.2009

thanks guys !

how to use it with 'if()' ?
to check first and second array (two different examples please)


Luxeon


Re: Using two or more arrays. - Backwardsman97 - 22.04.2009

Quote:
Originally Posted by MenaceX^
It's already there if I understand you well.

MAX_PLAYERS is array, 128 is array, two arrays

MAX_PLAYERS = 200, if you didn't know, so you can do
new Variable[200][128];
Yeah but if you use MAX_PLAYERS and have a server with 30 slots, you can just go into a_samp and change MAX_PLAYERS to 30 instead of going into each script and changing that number.

Quote:
Originally Posted by Luxeon
thanks guys !

how to use it with 'if()' ?
to check first and second array (two different examples please)


Luxeon
And what exactly do you mean?


Re: Using two or more arrays. - luxeon - 22.04.2009

Quote:
Originally Posted by backwardsman97
Quote:
Originally Posted by MenaceX^
It's already there if I understand you well.

MAX_PLAYERS is array, 128 is array, two arrays

MAX_PLAYERS = 200, if you didn't know, so you can do
new Variable[200][128];
Yeah but if you use MAX_PLAYERS and have a server with 30 slots, you can just go into a_samp and change MAX_PLAYERS to 30 instead of going into each script and changing that number.

Quote:
Originally Posted by Luxeon
thanks guys !

how to use it with 'if()' ?
to check first and second array (two different examples please)


Luxeon
And what exactly do you mean?
how to check what the first array has, and the second one
Variable[first_array][second_array]
like: if(first_array == somethings){ //do something }
if(second_array == something2){ //blaa }


Re: Using two or more arrays. - Backwardsman97 - 22.04.2009

Like this?

pawn Код:
if(Variable[playerid][4] == blah)//?



Re: Using two or more arrays. - Finn - 22.04.2009

pawn Код:
new Variable[MAX_PLAYERS][128];

Variable[0][0] = 'A';

Variable[1][0] = 'B';

if(Variable[0][0] == 'A' && Variable[1][0] == 'B') Variable[2][0] = 'C';