Adde Posted August 30, 2013 Posted August 30, 2013 (edited) Hello, I have a problem with this script. It doesn´t show the current level on the screen. It says attempt to call global theLevel (a nil value). Is something wrong with getElementData? function showLevel() theLevel = getElementData(source, "Level") color = tocolor(0,255,0,255) levelcolor = tocolor(255,255,0,255) dxDrawText("Current Level:", x*0.78, y*0.46, 0, 0, color, 3) dxDrawText("" ..theLevel, x*0.905, y*0.46, 0, 0, levelcolor, 3) end function HandleTheRendering ( ) addEventHandler("onClientRender", getRootElement(), showLevel) end addEventHandler("onClientResourceStart",resourceRoot, HandleTheRendering) Edited September 4, 2013 by Guest My ingame nickname is: Mr.Snus
#Al-Ha[J]aRii Posted August 30, 2013 Posted August 30, 2013 Hello, I have a problem with this script. It doesn´t show the current level on the screen. It says attempt to call global theLevel (a nil value). Is something wrong with getElementData? function showLevel() theLevel = getElementData(source, "Level") color = tocolor(0,255,0,255) levelcolor = tocolor(255,255,0,255) dxDrawText("Current Level:", x*0.78, y*0.46, 0, 0, color, 3) dxDrawText("" ..theLevel, x*0.905, y*0.46, 0, 0, levelcolor, 3) end function HandleTheRendering ( ) addEventHandler("onClientRender", getRootElement(), showLevel) end addEventHandler("onClientResourceStart",resourceRoot, HandleTheRendering) any error with debugscript ? Try a little harder to be a little better I Can Made To You Any Script For $ Skype : alhajarii-mtasa
Moderators IIYAMA Posted August 30, 2013 Moderators Posted August 30, 2013 local levelTextColor = tocolor(0,255,0,255) local levelColor = tocolor(255,255,0,255) local function showLevel() local theLevel = getElementData(localPlayer, "Level") or 0 dxDrawText("Current Level:", x*0.78, y*0.46, 0, 0, levelTextColor, 3) dxDrawText("" ..theLevel, x*0.905, y*0.46, 0, 0, levelcolor, 3) end function HandleTheRendering ( ) addEventHandler("onClientRender", getRootElement(), showLevel) end addEventHandler("onClientResourceStart",resourceRoot, HandleTheRendering) if it shows 0 then the level is 0 or the level haven't been set successfully. UPDATED AT 3-8-2013 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
Adde Posted August 30, 2013 Author Posted August 30, 2013 local levelTextColor = tocolor(0,255,0,255) local levelColor = tocolor(255,255,0,255) local function showLevel() local theLevel = getElementData(localPlayer, "Level") or 0 dxDrawText("Current Level:", x*0.78, y*0.46, 0, 0, levelTextColor, 3) dxDrawText("" ..theLevel, x*0.905, y*0.46, 0, 0, levelcolor, 3) end function HandleTheRendering ( ) addEventHandler("onClientRender", getRootElement(), showLevel) end addEventHandler("onClientResourceStart",resourceRoot, HandleTheRendering) if it shows 0 then the level is 0 or the level haven't been set successfully. UPDATED AT 3-8-2013 Thx! I got it working. My ingame nickname is: Mr.Snus
Moderators IIYAMA Posted August 30, 2013 Moderators Posted August 30, 2013 np. 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
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