getWeaponIDFromName
Client-side
Server-side
Shared
This page is incomplete! Help wanted!
Please finish this page using the corresponding Old Wiki article.
Go to Contribution guidelines for more information.
This function will obtain the ID of a particular weapon from its name.
Syntax
getWeaponIDFromName ( )Code Examples
server
This example will give the player the weapon they specify 20 ammo whenever they type "weaponname" into the console.
-- Define our function that will handle this commandfunction consoleGiveWeapon ( playerSource, commandName, weapName ) -- If a player triggered it (rather than the admin) then if ( playerSource ) then -- Get the weapon ID from the name local weapID = getWeaponIDFromName ( weapName ) -- If it's a valid weapon if ( weapID ) then -- Give the weapon to the player giveWeapon ( playerSource, weapID, 20 ) -- Output it in the chat box outputChatBox ( "You got a " .. weapName, playerSource ) else outputChatBox ( "Invalid weapon name." ) end endend-- Register the command handler and attach it to the 'consoleGiveWeapon' functionaddCommandHandler ( "weapon", consoleGiveWeapon )