Jump to content

question about onClientPlayerStealthKill


Chaos

Recommended Posts

hey,

i have a question why this won't abort knife kill when some one trying to kill me ?

function onKill() 
  
  timer1 = setTimer(function() 
  
    addEventHandler("onClientPlayerStealthKill",localPlayer,abortAllStealthKills) 
  
end,20000,1) 
end 
  
     
addCommandHandler( "peace", onKill)  
  
  
  
  
function abortAllStealthKills(targetPlayer) 
    cancelEvent() 
end 
  
  

Link to comment

Must be because 'source' in onClientPlayerStealthKill is the player that initiated the stealth kill, not the victim.

Change 'localPlayer' in addEventHandler to 'root', and then inside "abortAllStealthKills" function, before cancelEvent ( ), put:

if ( targetPlayer == localPlayer ) then 
end 

Link to comment

i tried this but it seems not working

    function onKill() 
      
      timer1 = setTimer(function() 
      
        addEventHandler("onClientPlayerStealthKill",root,abortAllStealthKills) 
      
    end,3000,1) 
    end 
      
        
    addCommandHandler( "peace", onKill)  
      
      
      
      
    function abortAllStealthKills(targetPlayer) 
        if ( targetPlayer == localPlayer ) then 
        outputChatBox("should now no one can kill you with a knife") 
        cancelEvent() 
    end 
         
    end 
      
      

Link to comment

i think you mean something like this

    function onKill() 
      
        timer1 = setTimer(function() 
        setElementData(localPlayer,"peace",true) 
        outputChatBox("peace is on !") 
end,3000,1) 
 end     
        
    addCommandHandler( "peace", onKill)  
      
      
      
    function abortAllStealthKills(targetPlayer) 
     if getElementData(targetPlayer,"peace") == true then 
        cancelEvent() 
    end 
    end 
         
  
addEventHandler("onClientPlayerStealthKill", root, abortAllStealthKills) 

Link to comment
  • 3 years later...
On 8/16/2014 at 17:23, Chaos said:

i think you mean something like this


    function onKill() 
      
        timer1 = setTimer(function() 
        setElementData(localPlayer,"peace",true) 
        outputChatBox("peace is on !") 
end,3000,1) 
 end     
        
    addCommandHandler( "peace", onKill)  
      
      
      
    function abortAllStealthKills(targetPlayer) 
     if getElementData(targetPlayer,"peace") == true then 
        cancelEvent() 
    end 
    end 
         
  
addEventHandler("onClientPlayerStealthKill", root, abortAllStealthKills) 
 

 

how can i add this in freeroam panel?pls its only for on mode how can i make for off mode?

for example if i type peace no one can kill me by knife same when i type peace now i can get killed my knife

i want this for only a particular player not for all

if i typed peace and only i must be in safe not whole server players 

below is my code i just want to make it for players who enable disable knife mode

addCommandHandler("kinfe", 
function() 
    if not kinfeKill then 
        outputChatBox("#00ff0Server: disableknife mode On!", 0, 255, 0, true) 
    else 
        outputChatBox("#00ff00Server: disableknife mode Off!", 255, 0, 0, true) 
    end 
    kinfeKill = not kinfeKill 
end) 
  
function stopKnifeKill() 
    if kinfeKill then 
        cancelEvent() 
    end 
end 
addEventHandler("onClientPlayerStealthKill", localPlayer, stopKnifeKill) 

 

addCommandHandler("disableknife", 
function() 
    if not kinfeKill then 
        outputChatBox("#00ff0Server: disableKnife mode On!", 0, 255, 0, true) 
    else 
        outputChatBox("#00ff00Server: disableKnife mode Off!", 255, 0, 0, true) 
    end 
    kinfeKill = not kinfeKill 
end) 
  
function stopKnifeKill() 
    if kinfeKill then 
        cancelEvent() 
    end 
end 
addEventHandler("onClientPlayerStealthKill", localPlayer, stopKnifeKill) 

this is code

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...