Adde Posted August 30, 2013 Share 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 Link to comment
#Al-Ha[J]aRii Posted August 30, 2013 Share 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 ? Link to comment
Moderators IIYAMA Posted August 30, 2013 Moderators Share 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 Link to comment
Adde Posted August 30, 2013 Author Share 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. 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