select ID from Array?
#1

Hey,

i want to create random spawns. Therefor I created this array:
Код:
new r_spawn[][] = 
{
{1,x,y,z,r},
{1,x,y,z,r},
{2,x,y,z,r},
{5,x,y,z,r},
...
{ID,x,y,z,r}
};
I put all the coords i have in this array. ( For /spawn1, /spawn2 )

As you can see the "1" is an ID which is given to the coords. If I type "spawn1" i want spawn at a random position -> Where ID = 1

If I type "spawn2" i want so spawn at a random position -> Where ID = 2


I hope you understand what i mean.


-Happy new year
Reply
#2

pawn Код:
new Float:r_spawn[][] =
{
     {Float:x, Float:y, Float:z, Float: r},
     // etc.
};
To select where a user spawns, You can do this.
pawn Код:
r_spawn[ID][Var];
Example:
pawn Код:
CMD:spawn1(playerid, params[])
{
     new rand = random(sizeof(r_spawn));
     SetPlayerPos(r_spawn[rand][x], r_spawn[rand][y], r_spawn[rand][z]);
     return 1;
}
EDIT: If you want to more than one random spawns, You will have to create more than one array I believe.
Reply
#3

Thanks but i already knew that.
I know that I actually can create more Arrays. One for each ID. But i want to create one for all
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)