Kenix Posted September 8, 2011 Share Posted September 8, 2011 (edited) I have question so i want create a scoreboard: Example: Name: ID ping: someguy 1 0 someguy2 2 10 and etc how create it in dxDrawText? Thx in advance Edited September 8, 2011 by Guest Link to comment
Cadu12 Posted September 8, 2011 Share Posted September 8, 2011 https://wiki.multitheftauto.com/wiki/DxDrawText viewtopic.php?f=91&t=30227&hilit=dxdrawtext+color&start=15#p329917 <-- for colored https://wiki.multitheftauto.com/wiki/DxDrawRectangle https://wiki.multitheftauto.com/wiki/DxGetTextWidth https://wiki.multitheftauto.com/wiki/GuiGetScreenSize Events: https://wiki.multitheftauto.com/wiki/OnClientClick https://wiki.multitheftauto.com/wiki/OnClientPlayerQuit https://wiki.multitheftauto.com/wiki/OnClientPlayerJoin https://wiki.multitheftauto.com/wiki/OnC ... ChangeNick https://wiki.multitheftauto.com/wiki/OnC ... ourceStart https://wiki.multitheftauto.com/wiki/OnClientRender Link to comment
Kenix Posted September 8, 2011 Author Share Posted September 8, 2011 i know it lol but i dont know how to transfer line addEventHandler("onClientRender",root, function() if getElementData(me,"isLogged") then dxDrawRectangle(385.0,190.0,519.0,645.0,tocolor(0,0,0,200),false) dxDrawText("Name ID Ping",458.0,290.0,616.0,310.0,tocolor(255,255,255,255),1.3,"arial","left","top",false,false,false) for i , v in ipairs(getElementsByType('player')) do dxDrawText("\n ("..i..")"..getPlayerName(v).." "..tonumber(getElementData(v,"ID")) or 0 .."",458.0,312.0,916.0,332.0,tocolor(255,255,255,255),1.3,"arial","left","top",false,false,false) dxDrawText("\n "..getPlayerPing(v),458.0,312.0,916.0,332.0,tocolor(255,255,255,255),1.3,"arial","left","top",false,false,false) end end end ) Link to comment
SDK Posted September 8, 2011 Share Posted September 8, 2011 If you mean, draw every player on a new line, use this method: addEventHandler("onClientRender", root, function() local x, y = 385,190 local dy = 15 for i, player in ipairs(getElementsByType('player') do dxDrawText(getPlayerName(player), x, y + dy * (i - 1)) end end) Link to comment
Kenix Posted September 8, 2011 Author Share Posted September 8, 2011 Yes i mean it thx dude. Link to comment
Cadu12 Posted September 8, 2011 Share Posted September 8, 2011 local _getPlayerName = getPlayerName addEventHandler("onClientRender",root, function() --if getElementData(me,"isLogged") then -- You can add this, i was testing and fixing it. local screenx, screeny = guiGetScreenSize() local line = 0 for i , v in ipairs(getElementsByType('player')) do dxDrawRectangle( ((screenx/2-(600/2))/1024)*screenx, ((screeny/2-(line * 20 + 100))/768)*screeny, (600/1024)*screenx, (line * 20 + 80/768)*screeny ,tocolor(0,0,0,200),false) dxDrawText("Name", ((screenx/2-(600/2-10))/1024)*screenx, ((screeny/2-(line * 20 + 90))/768)*screeny, ((screenx/2-(600-10/2))/1024)*screenx, ((screeny/2-(line * 20 + 90))/768)*screeny,tocolor(255,255,255,255), (screenx/800)*1.2,"arial","left","top",false,false,false) dxDrawText("ID", ((screenx/2-(600/2-300))/1024)*screenx, ((screeny/2-(line * 20 + 90))/768)*screeny, ((screenx/2-(600/2-300))/1024)*screenx, ((screeny/2-(line * 20 + 90))/768)*screeny,tocolor(255,255,255,255), (screenx/800)*1.2,"arial","left","top",false,false,false) dxDrawText("Ping", ((screenx/2-(600/2-550))/1024)*screenx, ((screeny/2-(line * 20 + 90))/768)*screeny, ((screenx/2-(600/2-550))/1024)*screenx, ((screeny/2-(line * 20 + 90))/768)*screeny,tocolor(255,255,255,255), (screenx/800)*1.2,"arial","left","top",false,false,false) dxDrawText("(" .. i .. ")" .. getPlayerName(v) , ((screenx/2-(600/2-10))/1024)*screenx, ((screeny/2-(line * 20 + 60))/768)*screeny, ((screenx/2-(600/2-10))/1024)*screenx, ((screeny/2-(line * 20 + 55))/768)*screeny,tocolor(255,255,255,200), (screenx/800)*1.2,"arial","left","top",false,false,false) dxDrawText( tonumber(getElementData(v,"ID")) or 0, ((screenx/2-(600/2-300))/1024)*screenx, ((screeny/2-(line * 20 + 60))/768)*screeny, ((screenx/2-(600/2-300))/1024)*screenx, ((screeny/2-(line * 20 + 55))/768)*screeny,tocolor(255,255,255,200), (screenx/800)*1.2,"arial","left","top",false,false,false) dxDrawText( getPlayerPing (v), ((screenx/2-(600/2-550))/1024)*screenx, ((screeny/2-(line * 20 + 60))/768)*screeny, ((screenx/2-(600/2-550))/1024)*screenx, ((screeny/2-(line * 20 + 55))/768)*screeny,tocolor(255,255,255,200), (screenx/800)*1.2,"arial","left","top",false,false,false) line = line + 1 end --end end ) function removeColorCoding ( name ) -- Credis to Race return type(name)=='string' and string.gsub ( name, '#%x%x%x%x%x%x', '' ) or name end function getPlayerName ( player ) -- Credis to Race return removeColorCoding ( _getPlayerName ( player ) ) end Edit: Maybe this is better or not, i was fixing... too slow D: Edit2: http://imageshack.us/photo/my-images/21/helpingw.png/ Link to comment
Kenix Posted September 8, 2011 Author Share Posted September 8, 2011 local _getPlayerName = getPlayerName addEventHandler("onClientRender",root, function() --if getElementData(me,"isLogged") then -- You can add this, i was testing and fixing it. local screenx, screeny = guiGetScreenSize() local line = 0 for i , v in ipairs(getElementsByType('player')) do dxDrawRectangle( ((screenx/2-(600/2))/1024)*screenx, ((screeny/2-(line * 20 + 100))/768)*screeny, (600/1024)*screenx, (line * 20 + 80/768)*screeny ,tocolor(0,0,0,200),false) dxDrawText("Name", ((screenx/2-(600/2-10))/1024)*screenx, ((screeny/2-(line * 20 + 90))/768)*screeny, ((screenx/2-(600-10/2))/1024)*screenx, ((screeny/2-(line * 20 + 90))/768)*screeny,tocolor(255,255,255,255), (screenx/800)*1.2,"arial","left","top",false,false,false) dxDrawText("ID", ((screenx/2-(600/2-300))/1024)*screenx, ((screeny/2-(line * 20 + 90))/768)*screeny, ((screenx/2-(600/2-300))/1024)*screenx, ((screeny/2-(line * 20 + 90))/768)*screeny,tocolor(255,255,255,255), (screenx/800)*1.2,"arial","left","top",false,false,false) dxDrawText("Ping", ((screenx/2-(600/2-550))/1024)*screenx, ((screeny/2-(line * 20 + 90))/768)*screeny, ((screenx/2-(600/2-550))/1024)*screenx, ((screeny/2-(line * 20 + 90))/768)*screeny,tocolor(255,255,255,255), (screenx/800)*1.2,"arial","left","top",false,false,false) dxDrawText("(" .. i .. ")" .. getPlayerName(v) , ((screenx/2-(600/2-10))/1024)*screenx, ((screeny/2-(line * 20 + 60))/768)*screeny, ((screenx/2-(600/2-10))/1024)*screenx, ((screeny/2-(line * 20 + 55))/768)*screeny,tocolor(255,255,255,200), (screenx/800)*1.2,"arial","left","top",false,false,false) dxDrawText( tonumber(getElementData(v,"ID")) or 0, ((screenx/2-(600/2-300))/1024)*screenx, ((screeny/2-(line * 20 + 60))/768)*screeny, ((screenx/2-(600/2-300))/1024)*screenx, ((screeny/2-(line * 20 + 55))/768)*screeny,tocolor(255,255,255,200), (screenx/800)*1.2,"arial","left","top",false,false,false) dxDrawText( getPlayerPing (v), ((screenx/2-(600/2-550))/1024)*screenx, ((screeny/2-(line * 20 + 60))/768)*screeny, ((screenx/2-(600/2-550))/1024)*screenx, ((screeny/2-(line * 20 + 55))/768)*screeny,tocolor(255,255,255,200), (screenx/800)*1.2,"arial","left","top",false,false,false) line = line + 1 end --end end ) function removeColorCoding ( name ) -- Credis to Race return type(name)=='string' and string.gsub ( name, '#%x%x%x%x%x%x', '' ) or name end function getPlayerName ( player ) -- Credis to Race return removeColorCoding ( _getPlayerName ( player ) ) end Edit: Maybe this is better or not, i was fixing... too slow D: Edit2: http://imageshack.us/photo/my-images/21/helpingw.png/ Thx dude Link to comment
Castillo Posted September 8, 2011 Share Posted September 8, 2011 But, that won't go of screen? because when there are about 50 ( or less ) players, the rectangle will be too big, I think you'll need a kind of scroll panel. 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