[PXG]Blue Posted September 20, 2015 Share Posted September 20, 2015 hey guys, i'm having a problem, when a player goes into the colshape a timer gets started, but when he leaves the timer doesnt get canceled. Code: safezone = createColSphere(2090.75049, -112.47958, 7.04545, 90, 10, 10) function onSafeEnable(thePlayer, matchingdim) if getElementType ( thePlayer ) == "player" then outputChatBox("You entered the Safezone, report griefers at our Forums or Ingame!", thePlayer, 255, 255, 255, false) playerBlood = getElementData(thePlayer, "blood") nodmtim = setTimer(function() if not thePlayer then killTimer(nodmtim) end -- HERE IS THE PROBLEM toggleControl(thePlayer, "fire", false) toggleControl(thePlayer, "zoom_in", false) toggleControl(thePlayer, "vehicle_fire", false) setElementData(thePlayer, "blood", playerBlood, true) end, 300, 0 ) else if getElementData(thePlayer, "slothbot") then setElementPosition(thePlayer, 0, 0, -10) setTimer(function() killPed(thePlayer) end, 5000, 1 ) end end end addEventHandler("onColShapeHit", safezone, onSafeEnable) function onSafeDisable(thePlayer, matchingdim) if getElementType ( thePlayer ) == "player" then killTimer(nodmtim) outputChatBox("You left the Safezone, Watch out for Yourself!", thePlayer, 255, 255, 255, false) toggleControl(thePlayer, "fire", true) toggleControl(thePlayer, "zoom_in", true) toggleControl(thePlayer, "aim_weapon", true) toggleControl(thePlayer, "vehicle_fire", true) end end addEventHandler ( "onColShapeLeave", safezone, onSafeDisable ) Link to comment
JR10 Posted September 20, 2015 Share Posted September 20, 2015 You don't need to kill the timer inside the timer's function itself, you just need to return and not execute any code. if not thePlayer then return end Link to comment
[PXG]Blue Posted September 20, 2015 Author Share Posted September 20, 2015 You don't need to kill the timer inside the timer's function itself, you just need to return and not execute any code. if not thePlayer then return end Still the same Link to comment
[PXG]Blue Posted September 20, 2015 Author Share Posted September 20, 2015 Fixed it. Code Link to comment
JR10 Posted September 20, 2015 Share Posted September 20, 2015 I didn't notice the infinite timer. Link to comment
Moderators IIYAMA Posted September 20, 2015 Moderators Share Posted September 20, 2015 That doesn't work well with more players and it is using too much bandwidth(because those are "set" and "toggle" functions). toggleControl(thePlayer, "fire", false) toggleControl(thePlayer, "zoom_in", false) toggleControl(thePlayer, "vehicle_fire", false) setElementData(thePlayer, "blood", playerBlood, true) Link to comment
[PXG]Blue Posted September 20, 2015 Author Share Posted September 20, 2015 That doesn't work well with more players and it is using too much bandwidth(because those are "set" and "toggle" functions). The Problem is that i'm using a DayZ mode, and as soon as you equipt a weapon in your Inventory it toggles it ON, thats why i have that timer. Link to comment
[PXG]Blue Posted September 20, 2015 Author Share Posted September 20, 2015 Problem Fixed, used Server & Clientside. 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