downight Posted March 5, 2014 Share Posted March 5, 2014 Hi, I want to show ping on screen. I've made code but doesn't work since I'm learning how to script Please help me function DXdraw() --Variables local screenWidth, screenHeight = guiGetScreenSize ( ) setTimer(function() triggerServerEvent("online",getLocalPlayer()) end, 10000, 1, true) local ping = getPlayerPing ( getLocalPlayer(), "ping") g_dxGUI = { ping = dxText:create("PING: ", screenWidth - 202,screenHeight - 86, false, 'bankgothic', 0.7), pingNumber = dxText:create(..ping, screenWidth - 150,screenHeight - 86, false, 'bankgothic', 0.7) } g_dxGUI.ping:color(255, 255, 255, 255) g_dxGUI.pingNumber:color(128,255,0,255) g_dxGUI.ping:type("shadow", 1, 0, 0, 0, 255) g_dxGUI.pingNumber:type("shadow", 1, 0, 0, 0, 255) end addEventHandler("onClientRender", getRootElement(), DXdraw) local pingEnabled = true function ping() if pingEnabled then g_dxGUI.ping:visible(false) g_dxGUI.pingNumber:visible(false) pingEnabled = false else g_dxGUI.pingEnabled = true g_dxGUI.ping:visible(true) g_dxGUI.pingNumber:visible(true) end end addCommandHandler("ping", ping, false, false) Link to comment
WhoAmI Posted March 5, 2014 Share Posted March 5, 2014 local screenWidth, screenHeight = guiGetScreenSize ( ) setTimer ( function ( ) triggerServerEvent("online", localPlayer) end , 10000, 0) function DXdraw() local ping = getPlayerPing ( localPlayer ) g_dxGUI = { ping = dxText:create("PING: ", screenWidth - 202,screenHeight - 86, false, 'bankgothic', 0.7), pingNumber = dxText:create(ping, screenWidth - 150,screenHeight - 86, false, 'bankgothic', 0.7) } g_dxGUI.ping:color(255, 255, 255, 255) g_dxGUI.pingNumber:color(128,255,0,255) g_dxGUI.ping:type("shadow", 1, 0, 0, 0, 255) g_dxGUI.pingNumber:type("shadow", 1, 0, 0, 0, 255) end Check this out. But are you sure that you want trigger server event every frame? This function is turning on 30-60 times per second. I put this timer before the function. Link to comment
downight Posted March 5, 2014 Author Share Posted March 5, 2014 I don't know. How bad is it? I mean, does it slowdown the server or what? Link to comment
WhoAmI Posted March 5, 2014 Share Posted March 5, 2014 Isn't it? You are just setting timer 50 times in 1 second. You can do this once in 10 seconds or even more. Link to comment
downight Posted March 5, 2014 Author Share Posted March 5, 2014 Your code doesn't work either for me :3 Link to comment
WhoAmI Posted March 5, 2014 Share Posted March 5, 2014 Errors? And you are sure that dxGUI is started? Link to comment
downight Posted March 5, 2014 Author Share Posted March 5, 2014 I have FPS script but in race.zip and it works fine. So could you help me edit it? Link to comment
downight Posted March 5, 2014 Author Share Posted March 5, 2014 Nvm for now. This ping code works good but I want "ping" text white and "ping number" 128,255,0 function DXdraw() --Variables local screenWidth, screenHeight = guiGetScreenSize ( ) setTimer(function() triggerServerEvent("online",getLocalPlayer()) end, 10000, 1, true) local ping = getPlayerPing ( getLocalPlayer(), "ping2") ping2= ' Ping:' ..ping dxDrawText(tostring(ping2),0, screenHeight - 190, screenWidth, screenHeight,tocolor(128,255,0),0.7,"bankgothic") end addEventHandler("onClientRender", getRootElement(), DXdraw) Link to comment
WhoAmI Posted March 5, 2014 Share Posted March 5, 2014 function DXdraw() --Variables local screenWidth, screenHeight = guiGetScreenSize ( ) setTimer(function() triggerServerEvent("online",getLocalPlayer()) end, 10000, 1, true) local ping = getPlayerPing ( localPlayer ) dxDrawText(tostring(ping), 0, screenHeight - 190, screenWidth, screenHeight,tocolor(128, 255, 0, 255),0.7,"bankgothic") dxDrawText("Ping:", 0, screenHeight - 190, screenWidth, screenHeight,tocolor(255, 255, 255, 255),0.7,"bankgothic") end addEventHandler("onClientRender", getRootElement(), DXdraw) You just need to change position in 2nd text. Link to comment
downight Posted March 5, 2014 Author Share Posted March 5, 2014 Nice, works But you know how to add shadow? I want to add a slight shadow to the text. I used: type("shadow", 1, 0, 0, 0, 255). But doesn't work tho Link to comment
WhoAmI Posted March 5, 2014 Share Posted March 5, 2014 Just add extra dxDrawText with same values, but x, y position +1, +1 colored black. Link to comment
downight Posted March 5, 2014 Author Share Posted March 5, 2014 I didn't think of that lol Thanks man ^^ 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