IsPlayerDead: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (Fixed example highlighting, improved example)
Line 17: Line 17:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--Check if player is alive or dead and let them know in the chat box
--Check if player is alive or dead and let them know in the chat box
function deathCheck ( player, commandName )
function deathCheck ( thePlayer, commandName )
    -- This if statement is true if the player is dead
     if ( isPlayerDead ( thePlayer ) ) then
     if ( isPlayerDead ( player ) ) then
         outputChatBox ( "You're dead... prepare to become a zombie.", thePlayer )
         outputChatBox ( "You're dead... prepare to become a zombie." )
     else
     else
         outputChatBox ( "Count your lucky stars, you're alive." )
         outputChatBox ( "Count your lucky stars, you're alive.", thePlayer )
     end
     end
end
end

Revision as of 11:59, 11 October 2007

This function checks if the specified player is dead or not.

Syntax

bool isPlayerDead ( player thePlayer )

Required Arguments

  • thePlayer: A player object referencing the specified player

Returns

Returns true if the player is dead, false otherwise.

Example

This example allows a player to use the command 'amidead' to see if they are dead or not.

Click to collapse [-]
Server
--Check if player is alive or dead and let them know in the chat box
function deathCheck ( thePlayer, commandName )
    if ( isPlayerDead ( thePlayer ) ) then
         outputChatBox ( "You're dead... prepare to become a zombie.", thePlayer )
    else
         outputChatBox ( "Count your lucky stars, you're alive.", thePlayer )
    end
end
addCommandHandler ( "amidead", deathCheck )

See Also