Jump to content

Colshape Problem ( When Player Quits )


[PXG]Blue

Recommended Posts

Posted

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

Posted
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 :/

c71d44cb48.png

( 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

  • Moderators
Posted

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 

  Tutorials  4x 

 

Posted
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

Posted

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

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