Jump to content

draw dx text


Adde

Recommended Posts

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 by Guest
Link to comment
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
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
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

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