Using two or more arrays.
#1

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

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];
Reply
#3

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

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

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");
Reply
#6

thanks guys !

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


Luxeon
Reply
#7

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

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 }
Reply
#9

Like this?

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

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';
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)