GetSlotFromWeapon: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
This allows you to identify the weapon slot that a weapon belongs to. | |||
This allows you to identify the weapon slot that a weapon belongs to | |||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
int getSlotFromWeapon ( int weaponid ) | int getSlotFromWeapon ( int weaponid ) | ||
Line 10: | Line 8: | ||
===Required Arguments=== | ===Required Arguments=== | ||
*'''weaponid:''' Specify the weapon of which weapon slot you want to know. | |||
*'''weaponid:''' Specify the weapon | |||
===Returns=== | ===Returns=== | ||
*Returns the player's current weapon slot ID. | |||
*Returns the player's current weapon slot ID | *Returns false if it fails to retrieve current weapon slot or if the weaponid is invalid. | ||
*Returns false if it fails to retrieve current weapon slot | |||
==Example== | ==Example== | ||
This will output to the chatbox what weapon slot a given weapon number belongs to when entered into the console (ie. 'getWeaponSlot 10'). | |||
This will output to the chatbox what weapon slot a | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function outputWeaponSlot ( source, commandName, weaponID ) | |||
local weaponSlot = getSlotFromWeapon ( weaponID ) | |||
if (weaponSlot) then | |||
outputChatBox ( " | outputChatBox ( "Weapon ID " .. weaponID .. " is in weapon slot " .. weaponSlot) | ||
else | |||
outputChatBox ( "Invalid weapon ID" ) | |||
end | |||
end | end | ||
</syntaxhighlight> | addCommandHandler ( "getWeaponSlot", outputWeaponSlot )</syntaxhighlight> | ||
==See Also== | ==See Also== | ||
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --> | <!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --> | ||
[[Weapons|Weapon IDs]] | |||
{{Weapon_functions}} | {{Weapon_functions}} |
Revision as of 06:28, 4 August 2007
This allows you to identify the weapon slot that a weapon belongs to.
Syntax
int getSlotFromWeapon ( int weaponid )
Required Arguments
- weaponid: Specify the weapon of which weapon slot you want to know.
Returns
- Returns the player's current weapon slot ID.
- Returns false if it fails to retrieve current weapon slot or if the weaponid is invalid.
Example
This will output to the chatbox what weapon slot a given weapon number belongs to when entered into the console (ie. 'getWeaponSlot 10').
function outputWeaponSlot ( source, commandName, weaponID ) local weaponSlot = getSlotFromWeapon ( weaponID ) if (weaponSlot) then outputChatBox ( "Weapon ID " .. weaponID .. " is in weapon slot " .. weaponSlot) else outputChatBox ( "Invalid weapon ID" ) end end addCommandHandler ( "getWeaponSlot", outputWeaponSlot )
See Also
- getWeaponProperty
- getPickupWeapon
- getOriginalWeaponProperty
- getSlotFromWeapon
- getWeaponIDFromName
- getWeaponNameFromID
- setWeaponAmmo
- setWeaponProperty