Jump to content

onClientPlayerStealthKill


Xabache

Recommended Posts

I can get either or here but not both? This can cancel the event, or it can kill the killer, depending on the order of killPed and cancelEvent. But I cant get it to both cancel the death of the Ped and kill the killer. Can I?

addEventHandler ( "onClientPlayerStealthKill", root, 
    function ( target ) 
        killPed ( sourcePlayer, sourcePlayer ) 
        cancelEvent ( ) 
    end 
) 

Link to comment

You can't use 'killPed' because it's a server side function try to use triggerServerEvent()

addEventHandler("onClientPlayerStealthKill", getLocalPlayer(),  
function(target) 
if (target and getElementType(target) == "player" and target ~= source) then 
triggerServerEvent("KillAttacker",source) 
cancelEvent() 
end 
) 

Link to comment

Client:

addEventHandler ( "onClientPlayerStealthKill", root, 
    function ( target ) 
        triggerServerEvent("KillAttacker",source) 
        cancelEvent() 
    end 
) 

Server:

addEvent("KillAttacker",true) 
function killAttacker (killer) 
    killPed(killer) 
    outputChatBox ("KARMA:" .. killer .. " is dead",source,0,233,0,true) 
end 
addEventHandler("KillAttacker",resourceRoot,killAttacker) 

No error message. But only canceling the event. The killer is not killed. The KARMA message is not displayed. What's wrong?

Link to comment

Client:

  
addEventHandler("onClientPlayerStealthKill", getLocalPlayer(), 
function(target) 
if (target and getElementType(target) == "player" and target ~= source) then 
triggerServerEvent("KillAttacker",resourceRoot,source) 
cancelEvent() 
end 
) 
  

Server:

  
addEvent("KillAttacker",true) 
function killAttacker (killer) 
    killPed(killer) 
    outputChatBox ("KARMA:" .. killer .. " is dead",source,0,233,0,true) 
end 
addEventHandler("KillAttacker",resourceRoot,killAttacker) 
  

Link to comment

Thank you Tomas and Anubhav, but neither suggestion functions.

Anubhav's still cancels the event without killing the killer.

and Tomas' the victim dies in the event without it being canceled and the killer is not harmed.

I want the killer to be struck down as a result of their attempted Stealth Kill.

Link to comment

Try this :

Client

  
addEventHandler("onClientPlayerStealthKill", getLocalPlayer(), 
function(target) 
if (target and getElementType(target) == "player" and target ~= source) then 
triggerServerEvent("KillAttacker",source,source) 
cancelEvent() 
end 
) 

Server

  
function killAttacker (killer) 
    killPed(killer) 
    outputChatBox ("KARMA:" .. killer .. " is dead",source,0,233,0,true) 
end 
addEvent("KillAttacker",true) 
addEventHandler("KillAttacker",root,killAttacker) 

Link to comment
Try this :

Client

  
addEventHandler("onClientPlayerStealthKill", getLocalPlayer(), 
function(target) 
if (target and getElementType(target) == "player" and target ~= source) then 
triggerServerEvent("KillAttacker",source,source) 
cancelEvent() 
end 
) 

Server

  
function killAttacker (killer) 
    killPed(killer) 
    outputChatBox ("KARMA:" .. killer .. " is dead",source,0,233,0,true) 
end 
addEvent("KillAttacker",true) 
addEventHandler("KillAttacker",root,killAttacker) 

Fully same what I told.

Link to comment
  • Moderators

When using root in an addEventHandler, it can accept every source element. When you use resourceRoot, it will only accept resourceRoot.

This will become the source element from the addEventHandler:

triggerServerEvent("KillAttacker",[color=#FF0000]source[/color],source) 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...