CreatePickup: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
Line 15: Line 15:
** '''1''': Armour Pickup
** '''1''': Armour Pickup
** '''2''': Weapon Pickup
** '''2''': Weapon Pickup
* '''amount/weapon''': This is an integer representing the amount of Health points or Armour points a pickup has.  If the type is a Weapon pickup, then it represents the Weapon ID of the weapon pickup the 'ammo' field must be entered if the type is Weapon Pickup.
* '''amount/weapon''': This is an integer representing the amount of Health points or Armour points a pickup has.  If the type is a Weapon pickup, then it represents the [[Weapon|weapon ID]] of the weapon pickup the 'ammo' field must be entered if the type is Weapon Pickup.


===Optional Arguments===  
===Optional Arguments===  

Revision as of 03:29, 9 December 2006

This function creates a pickup element, which is placed in the GTA world and can be picked up to retrieve a health, armour or a weapon.

Syntax

pickup createPickup ( float x, float y, float z, int type, int amount/weapon, [ int respawnTime = 30000, int ammo = 50 ] )         

Required Arguments

  • x: A floating point number representing the X coordinate on the map.
  • y: A floating point number representing the Y coordinate on the map.
  • z: A floating point number representing the Z coordinate on the map.
  • type: This is an integer representing the type of pickup, representing the following types:
    • 0: Health Pickup
    • 1: Armour Pickup
    • 2: Weapon Pickup
  • amount/weapon: This is an integer representing the amount of Health points or Armour points a pickup has. If the type is a Weapon pickup, then it represents the weapon ID of the weapon pickup the 'ammo' field must be entered if the type is Weapon Pickup.

Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.

  • respawnTime: How long before the pickup respawns in milliseconds
  • ammo: An integer representing the amount of ammo a pickup contains. This is only valid when the pickup type is a Weapon Pickup, and must be entered.

Example

This example creates a pickup after a player dies so that he drops his weapon.

addEventHandler ( "onPlayerWasted", root, "onPlayerWasted" ) --add an event handler for onPlayerWasted
function onPlayerWasted ( totalammo, killer, killerweapon, bodypart ) --when a player dies
    x, y, z = getElementPosition ( source ) --get the position of the person who died and define it as x, y and z
    currentweapon = getPlayerCurrentWeaponID ( source ) --get the current weapon of the dead person
    createPickup ( x, y, z, 2, currentweapon, 10000, totalammo )
end

See Also

GTASA IDs (vehicles, weapons, weathers, characters, colors): http://info.vces.net/ (Special thanks to Brophy and Ratt for making these lists)