SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 21/04/2009, 03:39 PM   #1
luxeon
Huge Clucker
 
Join Date: Dec 2007
Posts: 294
Reputation: 0
Default Using two or more arrays.

The question is:

How to make a variable have two different arrays?
pawn Code:
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
luxeon is offline  
Old 21/04/2009, 03:54 PM   #2
MenaceX^
High-roller
 
Join Date: Aug 2008
Posts: 3,262
Reputation: 13
Default Re: Using two or more arrays.

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];
MenaceX^ is offline  
Old 21/04/2009, 04:57 PM   #3
luxeon
Huge Clucker
 
Join Date: Dec 2007
Posts: 294
Reputation: 0
Default Re: Using two or more arrays.

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 Code:
new Variable[MAX_PLAYERS][128];
//   how to set a string into that [128] array?
//   and how to get it out from [128] array?


Luxeon
luxeon is offline  
Old 21/04/2009, 04:59 PM   #4
Francis[French]
Huge Clucker
 
Join Date: Jun 2007
Posts: 249
Reputation: 0
Default Re: Using two or more arrays.

Hi there,

You can use format.
pawn Code:
format(Variable[playerid], 128, "Hai there!");

Have fun scripting.

Kind regards,

Francis Morissette
SA-MP Scripter
http://sa-mp.com
Francis[French] is offline  
Old 21/04/2009, 05:01 PM   #5
Joe Staff
High-roller
 
Joe Staff's Avatar
 
Join Date: Aug 2007
Posts: 2,563
Reputation: 377
Default Re: Using two or more arrays.

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");
__________________
Big bottom girls make this rockin' world go 'round.
Joe Staff is offline  
Old 22/04/2009, 04:24 AM   #6
luxeon
Huge Clucker
 
Join Date: Dec 2007
Posts: 294
Reputation: 0
Default Re: Using two or more arrays.

thanks guys !

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


Luxeon
luxeon is offline  
Old 22/04/2009, 04:30 AM   #7
Backwardsman97
High-roller
 
Backwardsman97's Avatar
 
Join Date: Nov 2007
Posts: 1,501
Reputation: 36
Default Re: Using two or more arrays.

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?
Backwardsman97 is offline  
Old 22/04/2009, 04:38 AM   #8
luxeon
Huge Clucker
 
Join Date: Dec 2007
Posts: 294
Reputation: 0
Default Re: Using two or more arrays.

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 }
luxeon is offline  
Old 22/04/2009, 04:48 AM   #9
Backwardsman97
High-roller
 
Backwardsman97's Avatar
 
Join Date: Nov 2007
Posts: 1,501
Reputation: 36
Default Re: Using two or more arrays.

Like this?

pawn Code:
if(Variable[playerid][4] == blah)//?
Backwardsman97 is offline  
Old 22/04/2009, 04:49 AM   #10
Finn
High-roller
 
Join Date: Jan 2008
Posts: 1,465
Reputation: 382
Default Re: Using two or more arrays.

pawn Code:
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';
Finn is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with arrays Gozerr Help Archive 3 28/02/2010 01:07 PM
Arrays •Ajax• Help Archive 3 28/11/2009 06:40 AM
Help With Arrays StrickenKid Help Archive 1 01/10/2009 09:01 PM


All times are GMT. The time now is 12:56 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.