OnPlayerStealthKill: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
Line 21: Line 21:


<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
[lua]
function onStealthKill(targetPlayer)
function onStealthKill(targetPlayer)
     outputChatBox("Stealth kill!", source) -- Tell the player he/she has done a stealth kill.
     outputChatBox("Stealth kill!", source) -- Tell the player he/she has done a stealth kill.
Line 34: Line 33:


<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
[lua]
function onStealthKill(targetPlayer)
function onStealthKill(targetPlayer)
     cancelEvent(true, "No more stealth kills.") -- Aborts the stealth-kill.
     cancelEvent(true, "No more stealth kills.") -- Aborts the stealth-kill.

Revision as of 11:40, 12 April 2017

This event is triggered when a player stealth kills another player.

Parameters

element targetPlayer
  • targetPlayer: The player or ped that is being stealth killed.

Source

The source of this event is the player that initiated the stealth kill.

Cancel effect

If this event is canceled, then the stealth kill is aborted.

Example

Click to collapse [-]
Server
function onStealthKill(targetPlayer)
     outputChatBox("Stealth kill!", source) -- Tell the player he/she has done a stealth kill.
     outputChatBox("" .. getPlayerName(targetPlayer) .. " has been stealth-killed by " .. getPlayerName(source) .. ".")
end
addEventHandler("onPlayerStealthKill", getRootElement(), onStealthKill) -- Adds a handler for the stealth kill event.


Click to collapse [-]
Server
function onStealthKill(targetPlayer)
     cancelEvent(true, "No more stealth kills.") -- Aborts the stealth-kill.
end
addEventHandler("onPlayerStealthKill", getRootElement(), onStealthKill) -- Adds a handler for the stealth kill event.


See Also

Player events


Event functions