Creating 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)
+--- Thread: Creating array (
/showthread.php?tid=316126)
Creating array -
Shabi RoxX - 05.02.2012
How to create a array that will contain 2 or 3 information in each....
like
array:carsname
400 carname
401 ......
402 buffalo
.....
....
And
array:areaname
hitop x,y,z
and how to use thisin funtioncs etc
Re: Creating array -
[XST]O_x - 05.02.2012
pawn Код:
enum arrayinfo
{
id,
name[16]
}
new aInfo[][arrayinfo] =
{
{400,"landstalker"},
{401,"..."}
};
aInfo[0][id] = 400
aInfo[0][name] = landstalker
aInfo[1][id] = 401
aInfo[1][name] = ...
And so on.
Re: Creating array -
Shabi RoxX - 05.02.2012
Ooh thankx
Re: Creating array -
Jefff - 05.02.2012
or
pawn Код:
enum C_DATA {
Model,
Carname[32]
};
new array[][C_DATA] = {
{400,"Landstalker"},
{401,"..."}
};
array[0][Model] // 400
array[0][Carname] // Landstalker
enum A_DATA {
aName[24],
Float:aX,
Float:aY,
Float:aZ
};
new array[][A_DATA] = {
{"hitop1",x1,y1,z1},
{"hitop2",x2,y2,z2},
{"hitop3",x3,y3,z3},
{"hitop4",x4,y4,z4}
};
array[0][aName] // hitop1
array[0][aX] // x1
array[0][aY] // y1
array[0][aZ] // z1
Re: Creating array -
Shabi RoxX - 06.02.2012
whats the use of Static, Const

In place of new ?
Re: Creating array -
Vince - 06.02.2012
A static global is no different than a new global, except that static variables are always restricted to the file they are in. A static local acts like a global variable (without it actually being global) but only within the function itself. It remembers its value between seperate function calls. The wiki explains this very well:
https://sampwiki.blast.hk/wiki/Keywords:Initialisers#static
The const modifier declares the created variable as a constant. This means the variable will not be stored on the stack and that it cannot be modified by code. If you try to modify it the compiler will complain.