Cronoss Posted May 2, 2022 Share Posted May 2, 2022 I need help with something. I can't find anything about this on the forum, so I'll try to explain it; I want the player to be able to see their information in a panel (created with guieditor / dxDraw) Example: Your money: $40.000 Your Health: 100/100 I know this is possible but I don't know wich option I should choose for these "changing texts" : 1.- Using a "DX text" empty and then using some scripting, the player could get his info (?) 2.- Same here but with "label" (guieditor tool) (?) I'm not posting any code because I'm trying to figure out how to finish it, I just need to know between those options wich is the better way to make this possible Link to comment
Hydra Posted May 2, 2022 Share Posted May 2, 2022 --// DX Draw local sx, sy = guiGetScreenSize() local resW = sx/1920 --// I put sx/1920 bcs my resolution is 1920x1080 you can put sx/your resolution width, I use resW for text scalling function ShowInfo() local theCash = getPlayerMoney(localPlayer) dxDrawRectangle(sx * 0.1300, sy * 0.2300, sx * 0.2300, sy * 0.3000, tocolor(0, 0, 0, 210), false) dxDrawText("Player Money: "..theCash.."", sx * 0.1400, sy * 0.2700, sx * 0.0300, sy * 0.0300, tocolor(255, 255, 255, 255), 1.00*resW, "default-bold", "left", "top") end function CheckInfo() if not infoState then infoState = true addEventHandler("onClientRender", root, ShowInfo) else infoState = false removeEventHandler("onClientRender", root, ShowInfo) end end addCommandHandler("info", CheckInfo) --// GUI local window = guiCreateWindow(etc...) local label = guiCreateLabel(etc....) guiSetVisible(window, false) local timerUpdateInfo = nil function updateInfo() local theCash = getPlayerMoney(localPlayer) guiSetText(label, "Player Money: "..theCash.."") end function CheckInfo() if guiGetVisible(window) == false then guiSetVisible(window, true) timerUpdateInfo = setTimer(updateInfo, 1000, 0) else guiSetVisible(window, false) if isTimer(timerUpdateInfo) then killTimer(timerUpdateInfo) timerUpdateInfo = nil end end end addCommandHandler("info", CheckInfo) You can use GUI or DX without any problem, now it also depends on what kind of interface you want your server to have. If you want something classic you can use GUI but if you want something based on design and animations then DX it's the best way. I put an example above for the player info 1 Link to comment
Cronoss Posted May 2, 2022 Author Share Posted May 2, 2022 I appreciate it, but this wouldn't cause lag problems if I ask for element data? something like this: function infoPanel() local name = getElementData(localPlayer, "character.2") --dx draw text blabla "your name: "..name.."" end addEventHandler("onClientRender", getRootElement(), infoPanel) Link to comment
Hydra Posted May 3, 2022 Share Posted May 3, 2022 13 hours ago, Cronoss said: I appreciate it, but this wouldn't cause lag problems if I ask for element data? something like this: function infoPanel() local name = getElementData(localPlayer, "character.2") --dx draw text blabla "your name: "..name.."" end addEventHandler("onClientRender", getRootElement(), infoPanel) You can use the element data, it does not produce lag as some people say. I have 10+ element datas on my server and I have no lag. Depends on how you use it too 1 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