GetSlotFromWeapon: Difference between revisions
Jump to navigation
Jump to search
Paul Cortez (talk | contribs) m (Why is this marked server-only if it also works client-side? D:) |
m (→Syntax) |
||
(3 intermediate revisions by one other user not shown) | |||
Line 9: | Line 9: | ||
===Required Arguments=== | ===Required Arguments=== | ||
*'''weaponid:''' | *'''weaponid:''' [[Weapon]] to find the weapon slot of. | ||
===Returns=== | ===Returns=== |
Latest revision as of 16:33, 10 January 2010
This function allows you to identify the weapon slot that a weapon belongs to.
Syntax
int getSlotFromWeapon ( int weaponid )
Required Arguments
- weaponid: Weapon to find the weapon slot of.
Returns
Returns an integer representing the given weapon ID's associated weapon slot, false if the ID was invalid.
Example
This will output to the chatbox what weapon slot a given weapon number belongs to when entered into the console (i.e. '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 )