Jump to content

Teleport Gui buttons do not work


Visma

Recommended Posts

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) 
  

Link to comment

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 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...