bandi94 Posted December 28, 2013 Share Posted December 28, 2013 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
TAPL Posted December 28, 2013 Share Posted December 28, 2013 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
bandi94 Posted December 28, 2013 Author Share Posted December 28, 2013 Well it should , but that function will return all the timers , i need only timers from loadString and not other one's. I will try it without the nil line's Link to comment
bandi94 Posted December 28, 2013 Author Share Posted December 28, 2013 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
ixjf Posted December 28, 2013 Share Posted December 28, 2013 You shall rather write your function like this: local _setTimer = setTimer function setTimer ( ... ) local timer = _setTimer ( ... ) if ( timer ) then table.insert ( g_Timers, timer ) end return timer end 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