Jump to content

help


ali

Recommended Posts

this was suppoesed to be spawn protection

Server:

addEventHandler("onPlayerSpawn",root, 
function () 
setElementData(source,"spawn_state","spawn",true ) 
end) 
  
addEventHandler("onPlayerDamage", root , 
function (thePlayer) 
local state = getElementData(thePlayer,"spawn_state") 
if tostring(state) == "spawn" then 
cancelEvent( ) 
end 
end 
) 
  
setTimer( 
function (player) 
local state = getElementData(player,"spawn_state") 
if tostring(state) == "spawn" then 
setElementData(source,"spawn_state","finish",true) 
end 
end , 50000 , 0 ) 

[2012-12-21 15:17:56] WARNING: fear\logs.lua:8: Bad argument @ 'getElementData' [Expected element at argument 1, got nil]

[2012-12-21 15:18:32] WARNING: fear\logs.lua:17: Bad argument @ 'getElementData' [Expected element at argument 1, got nil]

Link to comment

Use source instead of thePlayer in the "onPlayerDamage" event:

local state = getElementData(source,"spawn_state") 

Note: cancelling onPlayerDamage event server-side won't cancel the damage, use onClientPlayerDamage on client side.

And who is the player in the timer function? You should make a new function for setting "spawn_state" to "finish" and add a new line to the "onPlayerSpawn" event:

setTimer(someFuntion , 50000 , 1, 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...