harryh Posted May 3, 2014 Posted May 3, 2014 I have this script, it works but when I use it, it lags the player massively. As it is using onClientRender. Here it is localPlayer = getLocalPlayer() health=0 sTime=0 ping=0 hours=0 minutes=0 function GetCurrentPlayerDateAndTime() local tTime = getRealTime() return string.format("%02d:%02d", tTime.hour, tTime.minute) end function getInfo() ping = getPlayerPing(getLocalPlayer()) sTime = GetCurrentPlayerDateAndTime() health = getElementHealth(localPlayer) end --addEventHandler ( "onClientRender", root, getInfo) function loadTheBox() background = guiCreateStaticImage(1174, 0, 186, 123, "Blackbox.png", false) guiSetAlpha(background, 30) end --addEventHandler('onClientResourceStart', resourceRoot, loadTheBox) function bInfo() localtime = guiCreateLabel(10, 1, 148, 15, "Local Time: " ..sTime.. "", false, background) igtime = guiCreateLabel(11, 26, 148, 15, "In-Game Time: " ..string.format("%02d:%02d", getTime()).. "", false, background) lagblud = guiCreateLabel(11, 51, 148, 15, "Ping: " ..ping.. "", false, background) hp = guiCreateLabel(11, 76, 148, 15, "Health: " ..string.gsub(health,"%.%d*","").."%" , false, background) end --addEventHandler ( "onClientRender", root, bInfo)
xXMADEXx Posted May 3, 2014 Posted May 3, 2014 It's because you're creating a new label every render. Use dxDrawText.
harryh Posted May 3, 2014 Author Posted May 3, 2014 OK, I have but it in one label and it still lags, I will try dxDrawText writelines = guiCreateLabel(13, 11, 163, 102, "Local Time: " ..sTime.. "\n\nIn-Game Time: " ..string.format("%02d:%02d", getTime()).. "\n\nPing: " ..ping.. "\n\nHealth: " ..string.gsub(health,"%.%d*","").."%", false, background) Edit: Thanks dxDrawText works, but it is not in same place for all resoultions
xXMADEXx Posted May 3, 2014 Posted May 3, 2014 On client render triggers any time a client renders. Therefore, a label is creating every render... That's about 50 labels a second.
harryh Posted May 3, 2014 Author Posted May 3, 2014 Ok, I understand now. How can I make this in the in the right top corner of the screen?
tosfera Posted May 3, 2014 Posted May 3, 2014 local x, y = guiGetScreenSize(); dxDrawText ( "Harro people.", x * 0.95, 0, x , y * 0.05, tocolor ( 255, 255, 255, 255 ), 1, "default", "left", "center" );
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