GivePedWeapon: Difference between revisions
(Created page with "__NOTOC__ {{Client function}} {{New feature/item|3.0141|1.4.1|6937| This function gives a specified weapon to the specified ped, this function cannot be used for players. The...") |
No edit summary |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 2: | Line 2: | ||
{{Client function}} | {{Client function}} | ||
{{New feature/item|3.0141|1.4.1|6937| | {{New feature/item|3.0141|1.4.1|6937| | ||
This function gives | This function gives the specified weapon to the specified ped. This function can't be used on players, use [[giveWeapon]] for that. | ||
This function is mainly useful for client side created peds however you can use it on a server side ped, though note that the weapon wouldn't be synced between clients unless your script gives the weapon to the ped on every client. | |||
There is an optional argument to specify ammunition and whether to set as the current weapon. If you don't specify an ammo value it will give 30 ammo by default and for a melee weapon you can specify just 1 or above. | |||
}} | }} | ||
{{Note| | {{Note| | ||
*When setting ammo for [[Weapon|weapons in slot]] 0,1,10,11 or 12 | *When setting ammo for [[Weapon|weapons in slot]] 0,1,10,11 or 12 the maximum ammo is 1 | ||
*When setting ammo for [[Weapon|weapons in slot]] 3,4,5 | *When setting ammo for [[Weapon|weapons in slot]] 3,4,5 the ammo is added | ||
*When setting ammo for [[Weapon|weapons in slot]] 2,6,7,8,9 and the slot weapon is changing, the ammo is replaced | *When setting ammo for [[Weapon|weapons in slot]] 2,6,7,8,9 and the slot weapon is changing, the ammo is replaced | ||
}} | }} | ||
Line 19: | Line 23: | ||
===Optional Arguments=== | ===Optional Arguments=== | ||
{{OptionalArg}} | {{OptionalArg}} | ||
*'''ammo:''' A whole number integer serving as the ammo amount for the given weapon. | *'''ammo:''' A whole number integer serving as the ammo amount for the given weapon. For weapons that do not require ammo, such as melee, this should be at least 1. | ||
*'''setAsCurrent:''' A boolean value determining whether or not the weapon will be set as the | *'''setAsCurrent:''' A boolean value determining whether or not the weapon will be set as the peds currently selected weapon. | ||
===Returns=== | ===Returns=== | ||
Line 31: | Line 35: | ||
local x, y, z = getElementPosition(localPlayer) -- Get your position | local x, y, z = getElementPosition(localPlayer) -- Get your position | ||
local thePed = createPed(0, x + 1, y, z) -- Create a CJ ped nearby | local thePed = createPed(0, x + 1, y, z) -- Create a CJ ped nearby | ||
givePedWeapon(thePed, 31, 5000, true) -- Give him 5000 rounds of M4 | |||
setControlState(thePed, "fire", true) -- Make him shoot continuously | setControlState(thePed, "fire", true) -- Make him shoot continuously | ||
end | end | ||
Line 38: | Line 42: | ||
==See Also== | ==See Also== | ||
{{Client | {{Client ped functions}} |
Latest revision as of 01:18, 28 December 2014
This function gives the specified weapon to the specified ped. This function can't be used on players, use giveWeapon for that.
This function is mainly useful for client side created peds however you can use it on a server side ped, though note that the weapon wouldn't be synced between clients unless your script gives the weapon to the ped on every client.
There is an optional argument to specify ammunition and whether to set as the current weapon. If you don't specify an ammo value it will give 30 ammo by default and for a melee weapon you can specify just 1 or above.
Syntax
bool givePedWeapon ( ped thePed, int weapon [, int ammo=30, bool setAsCurrent=false ] )
Required Arguments
- thePed: A ped element.
- weapon: A whole number integer that refers to a Weapon ID. Click here for a list of possible weapon IDs.
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.
- ammo: A whole number integer serving as the ammo amount for the given weapon. For weapons that do not require ammo, such as melee, this should be at least 1.
- setAsCurrent: A boolean value determining whether or not the weapon will be set as the peds currently selected weapon.
Returns
Returns true if weapon was successfully given to the ped, false otherwise.
Example
Example 1: This example creates a client side ped, gives them an M4 and make them shoot once you do the command '/armedped'
function cmdArmedPed( command ) local x, y, z = getElementPosition(localPlayer) -- Get your position local thePed = createPed(0, x + 1, y, z) -- Create a CJ ped nearby givePedWeapon(thePed, 31, 5000, true) -- Give him 5000 rounds of M4 setControlState(thePed, "fire", true) -- Make him shoot continuously end addCommandHandler("armedped", cmdArmedPed)
See Also
- canPedBeKnockedOffBike
- getPedAnalogControlState
- getPedAnimation
- getPedBonePosition
- getPedCameraRotation
- getPedControlState
- getPedMoveState
- getPedOxygenLevel
- getPedSimplestTask
- getPedTargetCollision
- getPedTargetEnd
- getPedTargetStart
- getPedTask
- getPedVoice
- getPedWeaponMuzzlePosition
- givePedWeapon
- isPedBleeding
- isPedDoingTask
- isPedReloadingWeapon
- isPedTargetingMarkerEnabled
- setAnalogControlState
- setPedAimTarget
- setPedAnalogControlState
- setPedBleeding
- setPedCameraRotation
- setPedCanBeKnockedOffBike
- setPedControlState
- setPedEnterVehicle
- setPedExitVehicle
- IsPedFootBloodEnabled
- setPedFootBloodEnabled
- setPedLookAt
- setPedOxygenLevel
- setPedTargetingMarkerEnabled
- setPedVoice
- Shared
- addPedClothes
- getPedClothes
- removePedClothes
- createPed
- getPedAmmoInClip
- getPedArmor
- getPedFightingStyle
- getPedOccupiedVehicle
- getPedOccupiedVehicleSeat
- getPedStat
- getPedTarget
- getPedTotalAmmo
- getPedWalkingStyle
- getPedWeapon
- getPedWeaponSlot
- getPedContactElement
- getValidPedModels
- isPedChoking
- isPedDead
- isPedDoingGangDriveby
- isPedDucked
- isPedHeadless
- isPedInVehicle
- isPedOnFire
- isPedOnGround
- isPedWearingJetpack
- killPed
- removePedFromVehicle
- setPedAnimation
- setPedAnimationProgress
- setPedAnimationSpeed
- setPedArmor
- setPedDoingGangDriveby
- setPedFightingStyle
- setPedHeadless
- setPedOnFire
- setPedStat
- setPedWalkingStyle
- setPedWeaponSlot
- warpPedIntoVehicle