How to check from arrays? -
K0P - 24.06.2016
Forexample i have a Float Array:
Код:
new Float:Array [][4] =
{x,y,z,a},
{x,y,z,a},
{x,y,z,a}
}
Actually i am making a derby system,I want to check if a player is spawned at one of these cords or not.
Re: How to check from arrays? -
Sjn - 24.06.2016
I don't get what you actually mean but why not just check it with a variable? When a player joins a derby set a var to true/1 right when you spawn them using one of those coord(s).
Re: How to check from arrays? -
K0P - 24.06.2016
I mean,how will i check if one of these coords are used? I want to avoid 2 players spawning is 1 place
Re: How to check from arrays? -
Konstantinos - 24.06.2016
Using another array with the same size and set accordingly (to true when the spot is taken or to false when not). To me though, the best way would be an iterator from foreach/y_iterate. When a derby match is starting, add all the free slots to the iterator and when a player joins, pick up a random slot and remove it from the iterator afterwards.
Re: How to check from arrays? -
K0P - 24.06.2016
Can i do like this?:
Код:
new Used[5];
OnPlayerSpawn(playerid)
{
new spawn = random(sizeof(Array));
if(Used[spawn] == 0)
{
SetPlayerPos(playerid, Array[spawn][0].....);
for(new i = 0; i < sizeof(Array); i++)
{
Used[i] == 1;
}
}
return 1;
}
Re: How to check from arrays? -
Konstantinos - 24.06.2016
The loop has no meaning, all you have to do is:
pawn Код:
SetPlayerPos(playerid, Array[spawn][0].....);
Used[spawn] = 1;
but again, for random slots and without loops to retrieve a random free slot foreach/y_iterate is the best option.
Re: How to check from arrays? -
Stinged - 24.06.2016
Are you actually asking if the spawn is used or if the player is using one of those spawns?
Because if you want to check if the player is using one of those spawns, you need to make a 2d array.
(Used[playerid][spawnid] -- spawnid is the spawns array slot)