onPickupExited (New Custom Event)

Started by Sonmez, Jan 07, 2021, 09:02 AM

Previous topic - Next topic

Sonmez

Syntax
function onPickupExited( player, pickup )

Example
function onPickupExited( player, pickup )
{
  if ( pickup.Model == 408 )
  {
    MessagePlayer( "You exited from pickup with model 408", player );
  }
}

Source Code
function onScriptLoad()
{
  LastPickup <- array(GetMaxPlayers(),null)
}
function onPlayerJoin( player )
{
  LastPickup[player.ID] = null;
}
function onPickupPickedUp( player, pickup )
{
  LastPickup[player.ID] = pickup;
}
function onPlayerMove( player, lastX, lastY, lastZ, newX, newY, newZ )
{
  if (LastPickup[player.ID] != null)
  {
    local LP = LastPickup[player.ID];
    local DistanceFromLastPickup = DistanceFromPoint( newX, newY, LP.Pos.x, LP.Pos.y).tointeger();
    if (DistanceFromLastPickup > 0.5)
    {
      onPickupExited(player,LP)
      LastPickup[player.ID] = null;
    }
  }
}

function onPickupExited( player,pickup )
{
  MessagePlayer("Wow, new function!. It works...",player);
}
if (!perfect) createAgain();

SHy^

Isn't onPickupClaimPicked(player, pickup) the function when a player exists the pickup?

Sebastian

I think this is more useful for when pickup doesn't dissappear after you pick it up.
This way sonmez did makes pickup act like some sort of sphere/checkpoint

KrOoB_

Quote from: Sebastian on Jan 07, 2021, 01:36 PMI think this is more useful for when pickup doesn't dissappear after you pick it up.
This way sonmez did makes pickup act like some sort of sphere/checkpoint
Exactly!

Quote from: SHy^ on Jan 07, 2021, 10:04 AMIsn't onPickupClaimPicked(player, pickup) the function when a player exists the pickup?

when you teleport the player with a checkpoint, that function won't work.
I did a lot of tests before

@Sonmez gj mate

Altay

We are getting closer step by step. Time to see revolution my partner. This event will help new coders.
Mustafa Kemal ATATURK, the man who changed the course of history. https://en.wikipedia.org/wiki/Mustafa_Kemal_Atat%C3%BCrk

NicusorN5

Quote from: |ADMIN|Yankee on Jan 08, 2021, 11:54 AMWe are getting closer step by step. Time to see revolution my partner. This event will help new coders.
lmao what? By the way - where you got your profile pic? (lmao this is getting too off-topic)

Altay

Quote from: Athanatos on Jan 08, 2021, 06:02 PM
Quote from: |ADMIN|Yankee on Jan 08, 2021, 11:54 AMWe are getting closer step by step. Time to see revolution my partner. This event will help new coders.
lmao what? By the way - where you got your profile pic? (lmao this is getting too off-topic)
This is a private question :D Send me a message.
Mustafa Kemal ATATURK, the man who changed the course of history. https://en.wikipedia.org/wiki/Mustafa_Kemal_Atat%C3%BCrk

Inferno

Viva la VU
VFS Developer
VCCNR Administrator