Victor214 Posted May 29, 2012 Share Posted May 29, 2012 So, I've made a script, when I tested it on "Host Game" it was working fine, then I put it on my server, my brother joined it to help me testing. The script is basicaly a dx rectangle, some images, some dx texts and a showhud function. For me, the script was working fine, but for my brother the only thing working was the showhud function, can anyone help me to find the reason? addEventHandler("onClientResourceStart",resourceRoot, function() GUIEditor_Window = {} GUIEditor_Image = {} GUIEditor_Window[1] = guiCreateWindow(227,759,486,78,"",false) guiSetAlpha(GUIEditor_Window[1],0) GUIEditor_Image[1] = guiCreateStaticImage(776,670,334,172,"images/gui5.png",false) GUIEditor_Image[2] = guiCreateStaticImage(235,778,79,73,"images/gui1.png",false) GUIEditor_Image[3] = guiCreateStaticImage(353,770,211,90,"images/gui2.png",false) GUIEditor_Image[4] = guiCreateStaticImage(594,727,124,137,"images/gui3.png",false) end ) --------- health = getElementHealth( localPlayer ) armor = getPedArmor ( localPlayer ) -- Direct X Drawing addEventHandler("onClientRender",root, function() wid = getPedWeapon(localPlayer) dxDrawRectangle(1152.0,864.0,5.0,5.0,tocolor(255,255,255,255),false) dxDrawRectangle(0.0,821.0,1152.0,41.0,tocolor(0,0,0,170),false) dxDrawRectangle(1152.0,863.0,5.0,5.0,tocolor(255,255,255,255),false) dxDrawText(""..getPedArmor(localPlayer).."",673.0,835.0,742.0,861.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) dxDrawText(""..getPedTotalAmmo(localPlayer).."",480.0,835.0,549.0,861.0,tocolor(255,255,0,255),1.0,"default","left","top",false,false,false) dxDrawText(""..getElementHealth(localPlayer).."",287.0,835.0,356.0,861.0,tocolor(255,0,0,255),1.0,"default","left","top",false,false,false) dxDrawText(""..getWeaponNameFromID(wid).."",480.0,845.0,356.0,861.0,tocolor(255,255,0,255),1.0,"default","left","top",false,false,false) showPlayerHudComponent ("ammo", false) showPlayerHudComponent ("armour", false) showPlayerHudComponent ("breath", false) showPlayerHudComponent ("clock", false) showPlayerHudComponent ("health", false) showPlayerHudComponent ("money", false) showPlayerHudComponent ("weapon", false) end ) Link to comment
Flaker Posted May 29, 2012 Share Posted May 29, 2012 (edited) Try this: function gui_create () local wdwMain = guiCreateWindow(227,759,486,78,"",false) local imgGUI5 = guiCreateStaticImage(776,670,334,172,"images/gui5.png",false) local imgGUI1 = guiCreateStaticImage(235,778,79,73,"images/gui1.png",false) local imgGUI2 = guiCreateStaticImage(353,770,211,90,"images/gui2.png",false) local imgGUI3 = guiCreateStaticImage(594,727,124,137,"images/gui3.png",false) showPlayerHudComponent ("ammo", false) showPlayerHudComponent ("armour", false) showPlayerHudComponent ("breath", false) showPlayerHudComponent ("clock", false) showPlayerHudComponent ("health", false) showPlayerHudComponent ("money", false) showPlayerHudComponent ("weapon", false) addEventHandler("onClientRender",client,renderFunc) end addEventHandler("onClientResourceStart",client, gui_create) function renderFunc() local wid = getWeaponNameFromID(getPedWeapon(localPlayer)) local cl_player_health = tostring(math.floor(getElementHealth( localPlayer ))) local cl_player_armor = tostring(math.floor(getPedArmor ( localPlayer ))) local cl_player_ammo = tostring(math.floor(getPedTotalAmmo(localPlayer))) dxDrawRectangle(1152.0,864.0,5.0,5.0,tocolor(255,255,255,255),false) dxDrawRectangle(0.0,821.0,1152.0,41.0,tocolor(0,0,0,170),false) dxDrawRectangle(1152.0,863.0,5.0,5.0,tocolor(255,255,255,255),false) dxDrawText(""..cl_player_armor.."",673.0,835.0,742.0,861.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) dxDrawText(""..cl_player_ammo.."",480.0,835.0,549.0,861.0,tocolor(255,255,0,255),1.0,"default","left","top",false,false,false) dxDrawText(""..cl_player_health.."",287.0,835.0,356.0,861.0,tocolor(255,0,0,255),1.0,"default","left","top",false,false,false) dxDrawText(""..wid.."",480.0,845.0,356.0,861.0,tocolor(255,255,0,255),1.0,"default","left","top",false,false,false) end Edited May 29, 2012 by Guest Link to comment
Victor214 Posted May 29, 2012 Author Share Posted May 29, 2012 (edited) Thanks, but the same thing is happening =X edit: I've found the problem, I put absolute positions of the screen (Pixels) and not a Percentage of the screen (Basically, It was there, but outside of the screen limits) Edited May 29, 2012 by Guest Link to comment
Smart. Posted May 29, 2012 Share Posted May 29, 2012 Its probably because you haven't calculated the position of the dxtext/images. Are you guys on the same resolution? (OBS! I haven't tested/looked through the whole code as I'm too lazy, monkey ) 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