Jump to content

Help with my Server Gui


AlexWo

Recommended Posts

Hi, I have a problem with my ServerGui.

I want that if a player press the button "LS" he got teleported to a place in LS.

If I press the button its not working :(

Client-Side:

local screenX, screenY = guiGetScreenSize() 
local width, height = 400, 400 
local x = (screenX/2) - (width/2) 
local y = (screenY/2) - (height/2) 
  
theWindow = guiCreateWindow(x,y,width,height,"Info-Box",false) 
guiWindowSetSizable(theWindow,false) 
guiSetVisible (theWindow, false) 
memo1 = guiCreateMemo (0.15,0.2,0.7,0.5,"Welcome on GlobalGaming",true,theWindow) 
 help_window_main_button_decline = guiCreateButton(0.15,0.5,0.2,0.2,"LS",true,theWindow) 
  
function onClientGUIClick() 
   if source == help_window_main_button_decline then 
        triggerServerEvent ("TeleportLS",getLocalPlayer()) 
        end 
    end 
     
  
 function resourceStart () 
  bindKey ("F1", "down", menuShow) 
end 
addEventHandler ("onClientResourceStart", getResourceRootElement ( getThisResource () ), resourceStart) 
  
  
function menuShow () 
    visableornot = guiGetVisible (theWindow) 
    if (visableornot == true) then 
        guiSetVisible (theWindow, false) 
        showCursor (false) 
    end 
    if (visableornot == false) then 
        guiSetVisible (theWindow, true) 
        showCursor (true) 
    end 
end 
  
  

Server-Side:

addEvent("TeleportLS", true) 
addEventHandler("TeleportLS", root, 
function() 
      getElementPosition(LocalPlayer) 
        setElementPosition(LocalPlayer,1187, -1323, 15) 
end 
) 
  

Maybe I've done something wrong.

It would be cool if you could help me :D

Link to comment
Guest Guest4401

You forgot addEventHandler. Add this line:

addEventHandler("onClientGUIClick",root,onClientGUIClick) 

Also, you should be using source instead of LocalPlayer serverside. Actually, you don't even need to trigger serverside because setElementPosition can be used clientside.

Link to comment

Fail.... Can't get it runned....

I changed it now to this:

Client:

local screenX, screenY = guiGetScreenSize() 
local width, height = 400, 400 
local x = (screenX/2) - (width/2) 
local y = (screenY/2) - (height/2) 
  
theWindow = guiCreateWindow(x,y,width,height,"Info-Box",false) 
guiWindowSetSizable(theWindow,false) 
guiSetVisible (theWindow, false) 
memo1 = guiCreateMemo (0.15,0.2,0.7,0.5,"Welcome on GlobalGaming",true,theWindow) 
 help_window_main_button_decline = guiCreateButton(0.15,0.5,0.2,0.2,"LS",true,theWindow) 
  
     
function onClientGUIClick() 
   if source == help_window_main_button_decline then 
       triggerServerEvent(TeleportLS) 
        end 
    end 
  
 function resourceStart () 
  bindKey ("F1", "down", menuShow) 
end 
addEventHandler ("onClientResourceStart", getResourceRootElement ( getThisResource () ), resourceStart) 
  
  
function menuShow () 
    visableornot = guiGetVisible (theWindow) 
    if (visableornot == true) then 
        guiSetVisible (theWindow, false) 
        showCursor (false) 
    end 
    if (visableornot == false) then 
        guiSetVisible (theWindow, true) 
        showCursor (true) 
    end 
end 
  
  

server:

addEvent("TeleportLS", true) 
addEventHandler("onClientGUIClick",root,onClientGUIClick)    
addEventHandler("TeleportLS", root, 
function() 
      getElementPosition(source) 
        setElementPosition(source, 1187, -1323, 15) 
end 
) 
  

PS: Sry I'm just started with scripting.

Link to comment

I changed it now that I have only the Client side.

But it's not working ....

Client Side:

addEventHandler("onClientGUIClick",root,onClientGUIClick) 
  
local screenX, screenY = guiGetScreenSize() 
local width, height = 400, 400 
local x = (screenX/2) - (width/2) 
local y = (screenY/2) - (height/2) 
  
theWindow = guiCreateWindow(x,y,width,height,"Info-Box",false) 
guiWindowSetSizable(theWindow,false) 
guiSetVisible (theWindow, false) 
memo1 = guiCreateMemo (0.15,0.15,0.7,0.5,"Welcome on GlobalGaming",true,theWindow) 
 help_window_main_button_decline = guiCreateButton(0.15,0.5,0.2,0.2,"LS",true,theWindow) 
  
  
function onClientGUIClick() 
   if source == help_window_main_button_decline then 
       setElementPosition(source, 1187, -1323, 15) 
        end 
    end 
    addEventHandler("onClientGUIClick",root,onClientGUIClick) 
  
  
 function resourceStart () 
  bindKey ("F1", "down", menuShow) 
end 
addEventHandler ("onClientResourceStart", getResourceRootElement ( getThisResource () ), resourceStart) 
  
  
function menuShow () 
    visableornot = guiGetVisible (theWindow) 
    if (visableornot == true) then 
        guiSetVisible (theWindow, false) 
        showCursor (false) 
    end 
    if (visableornot == false) then 
        guiSetVisible (theWindow, true) 
        showCursor (true) 
    end 
end 
  
  

Link to comment
  • Other Languages Moderators
local screenX, screenY = guiGetScreenSize() 
local width, height = 400, 400 
local x = (screenX/2) - (width/2) 
local y = (screenY/2) - (height/2) 
  
theWindow = guiCreateWindow(x,y,width,height,"Info-Box",false) 
guiWindowSetSizable(theWindow,false) 
guiSetVisible(theWindow, false) 
memo1 = guiCreateMemo (0.15,0.15,0.7,0.5,"Welcome on GlobalGaming",true,theWindow) 
help_window_main_button_decline = guiCreateButton(0.15,0.5,0.2,0.2,"LS",true,theWindow) 
  
function onClientGUIClick() 
     if source == help_window_main_button_decline then 
          setElementPosition(localPlayer, 1187, -1323, 15) 
     end 
end 
addEventHandler("onClientGUIClick",root,onClientGUIClick) 
  
function menuShow () 
     guiSetVisible (theWindow, not guiGetVisible(theWindow)) 
     showCursor(guiGetVisible(theWindow)) 
end 
bindKey("F1", "down", menuShow) 

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...