Vice City: Multiplayer

Server Development => Scripting and Server Management => Snippet Showroom => Topic started by: Sonmez on Jan 07, 2021, 09:02 AM

Title: onPickupExited (New Custom Event)
Post by: Sonmez on Jan 07, 2021, 09:02 AM
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);
}
Title: Re: onPickupExited (New Custom Event)
Post by: SHy^ on Jan 07, 2021, 10:04 AM
Isn't onPickupClaimPicked(player, pickup) the function when a player exists the pickup?
Title: Re: onPickupExited (New Custom Event)
Post by: Sebastian on Jan 07, 2021, 01:36 PM
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
Title: Re: onPickupExited (New Custom Event)
Post by: KrOoB_ on Jan 07, 2021, 02:19 PM
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
Title: Re: onPickupExited (New Custom Event)
Post by: Altay on Jan 08, 2021, 11:54 AM
We are getting closer step by step. Time to see revolution my partner. This event will help new coders.
Title: Re: onPickupExited (New Custom Event)
Post by: NicusorN5 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)
Title: Re: onPickupExited (New Custom Event)
Post by: Altay on Jan 08, 2021, 09:27 PM
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.
Title: Re: onPickupExited (New Custom Event)
Post by: Inferno on Jan 09, 2021, 01:07 PM
Good work.