SA-MP Forums Archive
select ID from 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: select ID from Array? (/showthread.php?tid=554189)



select ID from Array? - yellow - 02.01.2015

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


Re: select ID from Array? - Sledgehammer - 02.01.2015

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.


AW: select ID from Array? - yellow - 02.01.2015

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