Viudes Posted July 30, 2017 Share Posted July 30, 2017 (edited) i want only player who hit marker open this gui windows how i can made check? function toggleGUI (localPlayer) bool = not bool showCursor(bool) guiSetVisible(Base,bool) end Edited July 30, 2017 by Viudes I NEED Link to comment
Zorgman Posted July 30, 2017 Share Posted July 30, 2017 Use onMarkerHit. The element that hit the marker is the first parameter. Check if it's a player before firing up the gui. Link to comment
Viudes Posted July 30, 2017 Author Share Posted July 30, 2017 (edited) 47 minutes ago, Zorgman said: Use onMarkerHit. The element that hit the marker is the first parameter. Check if it's a player before firing up the gui. function toggleGUI (localPlayer, hitElement) if getElementType (hitElement) == "player" then bool = not bool showCursor(bool) guiSetVisible(Base,bool) end end Why that not work EDIT: Give warning getElementType Edited July 30, 2017 by Viudes Link to comment
Zorgman Posted July 30, 2017 Share Posted July 30, 2017 function toggleGUI (hitElement, dim) if getElementType (hitElement) == "player" then outputChatBox("function triggered") -- a simple check so you know it worked bool = not bool showCursor(bool) guiSetVisible(Base,bool) end addEventHandler( "onMarkerHit", resourceRoot, toggleGUI ) --[[note that: 1.you will need to replace resourceRoot with your actual marker element, otherwise function will trigger for all markers 2.this need to be server-side 3.it's untested ]] Link to comment
Viudes Posted July 30, 2017 Author Share Posted July 30, 2017 7 minutes ago, Zorgman said: function toggleGUI (hitElement, dim) if getElementType (hitElement) == "player" then outputChatBox("function triggered") -- a simple check so you know it worked bool = not bool showCursor(bool) guiSetVisible(Base,bool) end addEventHandler( "onMarkerHit", resourceRoot, toggleGUI ) --[[note that: 1.you will need to replace resourceRoot with your actual marker element, otherwise function will trigger for all markers 2.this need to be server-side 3.it's untested ]] Yeah that work but is still trigger all player.. Link to comment
Zorgman Posted July 30, 2017 Share Posted July 30, 2017 Well, looking at it again I'm surprised you say it works, since guiSetVisible is client-sided. Okay, what you need to do is trigger an event and send it only to the hitElement, telling it to fire up the gui. if getElementType (hitElement) == "player" then triggerClientEvent(hitElement,"YourEventName",root) end Don't forget to add your event clientside and put the gui part there. Link to comment
Tails Posted July 30, 2017 Share Posted July 30, 2017 (edited) No just add if hitElement == localPlayer then instead of if getElementType (hitElement) == "player" then also, it's onClientMarkerHit for the client side. Edited July 30, 2017 by Tails 1 Link to comment
Viudes Posted July 30, 2017 Author Share Posted July 30, 2017 1 hour ago, Zorgman said: Well, looking at it again I'm surprised you say it works, since guiSetVisible is client-sided. Okay, what you need to do is trigger an event and send it only to the hitElement, telling it to fire up the gui. if getElementType (hitElement) == "player" then triggerClientEvent(hitElement,"YourEventName",root) end Don't forget to add your event clientside and put the gui part there. Now this work! thx! Link to comment
Zorgman Posted July 30, 2017 Share Posted July 30, 2017 You're welcome! However, if you didn't do so already, you should move everything clientside as Tails suggested, it will work more smoothly this way. 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