GetWeaponIDFromName: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
mNo edit summary
 
(12 intermediate revisions by 5 users not shown)
Line 1: Line 1:
[[Category:Incomplete]]
__NOTOC__  
__NOTOC__  
This fake function is for use with blah & blah and does blahblahblabhalbhl
{{Server client function}}
This function will obtain the ID of a particular weapon from its name.


==Syntax==  
==Syntax==  
Line 10: Line 9:


===Required Arguments===  
===Required Arguments===  
*'''argumentName:''' description
*'''name:''' A [[string]] containing the name of the weapon. Names can be: (Case is ignored)
 
{{All Weapon Types}}
===Optional Arguments===
{{OptionalArg}}  
*'''argumentName2:''' descriptiona
*'''argumentName3:''' description


===Returns===
===Returns===
Returns ''true'' if blah, ''false'' otherwise.
Returns an [[int]] if the name matches that of a weapon, ''false'' otherwise.


==Example==  
==Example==  
This example does...
<section name="Server" class="server" show="true">
This example will give the player the weapon they specify 20 ammo whenever they type "weapon ''name''" into the console.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--This line does...
-- Define our function that will handle this command
blabhalbalhb --abababa
function consoleGiveWeapon ( playerSource, commandName, weapName )
--This line does this...
-- If a player triggered it (rather than the admin) then
mooo
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
end
end
-- Register the command handler and attach it to the 'consoleGiveWeapon' function
addCommandHandler ( "weapon", consoleGiveWeapon )
</syntaxhighlight>
</syntaxhighlight>
</section>


==See Also==
==See Also==
{{FunctionArea_Functions}}
{{Weapon functions}}
[[ru:getWeaponIDFromName]]

Latest revision as of 18:11, 26 May 2017

This function will obtain the ID of a particular weapon from its name.

Syntax

int getWeaponIDFromName ( string name )             

Required Arguments

  • name: A string containing the name of the weapon. Names can be: (Case is ignored)
  • brassknuckle
  • golfclub
  • nightstick
  • knife
  • bat
  • shovel
  • poolstick
  • katana
  • chainsaw
  • dildo
  • vibrator
  • flower
  • cane
  • grenade
  • teargas
  • molotov
  • colt 45
  • silenced
  • deagle
  • shotgun
  • sawed-off
  • combat shotgun
  • uzi
  • mp5
  • ak-47
  • m4
  • tec-9
  • rifle
  • sniper
  • rocket launcher
  • rocket launcher hs
  • flamethrower
  • minigun
  • satchel
  • bomb
  • spraycan
  • fire extinguisher
  • camera
  • nightvision
  • infrared
  • parachute

Returns

Returns an int if the name matches that of a weapon, false otherwise.

Example

Click to collapse [-]
Server

This example will give the player the weapon they specify 20 ammo whenever they type "weapon name" into the console.

-- Define our function that will handle this command
function 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
	end
end
-- Register the command handler and attach it to the 'consoleGiveWeapon' function
addCommandHandler ( "weapon", consoleGiveWeapon )

See Also