GetWeaponNameFromID: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
[[Category:Incomplete]]
__NOTOC__  
__NOTOC__  
This fake function is for use with blah & blah and does blahblahblabhalbhl
This function allows you to retrieve the name of a weapon from an ID.  Note it also allows you to retrieve the name of other methods of death, such as ''Fall'' and ''Rammed''.


==Syntax==  
==Syntax==  
Line 10: Line 8:


===Required Arguments===  
===Required Arguments===  
*'''argumentName:''' description
*'''id:''' The ID you wish to retrieve the name of
 
===Optional Arguments===
{{OptionalArg}}
*'''argumentName2:''' descriptiona
*'''argumentName3:''' description


===Returns===
===Returns===
Returns ''true'' if blah, ''false'' otherwise.
Returns a string of the name of the weapon.


==Example==  
==Example==  
This example does...
This example displays a death message in the format of "* ''Killer'' killed ''dead'' (''Weapon'')"
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--This line does...
addEventHandler ( "onPlayerWasted", root, "onPlayerWasted" ) --add an event handler for onPlayerWasted
blabhalbalhb --abababa
function onPlayerWasted ( totalammo, killer, killerweapon, bodypart ) --when a player dies
--This line does this...
k3 = getWeaponNameFromID ( killerweapon ) --get the name of the weapon of the 'killerweapon' and define it as 'k3'
mooo
k2 = getClientName ( source ) --get the name of the player who died and define it as 'k2'
if ( killer ) then --if there was a killer
k1 = getClientName ( killer ) --get the name of the killer and define it as 'k1'
if killer == source then --if the killer is the same as the person who died i.e. he killed himself
outputChatBox ( "* "..k1.." died ("..k3..")", root, 255, 100, 100 ) --output in the chatbox that  he died and the method he died in the brackets
else --if the killer is not the same as the person who died
outputChatBox ( "* "..k1.." killed "..k2.." ("..k3..")", root, 255, 100, 100 ) --output in the chatbox that he was killed by the killer and the method in brackets
end
else --if there was no killer
outputChatBox ( "* "..k2 .. " died (" ..k3..")", root, 255, 100, 100 ) --output in the chatbox that the dead person died and how he died
end
end
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{FunctionArea_Functions}}
{{Weapon functions}}

Revision as of 14:21, 14 August 2006

This function allows you to retrieve the name of a weapon from an ID. Note it also allows you to retrieve the name of other methods of death, such as Fall and Rammed.

Syntax

string getWeaponNameFromID ( int id )            

Required Arguments

  • id: The ID you wish to retrieve the name of

Returns

Returns a string of the name of the weapon.

Example

This example displays a death message in the format of "* Killer killed dead (Weapon)"

addEventHandler ( "onPlayerWasted", root, "onPlayerWasted" ) --add an event handler for onPlayerWasted
function onPlayerWasted ( totalammo, killer, killerweapon, bodypart ) --when a player dies
	k3 = getWeaponNameFromID ( killerweapon ) --get the name of the weapon of the 'killerweapon' and define it as 'k3'
	k2 = getClientName ( source ) --get the name of the player who died and define it as 'k2'
	if ( killer ) then --if there was a killer
	k1 = getClientName ( killer ) --get the name of the killer and define it as 'k1'
		if killer == source then --if the killer is the same as the person who died i.e. he killed himself
			outputChatBox ( "* "..k1.." died ("..k3..")", root, 255, 100, 100 ) --output in the chatbox that  he died and the method he died in the brackets
		else --if the killer is not the same as the person who died
			outputChatBox ( "* "..k1.." killed "..k2.." ("..k3..")", root, 255, 100, 100 ) --output in the chatbox that he was killed by the killer and the method in brackets
		end
	else --if there was no killer
		outputChatBox ( "* "..k2 .. " died (" ..k3..")", root, 255, 100, 100 ) --output in the chatbox that the dead person died and how he died
	end
end

See Also