07.11.2013, 02:09
I have a problem, minor problem really... I don't want player to share a sniping post in my gamemode... I have an array of coordinates for the post objects... Every time a player leaves a post (by dying or what not) I want to destroy it, then give them a new one... But, I don't want player to share a sniping post... So how do I choose a random post, destroy the last, make sure the new post is not being used, then give the player that empty post....?
This is what I have, I know I was wrong with this because the player will be sharing posts... PLease Help?
This is what I have, I know I was wrong with this because the player will be sharing posts... PLease Help?
pawn Код:
stock SetPlayerPost(playerid)
{
new PostNumber;
for(PostNumber = 0; PostNumber < 25; PostNumber++)
{
if( Pole[PostNumber] != INVALID_OBJECT_ID || Platform[PostNumber] != INVALID_OBJECT_ID )
PostNumber++;
}
new PostID = random(PostNumber);
if(Post[playerid] != -1)
{
DestroyObject(Pole[Post[playerid]]);
DestroyObject(Platform[Post[playerid]]);
}
if(Pole[PostID] != INVALID_OBJECT_ID || Platform[PostID] != INVALID_OBJECT_ID)
{
Post[playerid] = PostID;
Platform[PostID] = CreateObject(18769, ObjectPos[PostID][FloatX], ObjectPos[PostID][FloatY], ObjectPos[PostID][FloatZ], 0.0, 0.0, 0.0);
Pole[PostID] = CreateObject(18881, ObjectPos[PostID][FloatX], ObjectPos[PostID][FloatY], ObjectPos[PostID][FloatZ] - 100.0, 0.0, 0.0, 0.0);
SetPlayerPos(playerid, ObjectPos[PostID][FloatX], ObjectPos[PostID][FloatY], ObjectPos[PostID][FloatZ] + 2.0);
}
return 1;
}