Quenix Posted March 7, 2019 Posted March 7, 2019 Hey so this is my code and i get Expect argument and got nil at setElementAlpha so im wondering how i can use timer function correctly in this code? Here is the code regarding to the error: bindKey("aim_weapon", "both", function(key, press) if (getPedWeapon(localPlayer) == 34) then if (press == "down") then for i = 1, 4 do if (i ~= 3) then local tohide = getElementData(localPlayer, "tohide"..tostring(i)) or "NONE"; if (tohide ~= "NONE") then setElementAlpha(tohide, 0); end end end elseif (press == "up") then for i = 1, 4 do if (i ~= 3) then local tohide = getElementData(localPlayer, "tohide"..tostring(i)) or "NONE"; if (tohide ~= "NONE") then setElementAlpha(tohide, 255); end end end end end end);
Moderators IIYAMA Posted March 7, 2019 Moderators Posted March 7, 2019 @Quenix There is no timer function in this code... In case you use a timer function and you want to pass arguments: function remindMe (arg1, arg2) iprint(arg1, arg2) end ------------------- local arg1 = "argument1" local arg2 = "argument2" setTimer(remindMe, 1000, 1, arg1, arg2) 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
Moderators IIYAMA Posted March 7, 2019 Moderators Posted March 7, 2019 1 minute ago, Quenix said: Where exactly do i put this in the code? Obvious, at the place where you want to use a timer. It is your code, you know that best. 1 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
Quenix Posted March 7, 2019 Author Posted March 7, 2019 2 minutes ago, IIYAMA said: Obvious, at the place where you want to use a timer. It is your code, you know that best. That is correct, thank you for your assistance 1
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