Difference between revisions of "OnClientPlayerStealthKill"

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
 
{{Client event}}
 
{{Client event}}
This event is triggered when a player stealth kills another player.
+
This event is triggered when the local player stealth kills another player.
  
 
==Parameters==
 
==Parameters==
Line 11: Line 11:
  
 
==Source==
 
==Source==
The [[event system#Event source|source]] of this event is the [[player]] that initiated the stealth kill.
+
The [[event system#Event source|source]] of this event is the [[player]] that initiated the stealth kill. (Local player only)
  
 
==Cancel effect==
 
==Cancel effect==
Line 17: Line 17:
  
 
==Example==  
 
==Example==  
This example disables stealh kills.
+
This example disables stealth kills.
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
addEventHandler("onClientPlayerStealthKill",getLocalPlayer(),
+
function abortAllStealthKills(targetPlayer)
function (targetPlayer)
+
    cancelEvent()
cancelEvent()
+
end
end)
+
addEventHandler("onClientPlayerStealthKill", getLocalPlayer(), abortAllStealthKills)
 +
</syntaxhighlight>
 +
This example disables stealth kills on a specific Ped.
 +
<syntaxhighlight lang="lua">
 +
local myNPC = createPed (187, 1481.265, -1752.25, 15.446, 0)
 +
 
 +
function antiKnife (target)
 +
    if target == myNPC then
 +
        cancelEvent()
 +
    end
 +
end
 +
addEventHandler("onClientPlayerStealthKill", getLocalPlayer(), antiKnife)
 
</syntaxhighlight>
 
</syntaxhighlight>
  

Latest revision as of 17:08, 5 February 2018

This event is triggered when the local 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. (Local player only)

Cancel effect

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

Example

This example disables stealth kills.

function abortAllStealthKills(targetPlayer)
    cancelEvent()
end
addEventHandler("onClientPlayerStealthKill", getLocalPlayer(), abortAllStealthKills)

This example disables stealth kills on a specific Ped.

local myNPC = createPed (187, 1481.265, -1752.25, 15.446, 0)

function antiKnife (target)
    if target == myNPC then
        cancelEvent()
    end
end
addEventHandler("onClientPlayerStealthKill", getLocalPlayer(), antiKnife)

See Also

Client player events


Client event functions