CreatePickup

From SA-MP Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 21:50, 7 December 2016
OstGot (Talk | contribs)

← Previous diff
Current revision
IstuntmanI (Talk | contribs)

Line 33: Line 33:
// Later.. // Later..
DestroyPickup(pickup); // Example of using the pickup ID DestroyPickup(pickup); // Example of using the pickup ID
 +pickup = 0; // pickup variable needs to be reset to avoid future conflicts
</pawn> </pawn>

Current revision



Description:

This function does exactly the same as AddStaticPickup, except it returns a pickup ID which can be used to destroy it afterwards and be tracked using OnPlayerPickUpPickup.


Parameters:
(model, type, Float:X, Float:Y, Float:Z, virtualworld)
modelThe model of the pickup.
Float:XThe X coordinate to create the pickup at.
Float:YThe Y coordinate to create the pickup at.
Float:ZThe Z coordinate to create the pickup at.
virtualworldThe virtual world ID of the pickup. Use -1 to make the pickup show in all worlds.


Return Values:

The ID of the created pickup, -1 on failure (pickup max limit).


Image:32px-Ambox_warning_orange.png

Notes

  • The only type of pickup that can be picked up from inside a vehicle is 14 (except for special pickups such as bribes).
  • Pickups are shown to, and can be picked up by all players.
  • It is possible that if DestroyPickup() is used when a pickup is picked up, more than one player can pick up the pickup, due to lag. This can be circumvented through the use of variables.
  • Certain pickup types come with 'automatic responses', for example using an M4 model in the pickup will automatically give the player the weapon and some ammo. For fully scripted pickups, type 1 should be used.


Example Usage:

new pickup; // Create a variable to store the pickup ID in
 
public OnGameModeInit()
{
    pickup = CreatePickup(1242, 2, 1503.3359, 1432.3585, 10.1191, -1);
    // Create an armour pickup and store the ID in 'pickup'
    return 1;
}
 
// Later..
DestroyPickup(pickup); // Example of using the pickup ID
pickup = 0; // pickup variable needs to be reset to avoid future conflicts

Related Functions

The following functions may be useful, as they are related to this function in one way or another.


Related Callbacks

The following callbacks might be useful, as they're related to this function in one way or another.

Personal tools
In other languages