Jump to content

Send argument thru timer function


Quenix

Recommended Posts

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);

 

Link to comment
  • Moderators

@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)

 

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