KillPlayer: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 9: Line 9:


===Returns===
===Returns===
Returns true if the function succeeded, and false otherwise.
Returns ''true'' if the player was killed, ''false'' if the player specified could not be killed or is invalid.


==Example==
==Example==
<syntaxhighlight lang="lua">player = GetPlayerFromID ( 1 )
<syntaxhighlight lang="lua">
if ( KillPlayer ( player ) )
-- Get the player with an ID of 1
outputChatBox ( ( GetPlayerName ( player ), " was eliminated." ), source )
player = getPlayerFromID ( 1 )
end</syntaxhighlight>
-- If a player was found with an ID of 1 then
if ( player )
-- Kill the player
if ( killPlayer ( player ) ) then
-- Inform everyone that they were killed.
outputChatBox ( ( getPlayerName ( player ), " was eliminated." ) )
end
end
</syntaxhighlight>

Revision as of 17:27, 18 May 2006

This function kills the specified player. It returns a boolean value (true or false) depending on whether the function passed or failed.

Syntax

bool KillPlayer ( player thePlayer )

Required Arguments

  • player: A player object referencing the specified player.

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 )
	-- Kill the player
	if ( killPlayer ( player ) ) then
		-- Inform everyone that they were killed.
		outputChatBox ( ( getPlayerName ( player ), " was eliminated." ) )
	end
end