Jump to content

[HELP] Spawn protection


lolman

Recommended Posts

Hi,

I've a problem with my code... I want to set a timer on the onClientPlayerDamage part but it doesnt work very well... If someone could help me with setting a timer. I want that you will have 10 seconds protection and then you are damagable.

function protect() 
    if getElementAlpha(localPlayer) == 255 then 
    setElementAlpha(localPlayer, 180) 
    setElementData(localPlayer, "inv", true) 
end 
end 
addEventHandler("onClientPlayerSpawn", getRootElement(), protect) 
  
  
  
function() 
    if getElementData(localPlayer, "inv") == true then 
    cancelEvent() 
    setElementData(localPlayer, "gmm", true) 
    end 
end 
addEventHandler("onClientPlayerDamage", getRootElement(), cancelEvent) 
  
  
  
function seta() 
    if getElementAlpha(localPlayer) == 180 then 
    setElementAlpha(localPlayer, 255) 
end 
end 
setTimer(seta, 10000, 1) 

Link to comment

You don't defined the function in event "onPlayerDamage"

but test it.

  
  
function protect() 
    if getElementAlpha(localPlayer) == 255 then 
    setElementAlpha(localPlayer, 180) 
    setElementData(localPlayer, "inv", true) 
    setTimer(setElementData, 10000, 1, localPlayer, "inv", false)  
     setTimer(setElementAlpha, 10000, 1, localPlayer, 255) 
end 
end 
addEventHandler("onClientPlayerSpawn", getRootElement(), protect) 
  
  
  
function CancelEvent () 
    if getElementData(localPlayer, "inv") == true then 
    cancelEvent() 
    end 
end 
addEventHandler("onClientPlayerDamage", getRootElement(), CancelEvent) 
  
  
  

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