Jump to content

dxDrawText problem


Overkillz

Recommended Posts

Hey dear guys, Im trying to dxDrawText using values from a table

  
local statusfunctions = {"sMap","sNmap","sTimeL","sTimeP","sNos","sHealth","sPeedo","sFPS","sDeadList","sChat"} 
local functionleft = {"Display Map Name","Display Next Map Name","Display Time Left","Display Time Passed","Display Nos","Display Health","Display Speedo","Display FPS","Display Dead List","Display Chat"} 
  
function xsManager() 
    for i=1,#functionleft do 
        statusfunctions[i] = getElementData(localPlayer,statusfunctions[i]) or "Disabled" 
        dxDrawText(functionleft[i].." - "..statusfunctions[i],sX/2-sizeX/2+fontMaHei,(sY/2-sizeY/2+fontMaHei)+fontMaHei*2*i,0,0,tocolor(40,40,40,255),1,fontManager,"left","top",false,false,false,false) 
    end 
end 
addEventHandler("onClientRender",getRootElement(),xsManager) 
  
  

Im getting this error: http://puu.sh/n0LvY/d2f7511fcc.png

I hope u can help me, thanks

Link to comment

On 7th line you are setting statusfunctions to a new value and on next frame (when xsManager() is called again) you try to get getElementData(localPlayer,statusfunctions), which now returns false instead. But the error probably comes when getElementData returns true as boolean as then the "Disabled" is not returned instead.

Also, is this elementData synced with server or is only local? If only local then I guess it should be ok to ask it every frame, though it would make more sense to just keep the values in a separate table as per descriptions they don't change often. If synced, then you should definitely keep them cached and not ask updates from server on each frame.

Edited by Guest
Link to comment

The first time it's going well, but statusfunctions gets changed by that line:

 statusfunctions[i] = getElementData(localPlayer,statusfunctions[i]) or "Disabled" 

getElementData gives true back - atleast one of them.

And you cant use getElementData ( localPlayer, true ).

You should use

local status  = getElementData(localPlayer,statusfunctions[i]) or "Disabled" 
 dxDrawText(functionleft[i].." - "..status,sX/2-sizeX/2+fontMaHei,(sY/2-sizeY/2+fontMaHei)+fontMaHei*2*i,0,0,tocolor(40,40,40,255),1,fontManager,"left","top",false,false,false,false) 

Edit:

Oh, he was faster :D

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