SA-MP Forums Archive
Sniper Post Choosing - 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: Sniper Post Choosing (/showthread.php?tid=474223)



Sniper Post Choosing - Crayder - 07.11.2013

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?


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;
}



Re: Sniper Post Choosing - Crayder - 07.11.2013

Also, the only thing I need to fix, is making sure that the players connected do not share posts... (BTW: The max players for this mini-game is just 25, so the number of posts is fine...)


Re: Sniper Post Choosing - Crayder - 09.11.2013

Another thing... Every five kills I wanna give players a rocket... I tried to give them the rockets every time they kill 5 players using if(pInfo[playerid][KillStreak]%3), but that doesnt seem to work... How else could I do this?

(I used this post because I still need help with both of these...)


Re: Sniper Post Choosing - Crayder - 13.11.2013

I've waited a while, this is my last bump... But if someone would PLEASE HELP ME!!! Read my previous comments also, please...


Re: Sniper Post Choosing - RajatPawar - 13.11.2013

Use a flag (a boolean/integer) array to set post status for each player ( new isPOSTused[ MAX_POSTS ] ) OR an array for each player setting the player's index to the post number. Then loop through the array to check if the post is used by anyone, etc..


Re: Sniper Post Choosing - Crayder - 13.11.2013

Quote:
Originally Posted by Rajat_Pawar
Посмотреть сообщение
Use a flag (a boolean/integer) array to set post status for each player ( new isPOSTused[ MAX_POSTS ] ) OR an array for each player setting the player's index to the post number. Then loop through the array to check if the post is used by anyone, etc..
Im already setting the posts id to the player...
Also, can you help with this other problem? (Its in my comment)