GetWeaponFlags: Difference between revisions
Jump to navigation
Jump to search
Fernando187 (talk | contribs) (Remove obsolete Requirements section) |
|||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Client function}} | {{Client function}} | ||
This function gets the flags of a [[Element/Weapon|custom weapon]]. | |||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua">bool getWeaponFlags ( weapon theWeapon, string theFlag )</syntaxhighlight> | ||
{{OOP||[[Element/Weapon|weapon]]:getFlags||setWeaponFlags}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
* '''theWeapon:''' | * '''theWeapon:''' the weapon to get the flag of. | ||
* '''theFlag:''' | * '''theFlag:''' the weapon flag to get: | ||
** | ** '''disable_model''': makes the weapon and muzzle effect invisible or not. | ||
** flags | ** '''flags''': returns the flags used to get where the gun shoots at. These flags are (by order): | ||
** | *** '''checkBuildings''': allows the shoot to be blocked by GTA's internally placed buildings, i.e. the world map. | ||
** | *** '''checkCarTires''': allows the shoot to be blocked by [[vehicle]] tires. | ||
** | *** '''checkDummies''': allows the shoot to be blocked by GTA's internal dummies. These are not used in the current MTA version so this argument can be set to ''false''. | ||
** | *** '''checkObjects''': allows the shoot to be blocked by [[object|objects]]. | ||
** | *** '''checkPeds''': allows the shoot to be blocked by [[ped|peds]] and [[player|players]]. | ||
** | *** '''checkVehicles''': allows the shoot to be blocked by [[vehicle|vehicles]]. | ||
** | *** '''checkSeeThroughStuff''': allows the shoot to be blocked by translucent game objects, e.g. glass. | ||
** | *** '''checkShootThroughStuff''': allows the shoot to be blocked by things that can be shot through. | ||
** | ** '''instant_reload''': if enabled, the weapon reloads instantly rather than waiting the reload time until shooting again. | ||
** | ** '''shoot_if_out_of_range''': if enabled, the weapon still fires its target beyond the weapon range distance. | ||
** | ** '''shoot_if_blocked''': if enabled, the weapon still fires its target even if it's blocked by something. | ||
===Returns=== | ===Returns=== | ||
Returns the '' | Returns the ''true'' or ''false'' on success (''flags'' flag returns 8 values) if the flag is enabled or not. Returns ''false'' if the weapon element isn't valid or an error occured. | ||
==Example== | ==Example== | ||
<syntaxhighlight lang="lua">-- | This example checks whether the instant_reload flag is enabled or disabled. | ||
<syntaxhighlight lang="lua"> | |||
local weapon = createWeapon("silenced", 0, 0, 10) -- Create the weapon | |||
if weapon then -- if the weapon exist then | |||
setWeaponFlags(weapon, "instant_reload", true) -- enable instant_reload | |||
local flag = (getWeaponFlags (weapon,"instant_reload") and "instant_reload enabled") or "instant_reload disabled" | |||
outputChatBox (flag) | |||
end | |||
</syntaxhighlight> | |||
==See also== | |||
==See | |||
{{Client weapon creation functions}} | {{Client weapon creation functions}} |
Latest revision as of 17:06, 7 November 2024
This function gets the flags of a custom weapon.
Syntax
bool getWeaponFlags ( weapon theWeapon, string theFlag )
OOP Syntax Help! I don't understand this!
- Method: weapon:getFlags(...)
- Counterpart: setWeaponFlags
Required Arguments
- theWeapon: the weapon to get the flag of.
- theFlag: the weapon flag to get:
- disable_model: makes the weapon and muzzle effect invisible or not.
- flags: returns the flags used to get where the gun shoots at. These flags are (by order):
- checkBuildings: allows the shoot to be blocked by GTA's internally placed buildings, i.e. the world map.
- checkCarTires: allows the shoot to be blocked by vehicle tires.
- checkDummies: allows the shoot to be blocked by GTA's internal dummies. These are not used in the current MTA version so this argument can be set to false.
- checkObjects: allows the shoot to be blocked by objects.
- checkPeds: allows the shoot to be blocked by peds and players.
- checkVehicles: allows the shoot to be blocked by vehicles.
- checkSeeThroughStuff: allows the shoot to be blocked by translucent game objects, e.g. glass.
- checkShootThroughStuff: allows the shoot to be blocked by things that can be shot through.
- instant_reload: if enabled, the weapon reloads instantly rather than waiting the reload time until shooting again.
- shoot_if_out_of_range: if enabled, the weapon still fires its target beyond the weapon range distance.
- shoot_if_blocked: if enabled, the weapon still fires its target even if it's blocked by something.
Returns
Returns the true or false on success (flags flag returns 8 values) if the flag is enabled or not. Returns false if the weapon element isn't valid or an error occured.
Example
This example checks whether the instant_reload flag is enabled or disabled.
local weapon = createWeapon("silenced", 0, 0, 10) -- Create the weapon if weapon then -- if the weapon exist then setWeaponFlags(weapon, "instant_reload", true) -- enable instant_reload local flag = (getWeaponFlags (weapon,"instant_reload") and "instant_reload enabled") or "instant_reload disabled" outputChatBox (flag) end
See also
- createWeapon
- fireWeapon
- getWeaponAmmo
- getWeaponClipAmmo
- getWeaponFiringRate
- getWeaponFlags
- getWeaponOwner
- getWeaponProperty
- getWeaponState
- getWeaponTarget
- resetWeaponFiringRate
- setWeaponAmmo
- setWeaponClipAmmo
- setWeaponFiringRate
- setWeaponFlags
- setWeaponProperty
- setWeaponState
- setWeaponTarget