Visma Posted February 16, 2015 Posted February 16, 2015 The buttons do not work Client GUIEditor = { button = {}, window = {}, label = {} } function createLSTeleportGUI() GUIEditor.window[1] = guiCreateWindow(834, 424, 254, 111, "", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.label[1] = guiCreateLabel(29, 21, 192, 24, "Teleport to LS?", false, GUIEditor.window[1]) guiLabelSetHorizontalAlign(GUIEditor.label[1], "center", false) GUIEditor.button[1] = guiCreateButton(18, 57, 104, 33, "Yes", false, GUIEditor.window[1]) GUIEditor.button[2] = guiCreateButton(134, 57, 104, 33, "No", false, GUIEditor.window[1]) guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FFAAAAAA") guiSetVisible(GUIEditor.window[1],false) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function () createLSTeleportGUI() end ) function openLSTeleportGUI() guiSetVisible(GUIEditor.window[1],true) showCursor(true,true) end addCommandHandler("teleportme",openLSTeleportGUI) addEventHandler("onClientGUIClick", GUIEditor.button[1], teleportPlayer, false) addEventHandler("onClientGUIClick", GUIEditor.button[2], openLSTeleportGUI, false) function teleportPlayer(button,state) if button == "left" and state == "up" then triggerServerEvent("movePlayerToPosition",getLocalPlayer(),1917.7863769531,-2411.640625,13.53911781311) outputChatBox("You have teleported to LS. Use /teleport to go back.") guiSetVisible(GUIEditor.window[1], false) showCursor(false) end end function openLSTeleportGUI(button,state) if button == "left" and state == "up" then guiSetVisible(GUIEditor.window[1], false) showCursor(false) end end Server function moveThePlayer(x,y,z,rotation) if x and y and z and rotation then local skin = getElementModel(client) spawnPlayer(client,x,y,z,rotation,skin) setCameraTarget(client,client) end end addEvent("movePlayerToPosition",true) addEventHandler("movePlayerToPosition",root,moveThePlayer) Just when the caterpillar thought the world was ending, he turned into a butterfly
n3wage Posted February 16, 2015 Posted February 16, 2015 This: addEventHandler("onClientGUIClick", GUIEditor.button[1], teleportPlayer, false) addEventHandler("onClientGUIClick", GUIEditor.button[2], openLSTeleportGUI, false) Should be inside the createLSTeleportGUI function. function createLSTeleportGUI() GUIEditor.window[1] = guiCreateWindow(834, 424, 254, 111, "", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.label[1] = guiCreateLabel(29, 21, 192, 24, "Teleport to LS?", false, GUIEditor.window[1]) guiLabelSetHorizontalAlign(GUIEditor.label[1], "center", false) GUIEditor.button[1] = guiCreateButton(18, 57, 104, 33, "Yes", false, GUIEditor.window[1]) GUIEditor.button[2] = guiCreateButton(134, 57, 104, 33, "No", false, GUIEditor.window[1]) guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FFAAAAAA") guiSetVisible(GUIEditor.window[1],false) addEventHandler("onClientGUIClick", GUIEditor.button[1], teleportPlayer, false) addEventHandler("onClientGUIClick", GUIEditor.button[2], openLSTeleportGUI, false) end
JR10 Posted February 16, 2015 Posted February 16, 2015 It doesn't have to be inside the create gui function. The only reason it doesn't work is that it's executed before the functions are even declared. Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
Visma Posted February 16, 2015 Author Posted February 16, 2015 I done that, now I click the buttons the gui closes but nothing happens Just when the caterpillar thought the world was ending, he turned into a butterfly
JR10 Posted February 16, 2015 Posted February 16, 2015 A possible cause is that you never send the rotation argument. You only send the 3 coordinates, so the check in moveThePlayer always returns false. Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
Visma Posted February 17, 2015 Author Posted February 17, 2015 Okay Solved Just when the caterpillar thought the world was ending, he turned into a butterfly
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