RU/GetSlotFromWeapon: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
m (Redirected page to RU/getSlotFromWeapon)
 
Line 1: Line 1:
{{Translate|ru}}
#REDIRECT [[RU/getSlotFromWeapon]]
{{RU/Server function}}
This function allows you to identify the weapon slot that a weapon belongs to.
 
==Syntax==
<syntaxhighlight lang="lua">
int getSlotFromWeapon ( int weaponid )
</syntaxhighlight>
 
===Required Arguments===
*'''weaponid:''' The weapon ID 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').
<syntaxhighlight lang="lua">
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 )</syntaxhighlight>
 
==See Also==
[[Weapons|Weapon IDs]]
{{RU/Weapon_functions}}

Latest revision as of 06:33, 30 September 2014