Oekeokiki Posted December 29, 2009 Share Posted December 29, 2009 Dear members of the MTA Sa Forum, I have a new problem. If i start this script when i am in the server, i see the GUI and i can't click anything, after that i need to reconnect because of this script. The marker doesn't work but i can luckly see it. I think that there is a problem with guiSetVisible. Can someone help me? Thanks in advance, Oekeokiki Client: local trainsf = createMarker( -1959, 138, 28, 'cylinder', 2.0, 255, 0, 0, 150 ) function weedspeedtrains () GUIEditor_Button = {} GUIEditor_Label = {} Weedspeed_Trains = guiCreateWindow(307,256,418,282,"Weedspeed Trains",false) GUIEditor_Label[1] = guiCreateLabel(0.1124,0.117,0.8062,0.2057,"Welcome at WeedSpeed Trains, where do you want to go?",true,Weedspeed_Trains) guiLabelSetColor(GUIEditor_Label[1],255,255,255) guiLabelSetVerticalAlign(GUIEditor_Label[1],"top") guiLabelSetHorizontalAlign(GUIEditor_Label[1],"left",false) lossantosmarket = guiCreateButton(0.0622,0.3227,0.3038,0.1773,"Los Santos Market",true,Weedspeed_Trains) GUIEditor_Button[2] = guiCreateButton(0.5694,0.3227,0.3038,0.1773,"Los Santos Little Mexico",true,Weedspeed_Trains) GUIEditor_Button[3] = guiCreateButton(0.0646,0.5532,0.3038,0.1773,"San Fierro",true,Weedspeed_Trains) GUIEditor_Button[4] = guiCreateButton(0.3254,0.7695,0.3038,0.1773,"Las Venturas East",true,Weedspeed_Trains) GUIEditor_Button[5] = guiCreateButton(0.5718,0.5532,0.3038,0.1773,"Las Venturas North",true,Weedspeed_Trains) guiSetVisible(Weedspeed_Trains, false) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function () weedspeedtrains() if (Weedspeed_Trains ~= nil) then guiSetVisible(Weedspeed_Trains, true) end showCursor(true) guiSetInputEnabled(true) end ) function lossantosmarketgo(button) if button == "left" then triggerServerEvent("warplsmarket", getRootElement() ) guiSetVisible(Weedspeed_Trains, false) showCursor(false) end end addEventHandler("onClientGUIClick", lossantosmarket, lossantosmarketgo, false) addEventHandler( "onMarkerHit", trainsf, weedspeedtrains ) Server: function spawnlsmarket(client) local x,y,z x = 1738 y = -1949 z = 15 if (client) then spawnPlayer(client, x, y, z) fadeCamera(client, true) end end addEvent("warplsmarket", true) addEventHandler("warplsmarket", getRootElement(), spawnlsmarket) Link to comment
50p Posted December 29, 2009 Share Posted December 29, 2009 Why can't you click anything? Can't you see a cursor that you're showing or buttons are not click-able? You want to use guiBringToFront to make it top most window (make it the first GUI element at "Z axis"). DO NOT use client as a parameter for your function attached to an event that is triggered from client-side script simply because client is another hidden variable (just like source) that is passed to function calls every time client triggers a server-side event and this variable points to the player that triggered the specific event. Just remove the client parameter for spawnlsmarket function. You don't need this for another reason: you don't even pass any arguments when you triggerServerEvent. Link to comment
Remp Posted December 29, 2009 Share Posted December 29, 2009 move your onClientGUIClick event handler into your weedspeedtrains function. currently you are trying to add the event when the button doesnt actually exist (when the script is loaded), so it wont attach and consequently button clicks wont trigger this will also cause some issues: addEventHandler( "onMarkerHit", trainsf, weedspeedtrains ) currently that will recreate the gui every time you step into the marker (ie: if you step into the marker twice, you will have 2 guis and so on) you may want to change it so it only makes the gui visible instead Link to comment
50p Posted December 29, 2009 Share Posted December 29, 2009 ...this will also cause some issues: addEventHandler( "onMarkerHit", trainsf, weedspeedtrains ) currently that will recreate the gui every time you step into the marker (ie: if you step into the marker twice, you will have 2 guis and so on) you may want to change it so it only makes the gui visible instead No, this will not cause any issues since there is no "onMarkerHit" client-side event. Link to comment
Oekeokiki Posted December 30, 2009 Author Share Posted December 30, 2009 sorry that i was away. I can see the cursor but i can't click on anything. I will try the solutions and will update this post. 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