givePedWeapon | Multi Theft Auto: Wiki Skip to content

givePedWeapon

Client-side
Server-side
Shared

This page is incomplete! Help wanted!

Please finish this page using the corresponding Old Wiki article.
Go to Contribution guidelines for more information.


This function gives the specified weapon to the specified ped. This function can't be used on players, use giveWeapon for that.

Note

When setting ammo for weapons in slot 0,1,10,11 or 12 the maximum ammo is 1 When setting ammo for weapons in slot 3,4,5 the ammo is added When setting ammo for weapons in slot 2,6,7,8,9 and the slot weapon is changing, the ammo is replaced

Syntax

givePedWeapon ( )

Code Examples

client

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