Jump to content

Check part of a function


PashaBiceps

Recommended Posts

I would like to check a part of my function, he works good but he is not checking and updating.

	local playername = getPlayerName(getLocalPlayer())
	local avatar = getElementData(getLocalPlayer(), "avatar")

		if playername then
			if avatar >= 1 then
				dxDrawImage(x*639,y*306.5,x*94,y*94, "avatars/"..avatar..".png")
			else
				dxDrawImage(x*639,y*306.5,x*94,y*94,"gfx/avatar0.png")
			end
		end

What i want is check this part of the function and when he don't detect the player name on log in, his avatar change immediately.

I tried to use a timer but when i put it, this part of the script stopped work. 

Can you guys help? ❤️ 

 

Link to comment

I suggest you using the global variable ´localPlayer’ instead of calling getLocalPlayer() function that use less CPU. Also when you know you will use the same function in the same part of code multiple times you may want to declare a variable to save CPU

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