SA-MP Forums Archive
PLAYER LEAVING PICKUP - 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: PLAYER LEAVING PICKUP (/showthread.php?tid=581282)



PLAYER LEAVING PICKUP - BruLaX - 11.07.2015

Hello,

I have a litle problem i have robbing system and i would like to make it with pickups but the thing is when you are on the pickup and your robbing it takes 30 sec to rob a store but i would like to now when a player leaves a pickups so it can cancel the robbing and i dont now how to do good.

Thank You


Re: PLAYER LEAVING PICKUP - SilentSoul - 11.07.2015

You can check by using IsPlayerInRangeOfPoint function, just to check if he is still near the pickup, you may also start a 1 second repeating timer and decrease its variable and show him a gametext for the time left, it will be helpful also to detect whether if he still pick it up or not

pawn Код:
new
        PlayerRobbery[ MAX_PLAYERS ] = 0,
        PlayerTimer[ MAX_PLAYERS ] = -1,
        bool:RobberyStart[ MAX_PLAYERS] = false;
public OnPlayerConnect( playerid )
{
    PlayerRobber[ playerid ] = 0;
    RobberyStart[ playerid ] = false;
    return true;
}
public OnPlayerPickUpPickup( playerid, pickupid )
{
    if( pickupid == .. )
    {
        if( RobberyStart[ playerid ] == false )
        {
            RobberyStart[ playerid ] = true;
            PlayerTimer[ playerid ] = SetTimerEx("Robbery", 1000, "i", playerid );
            PlayerRobbery[ playerid ] = 30;
        }
    }
    return 1;
}
forward Robbery( playerid );
public Robbery( playerid )
{
    if( PlayerRobbery[ playerid ] > 0 )
    {
        PlayerRobbery[ playerid ] --;
        if(IsPlayerInRangeOfPoint( playerid, 1.0, x, y , z ) )
        {
            //if he still pick it up
        }
        else
        {
            KillTimer( PlayerTimer[ playerid ] );
            RobberyStart[ playerid ] = false;
            //he left the pickup!
        }
    }
    if( PlayerRobbery[ playerid ] <= 0 )
    {
        KillTimer( PlayerTimer[ playerid ] );
        RobberyStart[ playerid ] = false;
    }
}