DRW Posted April 9, 2015 Share Posted April 9, 2015 Hello. Sorry for bothering you, but I have a problem and if you could give me some help it would be awesome, I just started scripting yesterday. So, I'm trying to create a serverside marker, so when the player hits the marker, a GUI with two buttons will appear only for him, then when the player clicks "Yes", it'll be warped to an area, if the player clicks "No", the GUI will close. I don't want a script, just a a small example to give me a boost. Link to comment
Mr.unpredictable. Posted April 9, 2015 Share Posted April 9, 2015 You will need these set of functions do to that to create gui It's better you use R3mp's gui editor You will need these set of functions do to do what you want. createMarker onMarkerHit triggerClientEvent setElementPosition client Create gui using r3mp's editor onClientGUIClick triggerServerEvent this just an idea on how you can do. Link to comment
DRW Posted April 9, 2015 Author Share Posted April 9, 2015 Could you give me an example of triggerclientevent and triggerserverevent? Link to comment
Addlibs Posted April 9, 2015 Share Posted April 9, 2015 Example usage: Server: --onMarketHit (serverside): triggerClientEvent(source, "teleport openGUIpanel", source) --trigger client side event that opens up the GUI addEvent("teleport teleportMe", true) --register event and make it remotely trigger-able (so the client can trigger it server side with a response) addEventHandler("teleport teleportMe", root, function() --warp end) Client: addEvent("teleport openGUIpanel", true) --register event and make it remotely trigger-able (so the server can trigger it client side) addEventHandler("teleport openGUIpanel", localPlayer, function() guiSetVisible(guiWindow, true) --open the GUI end) --onClientGUIClick (clientside): guiSetVisible(guiWindow, false) --hide the GUI if source==acceptBtn then triggerServerEvent("teleport teleportMe", localPlayer) --send a response end --don't sent any response if No button was clicked. Just hide the GUI Link to comment
DRW Posted April 10, 2015 Author Share Posted April 10, 2015 (edited) Example usage:Server: --onMarketHit (serverside): triggerClientEvent(source, "teleport openGUIpanel", source) --trigger client side event that opens up the GUI addEvent("teleport teleportMe", true) --register event and make it remotely trigger-able (so the client can trigger it server side with a response) addEventHandler("teleport teleportMe", root, function() --warp end) Client: addEvent("teleport openGUIpanel", true) --register event and make it remotely trigger-able (so the server can trigger it client side) addEventHandler("teleport openGUIpanel", localPlayer, function() guiSetVisible(guiWindow, true) --open the GUI end) --onClientGUIClick (clientside): guiSetVisible(guiWindow, false) --hide the GUI if source==acceptBtn then triggerServerEvent("teleport teleportMe", localPlayer) --send a response end --don't sent any response if No button was clicked. Just hide the GUI I've been trying to make the GUI window appear only for the player when it hits a server-sided marker and not on script start, but it's not working. Could you tell me how to make the GUI window appear only when the player hits the marker and not when the script starts? Server Marker1 = createMarker (-454,2604, 65,"cylinder",2.0,100,255,150,255) addEventHandler("onMarkerHit", Marker1, function() triggerClientEvent (source, "guiVentana", source) end) Client addEvent ("guiventana", true) addEventHandler ("guiventana", localPlayer, function() guiSetVisible (VentanaGUI, true) end) VentanaGUI = guiCreateWindow(258, 212, 312, 211, "Misión: Área Restringida", false) guiWindowSetSizable(VentanaGUI, false) GUIMemo = guiCreateMemo(9, 22, 293, 137, "¿¡Lo has oído!? ¡Un soldado del Área Restringida militar se ha instalado en nuestra comunidad, y dice que ahí hay antídotos suficientes para nuestros ciudadanos! El problema es que dice que por muy poco casi ni sale vivo de ahí, está lleno de esos cadáveres caminantes. ¡Eh! A ti te he visto luchar muy bien ahí fuera. Si entras y consigues lo nuestro, te pagaremos lo debido.", false, VentanaGUI) boton1 = guiCreateButton(20, 166, 129, 35, "¡Vamos!", false, VentanaGUI) guiSetFont(boton1, "sa-header") guiSetProperty(boton1, "NormalTextColour", "FF1AF303") boton2 = guiCreateButton(161, 166, 131, 35, "No quiero morir.", false, VentanaGUI) guiSetProperty(boton2, "NormalTextColour", "FFF50000") addEventHandler ("onClientGUIClick",boton2, function() guiSetVisible(VentanaGUI, false) end) addEventHandler ("onClientGUIClick",boton1, function() setElementPosition (getLocalPlayer(),213,1872,12.-- s8) --> guiSetVisible(VentanaGUI, false) end) EDIT: I solved it, thanks Edited April 10, 2015 by Guest Link to comment
Mr.unpredictable. Posted April 10, 2015 Share Posted April 10, 2015 Example usage:Server: --onMarketHit (serverside): triggerClientEvent(source, "teleport openGUIpanel", source) --trigger client side event that opens up the GUI addEvent("teleport teleportMe", true) --register event and make it remotely trigger-able (so the client can trigger it server side with a response) addEventHandler("teleport teleportMe", root, function() --warp end) Client: addEvent("teleport openGUIpanel", true) --register event and make it remotely trigger-able (so the server can trigger it client side) addEventHandler("teleport openGUIpanel", localPlayer, function() guiSetVisible(guiWindow, true) --open the GUI end) --onClientGUIClick (clientside): guiSetVisible(guiWindow, false) --hide the GUI if source==acceptBtn then triggerServerEvent("teleport teleportMe", localPlayer) --send a response end --don't sent any response if No button was clicked. Just hide the GUI I've been trying to make the GUI window appear when you hit a client-sided marker and not on script start, but it's not working. Could you tell me how to make the GUI window appear only when the player hits the marker and not when the script starts? guiSetVisible make guiSetVisible false for onresourcestart and true for on marker hit. Link to comment
ALw7sH Posted April 10, 2015 Share Posted April 10, 2015 when you create the window hide it with guiSetVisible then use onClientMarkerHit and show the window with guiSetVisible Link to comment
DRW Posted April 10, 2015 Author Share Posted April 10, 2015 Yeah it worked, I took a look at other scripts related to the one I wanted to make and I've corrected some things, now it works! Now there is another problem, I added a function per button, the first warps the player to a zone, the other one closes the GUI. That's what I wanted to do, but now the problem is that if I click any other part of the GUI, for example the GUI window, it warps me, without even clicking the button. rRoot = getResourceRootElement(getThisResource()) addEventHandler("onClientResourceStart",rRoot,function() guiSetVisible(VentanaGUI,false) end) function verventana() guiSetVisible(VentanaGUI, true) showCursor(true) guiBringToFront(VentanaGUI) end addEvent ("verventana", true) addEventHandler ("verventana", root, verventana) VentanaGUI = guiCreateWindow(258, 212, 312, 211, "Misión: Área Restringida", false) guiWindowSetSizable(VentanaGUI, false) GUIMemo = guiCreateMemo(9, 22, 293, 137, "¿¡Lo has oído!? ¡Un soldado del Área Restringida militar se ha instalado en nuestra comunidad, y dice que ahí hay antídotos suficientes para nuestros ciudadanos! El problema es que dice que por muy poco casi ni sale vivo de ahí, está lleno de esos cadáveres caminantes. ¡Eh! A ti te he visto luchar muy bien ahí fuera. Si entras y consigues lo nuestro, te pagaremos lo debido.", false, VentanaGUI) boton1 = guiCreateButton(20, 166, 129, 35, "¡Vamos!", false, VentanaGUI) guiSetFont(boton1, "sa-header") guiSetProperty(boton1, "NormalTextColour", "FF1AF303") boton2 = guiCreateButton(161, 166, 131, 35, "No quiero morir.", false, VentanaGUI) guiSetProperty(boton2, "NormalTextColour", "FFF50000") addEventHandler ("onClientGUIClick",boton2, function() showCursor(false) guiSetVisible(VentanaGUI, false) end) addEventHandler ("onClientGUIClick",boton1, function() setElementPosition (getLocalPlayer(),213,1872,12.-- s8) --> showCursor(false) guiSetVisible(VentanaGUI, false) end) Link to comment
ALw7sH Posted April 10, 2015 Share Posted April 10, 2015 addEventHandler ("onClientGUIClick",root, function() if source == boton2 then showCursor(false) guiSetVisible(VentanaGUI, false) elseif source == boton1 then setElementPosition (getLocalPlayer(),213,1872,12) showCursor(false) guiSetVisible(VentanaGUI, false) end 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