Jump to content

setTimer warper , not working


bandi94

Recommended Posts

I need to warp all timers created by loadString , to can kill them if it need to be.

but it's not working like if i use: "setTimer(setVehicleFrozen,1000,1,vehicle,true)" i will get :

Bad argument: @setVhecileFrozen.

My best guest is that the function is not send to "func" as a pointer to the real function.

local g_Timers = {} 
_setTimer = setTimer 
setTimer = function (func, a, b, c, d, e, f , g, h) 
    if not c then c = nil end 
    if not d then d = nil end 
    if not e then e = nil end 
    if not f then f = nil end 
    if not g then g = nil end 
    if not h then h = nil end 
    local timer = _setTimer(func, a, b, c, d, e , f, g, h) 
    if timer then 
        g_Timers[#g_Timers+1] = timer 
        return timer 
    end 
end 

Link to comment

I can't see anything wrong other than these lines:

if you set bool 'false' it will change it for you to nil and you will have problem with functions that need bool, you don't need these lines because it will be nil by default.

     if not c then c = nil end 
    if not d then d = nil end 
    if not e then e = nil end 
    if not f then f = nil end 
    if not g then g = nil end 
    if not h then h = nil end 

Edit: This function should do what you want.

getTimers 

Link to comment
I can't see anything wrong other than these lines:

if you set bool 'false' it will change it for you to nil and you will have problem with functions that need bool, you don't need these lines because it will be nil by default.

     if not c then c = nil end 
    if not d then d = nil end 
    if not e then e = nil end 
    if not f then f = nil end 
    if not g then g = nil end 
    if not h then h = nil end 

Edit: This function should do what you want.

getTimers 

Yep you were right , the "nil" was the problem , i just removed it and now it's working , THX

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