Turbe$Z Posted May 21, 2017 Share Posted May 21, 2017 local screenW, screenH = guiGetScreenSize() function ahudd() dxDrawImage(screenW * 0.8424, screenH * 0.6289, screenW * 0.1194, screenH * 0.0256, "nbgg.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawImage(screenW * 0.8444, screenH * 0.6322, screenW * 0.1153, screenH * 0.0189, "nn.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawText("Jármű épség:", (screenW * 0.8424) + 1, (screenH * 0.6289) + 1, (screenW * 0.9618) + 1, (screenH * 0.6544) + 1, tocolor(0, 0, 0, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false) dxDrawText("Jármű épség:", screenW * 0.8424, screenH * 0.6289, screenW * 0.9618, screenH * 0.6544, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false) end function asdxd() local playerVehicle = getPedOccupiedVehicle ( localPlayer ) if playerVehicle then local vehicleHealth = getElementHealth ( playerVehicle ) / 10 addEventHandler("onClientRender", root, ahudd) else removeEventHandler("onClientRender", root, ahudd) end end addEventHandler("onClientRender", root, asdxd) fileDelete("client.lua") why not working? i want, when the player get in a vehicle, show the dx element, and when get out, hide the dx element, and if player in a vehicle, the dx element show just for her Link to comment
Tails Posted May 21, 2017 Share Posted May 21, 2017 Use the onClientVehicleEnter event. Something like this: addEventHandler("onClientVehicleEnter", root, function(plr) if plr == localPlayer then addEventHandler("onClientRender", root, draw) end end ) function draw() local veh = getPedOccupiedVehicle(localPlayer) if veh then ahudd() else removeEventHandler("onClientRender", root, draw) end end 1 Link to comment
Turbe$Z Posted May 21, 2017 Author Share Posted May 21, 2017 3 minutes ago, Tails said: Use the onClientVehicleEnter event. Something like this: addEventHandler("onClientVehicleEnter", root, function(plr) if plr == localPlayer then addEventHandler("onClientRender", root, draw) end end ) function draw() local veh = getPedOccupiedVehicle(localPlayer) if veh then ahudd() else removeEventHandler("onClientRender", root, draw) end end Thank you! 1 Link to comment
DNL291 Posted May 21, 2017 Share Posted May 21, 2017 That code will not work if you warp on a vehicle. Just use getPedOccupiedVehicle(localPlayer) inside the function 'ahudd': local screenW, screenH = guiGetScreenSize() function ahudd() if getPedOccupiedVehicle ( localPlayer ) then dxDrawImage(screenW * 0.8424, screenH * 0.6289, screenW * 0.1194, screenH * 0.0256, "nbgg.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawImage(screenW * 0.8444, screenH * 0.6322, screenW * 0.1153, screenH * 0.0189, "nn.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawText("Jármű épség:", (screenW * 0.8424) + 1, (screenH * 0.6289) + 1, (screenW * 0.9618) + 1, (screenH * 0.6544) + 1, tocolor(0, 0, 0, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false) dxDrawText("Jármű épség:", screenW * 0.8424, screenH * 0.6289, screenW * 0.9618, screenH * 0.6544, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false) end end addEventHandler( "onClientResourceStart", resourceRoot, function() addEventHandler("onClientRender", root, ahudd) end ) if fileExists("client.lua") then fileDelete("client.lua") end 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