Creating array
#1

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

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.
Reply
#3

Ooh thankx
Reply
#4

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

whats the use of Static, Const In place of new ?
Reply
#6

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)