AlexWo Posted August 20, 2012 Share Posted August 20, 2012 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 Link to comment
Guest Guest4401 Posted August 20, 2012 Share Posted August 20, 2012 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
AlexWo Posted August 20, 2012 Author Share Posted August 20, 2012 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
Guest Guest4401 Posted August 20, 2012 Share Posted August 20, 2012 You should add this: addEventHandler("onClientGUIClick",root,onClientGUIClick) Clientside Link to comment
AlexWo Posted August 20, 2012 Author Share Posted August 20, 2012 And where exactly, in which line? Link to comment
Thelastride Posted August 20, 2012 Share Posted August 20, 2012 And where exactly, in which line? just add in client side anywhere, first line will be cool Link to comment
AlexWo Posted August 20, 2012 Author Share Posted August 20, 2012 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
Guest Guest4401 Posted August 20, 2012 Share Posted August 20, 2012 Use localPlayer instead of source in line 17. Link to comment
TAPL Posted August 20, 2012 Share Posted August 20, 2012 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
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