Machine Posted February 16, 2019 Share Posted February 16, 2019 can someone pls tell me what is wrong here Client Side- GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Label = {} GUIEditor_Window[1] = guiCreateWindow(0.3875,0.300,0.50,0.6117,"Elevator",true) guiWindowSetMovable(GUIEditor_Window[1],false) GUIEditor_Button[1] = guiCreateButton(15,50,400,50,"Ground floor",false,GUIEditor_Window[1]) GUIEditor_Button[2] = guiCreateButton(14,111,400,50,"Roof floor",false,GUIEditor_Window[1]) guiLabelSetColor(GUIEditor_Label[1],255,255,0) guiSetFont(GUIEditor_Label[1],"default-bold-small") GUIEditor_Button[4] = guiCreateButton(17,313,450,41,"Exit",false,GUIEditor_Window[1]) guiSetVisible(GUIEditor_Window[1], false) showCursor(false) local marker = createMarker(270.79998779297, 1879, 16.60000038147, "cylinder", 1.5, 255,0,0,70) function markerhit (hitPlayer) if ( hitPlayer == localPlayer ) then guiSetVisible (GUIEditor_Window[1], true) guiSetEnabled(GUIEditor_Button[1],true) guiSetEnabled(GUIEditor_Button[2],true) guiSetEnabled(GUIEditor_Button[3],true) guiSetEnabled(GUIEditor_Button[4],true) showCursor (true) end end addEventHandler ("onClientMarkerHit", marker, markerhit) function markerLeave () guiSetVisible (GUIEditor_Window[1], false) showCursor (false) end addEventHandler ("onClientMarkerLeave", marker, markerLeave) addEventHandler("onClientGUIClick", root, function ( ) if ( source == GUIEditor_Button[1] ) then triggerServerEvent ( "qd", getLocalPlayer() ) elseif ( source == GUIEditor_Button[2] ) then triggerServerEvent ( "qd2", getLocalPlayer() ) elseif ( source == GUIEditor_Button[3] ) then triggerServerEvent ( "qd4", getLocalPlayer() ) elseif ( source == GUIEditor_Button[4] ) then guiSetVisible ( GUIEditor_Window[1], false ) showCursor ( false ) end end ) Server Side-- function qm ( ) elevatordoor = createObject ( 2634, 267.70001, 1880, 18, 0, 0, 270 ) function VehicleHit(hitElement,matchingDimension) if getElementType(hitElement)=="player" then moveObject ( elevatordoor, 3000, -2017, 158.79998779297, 20.39999961853 ) end end else outputChatBox ( "Step inside the elevator", source ) end end end setTimer ( VehicleHit, 1000, 1 ) addEvent( "qd", true ) addEventHandler( "onMarkerHit", getRootElement(), qm ) i am trying to make an elevator that work with the gui Link to comment
Addlibs Posted February 16, 2019 Share Posted February 16, 2019 A lot of issues in the serverside code. VehicleHit is a function defined within a function, which, while legal, doesn't make sense unless you're making a local function. VehicleHit is called by a timer started outside the qm function, meaning that qm must be called (via hitting a marker) within 1000 ms of starting the serverside code. Additionally, the timer does not send over any special parameters but your VehicleHit function expects a hitElement parameter and checks that it's a player element. You're sending a nil. qd event is only declared but never actually used. qd2 and qd4 aren't even declared on the serverside. Link to comment
Machine Posted February 16, 2019 Author Share Posted February 16, 2019 problem is which function should i use in order that when the client hit the button on gui it should trigger server side to move the object and qd2 is the floor roof but i didnt write it yet cuz i wanna solve the qd first and qd4 is just to close the gui can u tell me what is the right way to write serverside ? Link to comment
Peti Posted February 16, 2019 Share Posted February 16, 2019 (edited) Serverside code is kinda messy, yes. addEvent( "qd", true ) addEventHandler( "qd", root, function() elevatordoor = createObject ( 2634, 267.70001, 1880, 18, 0, 0, 270 ) moveObject ( elevatordoor, 3000, -2017, 158.79998779297, 20.39999961853 ) end, true) That should work. You can't use marker functions without markers. Your markers are on client, so you have to use them there. Edited February 16, 2019 by Peti 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