- Documentation
- Server functions
- createWeapon
Function
createWeapon
Creates a scripted weapon that stands in the world and belongs to no ped. You control it with setWeaponTarget, fireWeapon and setWeaponState.
Syntax
weapon createWeapon(string/int theType, float x, float y, float z [, bool allowInvisible = false])Arguments
theTypestring/int- Weapon name (
"m4") or ID. xfloat- X position.
yfloat- Y position.
zfloat- Z position.
allowInvisiblebool, optional = false- For compatibility with existing scripts.Not in MTA:SA
Differences from MTA:SA
- Arguments in a different colour differ from MTA:SA.
In MTA:SA
createWeapon(string theType, float x, float y, float z)Returns
The new weapon or false.
Example
local turret = createWeapon("m4", 2495.0, -1670.0, 15.0)
setWeaponClipAmmo(turret, 50)
setWeaponAmmo(turret, 500)