Kenix Posted September 18, 2011 Share Posted September 18, 2011 So if i am hit marker in next time then not in first round ( in next round then timer not destroying and calculate 2 times in next round 3 times and etc Debug: WARNING: zombie_mod\core_server.lua:56: Bad argument @ 'killTimer' [Expected lua-timer at argument 1, got nil] WARNING: zombie_mod\core_server.lua:50: Bad argument @ 'getElementData' [Expected element at argument 1, got nil] addEventHandler("onGamemodeMapStart", root, function( startedMap ) local resource_name = getResourceName( startedMap ) local prefix = resource_name:sub( 1, 2 ); if prefix == 'zp' then mapRoot = getResourceRootElement(startedMap) local general_marker = getElementsByType ("Capture_marker",mapRoot) local obj_enter = getElementsByType ("Object_enter",mapRoot) local obj_key = getElementsByType ("Object_key",mapRoot) for i,v in ipairs(general_marker) do -- local marker = createMarker( tonumber(getElementData(v,"posX")),tonumber(getElementData(v,"posY")),tonumber(getElementData(v,"posZ")),"cylinder",1.5,153,77,39,255) setElementParent( marker, v ) setElementID( marker, "marker"..tostring( getElementData( v, "id" ) ) ) end for i,v in ipairs(obj_enter) do local wall = createObject(16501, getElementData( v,"posX"), getElementData( v,"posY"), getElementData( v,"posZ"), getElementData( v,"rotX"), getElementData( v,"rotY"), getElementData( v,"rotZ") ) setElementParent( wall, getElementByID( "marker"..tostring( getElementData( v, "Parent" ) ) ) ) setElementData( wall, "state", "close" ) local health = tonumber( getElementData( v, "health") ) or 100 setElementData( wall, "health", health ) setElementData( wall, "maxhealth", health ) end for _,v in ipairs(obj_key) do createObject(2886, getElementData( v,"posX"), getElementData( v,"posY"), getElementData( v,"posZ"), getElementData( v,"rotX"), getElementData( v,"rotY"), getElementData( v,"rotZ") ) end addEventHandler("onMarkerHit",root, function( player, dim ) outputChatBox("Capture_marker HIT !") local parent = getElementParent( source ) local elementhit = getElementID( parent ) ------- FIND the Door ONLY ------ local walls = getElementChildren( source ) local wall = walls[1] ----------------------------------------- if ( getElementData( wall, "state" ) ~= "close" ) then return outputChatBox( "not closed" ) end if getElementData( wall, "health" ) >= 0 then if ( getElementByID( elementhit ) ) then local timerDestroy = setTimer( function( player, elementhit ) if isElement( player ) then if getElementData( wall ,"state") == "open" then killTimer(timerDestroy) timerDestroy = nil return end local doorHealth = tonumber(getElementData( wall, "health"))-10 outputChatBox( "health: "..tostring(doorHealth) ) setElementData( wall, "health", doorHealth ) local maxHealth = tonumber(getElementData( wall, "maxhealth")) local doorPercent = math.ceil( (doorHealth/maxHealth)*100 ) triggerClientEvent(player,"sendPercentOpening",player, doorPercent) if ( doorHealth <= 0 ) then local timer = getElementData( player, "timerDestroy" ) if ( isTimer( timer ) ) then killTimer( timer ) end killTimer( timerDestroy ) outputChatBox( "opening the door" ) local x,y,z = getElementPosition( wall ) local _,_,rz = getElementRotation( wall ) outputChatBox( tostring( rz ) ) ------- Calculate the target position ------------ local distance = 0.13 rz = math.rad(rz) local x2 = x+(distance * math.deg(math.sin(-rz))) local y2 = y+(distance * math.deg(math.cos(-rz))) ------------------------------------------------ moveObject( wall, 2500, x2, y2, z ) -- move the door setElementData( wall, "state", "open" ) triggerClientEvent(player,"hideDoorPercent",player) end end end, 1000, 0, player, getElementByID( elementhit ), elementhit ) setElementData( player, "timerDestroy", timerDestroy ) end end end) addEventHandler("onMarkerLeave",root, function( player, dim ) local timer = getElementData( player, "timerDestroy" ) if ( isTimer( timer ) ) then killTimer( timer ) end triggerClientEvent(player,"hideDoorPercent",player) end ) end end ) Thx in advance. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now