CreateWeaponObject
Docslocal retval = CreateWeaponObject(weaponHash, ammoCount, x, y, z, bCreateDefaultComponents, scale, customModelHash)Description
Create a weapon object that cannot be attached to a ped. If you want to create a weapon object that can be attached to a ped, use <code>CREATE_OBJECT</code> instead.
NativeDB Added Parameter 9: BOOL bRegisterAsNetworkObject
NativeDB Added Parameter 10: BOOL bScriptHostObject
Parameters
| Name | Type | Description |
|---|---|---|
weaponHash | Hash | The hash of the weapon to create. |
ammoCount | int | The amount of ammo for the weapon. |
x | float | X coordinate for the weapon's position. |
y | float | Y coordinate for the weapon's position. |
z | float | Z coordinate for the weapon's position. |
bCreateDefaultComponents | BOOL | Boolean that indicates whether the default components should be created for that weapon (`true`/`false`). |
scale | float | The size of the object, to increase it, set the scale to a value greater than `1.0`. |
customModelHash | int | The hash of the custom model to use for the weapon object. Set to `0` if you do not intend to use a custom model hash. |
Quick Snippet: Get Coordinatesxyz
xyzAdd this command to your client script to retrieve precise locations in-game.
-- Add this to your client.lua. Type /pos in-game to copy coords.
RegisterCommand('pos', function()
local ped = PlayerPedId()
local coords = GetEntityCoords(ped)
local heading = GetEntityHeading(ped)
local output = string.format("vector4(%.2f, %.2f, %.2f, %.2f)", coords.x, coords.y, coords.z, heading)
print(output)
TriggerEvent('chat:addMessage', { args = { '^4[COORD]^0', output } })
end)Returns
ObjectReturns an object handle.