SetWeaponProperty: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
m (New example)
Line 38: Line 38:
     outputChatBox("M4 range at poor skill is set now 75!")
     outputChatBox("M4 range at poor skill is set now 75!")
end
end
</syntaxhighlight>
This example makes the silenced pistol dual wielded at pro skill level
<syntaxhighlight lang="lua">
setWeaponProperty(23, "pro", "flags", 0x000800)
setWeaponProperty(23, "pro", "flags", 0x000002)
setWeaponProperty(23, "pro", "maximum_clip_ammo", 34)
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{Weapon functions}}
{{Weapon functions}}

Revision as of 18:42, 26 November 2011

Only available in MTA:SA v1.2 and onwards. This function sets the weapon property of the specified weapons specified weapon type.

Syntax

bool setWeaponProperty ( int weaponID/string weaponName, string weaponType, string property/int property, int/float theValue )

Required Arguments

  • weaponID: The ID of the weapon you want to get info of see Weapons
  • weaponType: Either: "pro", "std" or "poor"
  • property: The property you want to get the value of:
    • "weapon_range" - float
    • "target_range" - float
    • "accuracy" - float
    • "damage" - int
    • "maximum_clip_ammo" - int
    • "move_speed" - float
    • "flags" - int (specify a flag to toggle it on/off) See Weapon Flags
  • theValue: The value to set the property too.

Returns

On success:

bool: Returns true if the weapon property was successfully set

On failure:

bool: Returns false if the weapon property was unable to be set

Example

This example sets the weapon range of the M4 at poor skill level to 75

local rangeSet = setWeaponProperty(31, "poor", "weapon_range", 75)
if (rangeSet) then
    outputChatBox("M4 range at poor skill is set now 75!")
end

This example makes the silenced pistol dual wielded at pro skill level

setWeaponProperty(23, "pro", "flags", 0x000800)
setWeaponProperty(23, "pro", "flags", 0x000002)
setWeaponProperty(23, "pro", "maximum_clip_ammo", 34)

See Also