Gordon_G Posted August 21, 2016 Share Posted August 21, 2016 (edited) Ok, so ... I will try to explain everything correctly. I try to make a GUI visible by a server script and ... For some reason does that I don't know for the moment everyone see this GUI ... But I just wanna that the source of the server side can see the GUI. You understand ? --Server function seegui(source) triggerClientEvent("achatarmesgui",root, source) end addCommandHandler("seegui", seegui) --Client prixarmes = { neufmm = {1500,22}, tecneuf = {4000,30}, deagle = {3000,24}, ak = {7000,32}, shotgun = {5500,25}, } local screenW, screenH = guiGetScreenSize() achatarmess = guiCreateWindow((screenW - 608) / 2, (screenH - 347) / 2, 608, 347, "Achat armes", false) guiWindowSetSizable(achatarmess, false) guiSetVisible ( achatarmess, false ) eaglei = guiCreateStaticImage(10, 171, 95, 95, "deserteagle.png", false, achatarmess) neufi = guiCreateStaticImage(10, 48, 95, 95, "9mm.png", false, achatarmess) teci = guiCreateStaticImage(142, 52, 95, 95, "tec9.png", false, achatarmess) shotguni = guiCreateStaticImage(261, 52, 95, 95, "shotgun.png", false, achatarmess) aki = guiCreateStaticImage(405, 56, 95, 95, "ak47.png", false, achatarmess) achatarmeslabel1 = guiCreateLabel(20, 143, 75, 17, prixarmes.neufmm[1], false, achatarmess) achatarmeslabel2 = guiCreateLabel(152, 143, 75, 17, prixarmes.tecneuf[1], false, achatarmess) achatarmeslabel3 = guiCreateLabel(20, 276, 75, 17, prixarmes.deagle[1], false, achatarmess) achatarmeslabel4 = guiCreateLabel(271, 143, 75, 17, prixarmes.shotgun[1], false, achatarmess) achatarmeslabel5 = guiCreateLabel(419, 143, 75, 17, prixarmes.ak[1], false, achatarmess) buttonclose = guiCreateButton(569, 23, 29, 25, "X", false, achatarmess) addEvent("achatarmesgui", true) function achatarmes() guiSetVisible(achatarmess, true) showCursor(true,true) end addEventHandler("achatarmesgui", root,achatarmes) So ... Could someone explain me ? Please Edited August 21, 2016 by Guest Link to comment
StefanAlmighty Posted August 21, 2016 Share Posted August 21, 2016 When you trigger the event, by triggering it to 'root' you trigger it to every element in the game. This is why everybody is seeing it and it may also cause lag. Also when you add the event handler you also put 'root'. Basically what I am saying is by using 'root' that triggers it for everyone. Instead of 'root', try using 'source' in serverside and getLocalPlayer() clientside. This should prevent everybody seeing your GUI and only the person who types /seegui will see it. You're welcome. Link to comment
Gordon_G Posted August 21, 2016 Author Share Posted August 21, 2016 Thanks a lot ! I'll immediatly try that Link to comment
StefanAlmighty Posted August 21, 2016 Share Posted August 21, 2016 Also I advise taking a look here: https://wiki.multitheftauto.com/wiki/Element_tree It will give you more of an understanding about using elements in the element tree. Link to comment
Gordon_G Posted August 21, 2016 Author Share Posted August 21, 2016 That's work ! And, I learnt to script myself so I don't now everything yet. I am scripting a gamemode and, you helped me a lot triggerClientEvent("achatarmesgui", source) addEventHandler("achatarmesgui", getLocalPlayer(),achatarmes) 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