KillPlayer: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
{{Server function}}
__NOTOC__
__NOTOC__
This function kills the specified player. It returns a boolean value (true or false) depending on whether the function passed or failed.
This function kills the specified player.


==Syntax==
==Syntax==
<syntaxhighlight lang="lua">bool killPlayer ( player thePlayer, [ player theKiller = NULL, int weapon = 255, int bodyPart = 255 ] )</syntaxhighlight>
<syntaxhighlight lang="lua">bool killPlayer ( player thePlayer, [ player theKiller = nil, int weapon=255, int bodyPart=255 ] )</syntaxhighlight>


===Required Arguments===
===Required Arguments===
* '''thePlayer''': A [[player]] object referencing the specified player.
* '''thePlayer:''' The [[player]] to kill


===Optional Arguments===
===Optional Arguments===
* '''theKiller''': The player who killed the player
* '''theKiller:''' The player responsible for the kill
* '''weapon''': The ID of the weapon that should appear to have killed the player (doesn't affect how they die)
* '''weapon:''' The ID of the weapon that should appear to have killed the player (doesn't affect how they die)
* '''bodyPart''': The ID of the body part that should appear to have been hit by the weapon (doesn't affect how they die)
* '''bodyPart:''' The ID of the body part that should appear to have been hit by the weapon (doesn't affect how they die)


===Returns===
===Returns===
Line 21: Line 22:
player = getPlayerFromID ( 1 )
player = getPlayerFromID ( 1 )
-- If a player was found with an ID of 1 then
-- If a player was found with an ID of 1 then
if ( player )
if ( player ) then
-- Kill the player
-- Kill the player
if ( killPlayer ( player ) ) then
if ( killPlayer ( player ) ) then

Revision as of 19:38, 16 August 2007

This function kills the specified player.

Syntax

bool killPlayer ( player thePlayer, [ player theKiller = nil, int weapon=255, int bodyPart=255 ] )

Required Arguments

Optional Arguments

  • theKiller: The player responsible for the kill
  • weapon: The ID of the weapon that should appear to have killed the player (doesn't affect how they die)
  • bodyPart: The ID of the body part that should appear to have been hit by the weapon (doesn't affect how they die)

Returns

Returns true if the player was killed, false if the player specified could not be killed or is invalid.

Example

-- Get the player with an ID of 1
player = getPlayerFromID ( 1 )
-- If a player was found with an ID of 1 then
if ( player ) then
	-- Kill the player
	if ( killPlayer ( player ) ) then
		-- Inform everyone that they were killed.
		outputChatBox ( ( getPlayerName ( player ), " was eliminated." ) )
	end
end

See Also