From Multi Theft Auto: Wiki
Jump to navigation Jump to search

This function retrieves the weapon ID of a weapon pickup.


int getPickupWeapon ( pickup thePickup )

Required Arguments

  • thePickup: The pickup of which you wish to retrieve the weapon


Returns the Weapon ID of the pickup, or false if the pickup is invalid.


This example gives extra ammo to a player if a pickup only has a small amount of ammo.

Click to collapse [-]
function onPickupHitFunc ( thePlayer )                  -- when a pickup is hit
    if getPickupType ( source ) == 2 then               -- check if it's a weapon pickup
        local ammo = getPickupAmmo ( source )           -- get the pickup ammo
        if ammo < 50 then                               -- if ammo is less than 50
            local weapon = getPickupWeapon ( source )   -- store pickup weapon
            giveWeaponAmmo ( thePlayer, weapon, 50 )    -- give an extra 50 ammo
addEventHandler ( "onPickupHit", root, onPickupHitFunc )    -- add the function as handler for onPickupHit

See Also

GTASA IDs (vehicles, weapons, weathers, characters, colors): (Special thanks to Brophy and Ratt for making these lists)