[PXG]Blue Posted September 20, 2015 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 ) ( Renamed from BeaTzZ to [PXG]Blue ) Looking for a Scripter that can make you free / Paid Scripts with a negotiable price? Look no further! add me on skype: phoenix_beatzz My GitHub
JR10 Posted September 20, 2015 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 Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
[PXG]Blue Posted September 20, 2015 Author 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 ( Renamed from BeaTzZ to [PXG]Blue ) Looking for a Scripter that can make you free / Paid Scripts with a negotiable price? Look no further! add me on skype: phoenix_beatzz My GitHub
[PXG]Blue Posted September 20, 2015 Author Posted September 20, 2015 Fixed it. Code ( Renamed from BeaTzZ to [PXG]Blue ) Looking for a Scripter that can make you free / Paid Scripts with a negotiable price? Look no further! add me on skype: phoenix_beatzz My GitHub
JR10 Posted September 20, 2015 Posted September 20, 2015 I didn't notice the infinite timer. Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
Moderators IIYAMA Posted September 20, 2015 Moderators 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) Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
[PXG]Blue Posted September 20, 2015 Author 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. ( Renamed from BeaTzZ to [PXG]Blue ) Looking for a Scripter that can make you free / Paid Scripts with a negotiable price? Look no further! add me on skype: phoenix_beatzz My GitHub
[PXG]Blue Posted September 20, 2015 Author Posted September 20, 2015 Problem Fixed, used Server & Clientside. ( Renamed from BeaTzZ to [PXG]Blue ) Looking for a Scripter that can make you free / Paid Scripts with a negotiable price? Look no further! add me on skype: phoenix_beatzz My GitHub
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