Markeloff Posted August 29, 2014 Share Posted August 29, 2014 So, I want to know how to solve getting debug errors about expected element at argument 1, got nil. Actually, this happens to be everytime I use a timer containing a whole function in a function. I know source isn't defined in the function inside this timer but doesn't every function have 'source' as argument by random? So even when I tried to put the argument source in the function but the same problem. I solved this by excluding the function from being inside the timer but I need to know how to solve it this way. function CheckingOnLogin() setTimer ( function() if isPlayerInSafeZone(source) then outputChatBox(getPlayerName(source).." logged in and in safe zone",root,255,0,0) setElementData(source,"isPlayerInSafeZone",true) toggleControl (source, "fire", false) toggleControl (source, "aim_weapon", false) else outputChatBox(getPlayerName(source).." logged in and not in safe zone",root,255,0,0) end end, 5000, 1 ) end addEventHandler("onPlayerLogin",root,CheckingOnLogin) Link to comment
WASSIm. Posted August 29, 2014 Share Posted August 29, 2014 try this function CheckingOnLogin() setTimer ( function(source) if isPlayerInSafeZone(source) then outputChatBox(getPlayerName(source).." logged in and in safe zone",root,255,0,0) setElementData(source,"isPlayerInSafeZone",true) toggleControl (source, "fire", false) toggleControl (source, "aim_weapon", false) else outputChatBox(getPlayerName(source).." logged in and not in safe zone",root,255,0,0) end end, 5000, 1, source ) end addEventHandler("onPlayerLogin",root,CheckingOnLogin) Link to comment
Markeloff Posted August 29, 2014 Author Share Posted August 29, 2014 Wassim, So even when I tried to put the argument source in the function but the same problem. I tried it but, the same problem. Edit : it worked, thank you. I haven't got it yet, I did the same you had done but, it didn't work. Link to comment
Markeloff Posted August 29, 2014 Author Share Posted August 29, 2014 Problem solved, thank you Wassim. 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