Detecting if player is on a pickup
#1

Hi everyone,

Like the title says, is there something like OnPlayerLeaveDynamicCP, but then for dynamic pickups?
I made something, that shows a textdraw when on a pickup, but i don't know how to hide them as soon as the player leaves the pickup..

Everything is welcome, thanks in advance
Reply
#2

Use timer after they pickup the pickup.
Reply
#3

Yeah, but how to check if the player is picking up something?
Maybe its pretty abvious, but im really tired xD
Reply
#4

Maybe you can try this?
pawn Код:
//OnPlayerPickupPickup
{
    if(pickupid == yourpickupID)
    {
         TextDrawShow....()
         SetTimer("test",5000,false);
    }
    return 1;
}

forward test(playerid);
public test(playerid)
{
     TextDrawHideForPlayer();
     return 1;
}
Reply
#5

ah, thats a great idea.. thanks
Reply
#6

What you should do is ignore the OnPlayerPickUpPickup and just determine if the player is within pickup range with a timer

pawn Код:
new PlayerPickup[MAX_PLAYERS];
new PickupPos[2][3]={        //2 Pickup positions of 3 dimensions
    {0.0,0.0,0.0},                //Pickup Positions (x,y,z)
    {1000.0,2000.0,-10.0}
};
stock GetPlayerPickup(playerid)return PlayerPickup[playerid];
forward PickupCheck();

public OnGameModeInit()
{
    SetTimer("PickupCheck",1000,1);

    for(new pickup;pickup<sizeof PickupPos; pickup++)
    CreatePickup(1242, 2, PickupPos[pickup][0], PickupPos[pickup][1], PickupPos[pickup][2], -1); //create visual pickup, you can also use 3D Texts or objects here
}
public PickupCheck()
{
    for(new playerid; playerid<MAX_PLAYERS;playerid++)
    {
        if(!IsPlayerConnected(playerid))continue;
        PlayerPickup[playerid]=-1;
        for(new pickup; pickup<sizeof PickupPos; pickup++)
        if(IsPlayerInRangeOfPoint(playerid,3.0,PickupPos[pickup][0],PickupPos[pickup][1],PickupPos[pickup][2]))
        {
            PlayerPickup[playerid]=pickup;
            //Place code here for ticking functions (every 1 second)
        }
    }
}
After this you could easily get what Pickup that the player is standing on with GetPlayerPickup(playerid) or you could set code to activate every second of the player standing on the pickup by placing it at the commented line. Also you should be able to easily define pickups
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)