onPlayerPickup

From GTA Network Wiki
Jump to: navigation, search

onPlayerPickup
Shared Function

utilities-terminal.png Server-Side system-users.png Client-Side
csharp.png C-Sharp javascript.png Javascript



dialog-warning.pngRework required!

The contents of this page are possibly invalid or incomplete. Please treat the contents of this page with caution!

If you are able to, please modify the page so that it's factually correct.


This type of event is used for handling code when the character picks up a pickup entity (pika-pika! i hear you pokemon go fans!)


Requirements

First of all, it should be defined in your Main constructor for it to be called, otherwise it wouldn't be initiated at all!

   public Main()
   {
      API.onPlayerPickup += OnPlayerPickupHandler;
   }

Usage example(s)

Before we start, myAwesomePickup variable is of NetHandle type defined somewhere in the script, if missing, it will output an error

   private void OnPlayerPickupHandler(Client player, NetHandle pickup)
   {
      if(pickup == myAwesomePickup)
      {
         API.sendChatMessageToPlayer(player, "Wooooo! Free HEALTH!!");
         API.setPlayerHealth(player, 100);
      }
   }

Changelog

Version Description
1.0 Release.

References