toptional Posted November 15, 2012 Share Posted November 15, 2012 Got another problem My problem is when you enter the marker the GUI shows but clicking the button doesnt take you to the place set spawnmarker = createMarker ( 1969.9000244141, -1517.8000488281, 970.79998779297 , "cylinder", 2, 9, 30, 213, 255 ) GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Label = {} addEventHandler ( "onClientResourceStart", resourceRoot, function ( ) GUIEditor_Window[2] = guiCreateWindow(147,141,749,548,"The Aviator Spawn Panel by Robbster",false) guiSetVisible ( GUIEditor_Window[2], false ) GUIEditor_Memo[2] = guiCreateMemo(80,56,627,302,'Welcome to to the Aviators Airline Gamemode!t\n\n-----\nINFO\nINFO \nINFO\nINFO\n-------\n\nHere are the ranks\n\nA student pilot is 0 points : These can fly everything except the Andromada, AT-400, military planes and military helicopters (hydra/hunter)\n\nA Private pilot is 150 points : These can fly everything except the Andromada and AT-400, and military planes and helicopters (hydra/hunter) and flying with the shamal will be x1.5 the amount of money a student pilot earns\n\nA Commercial pilot is 250 points : These can fly everything except the military planes and helicopters (hydra/hunter)\n\nArmy pilots is 500 points : These can fly everything\nIn an airline, all airplanes of the airline can be used not matter what \"level\" you are.',false,GUIEditor_Window[2]) GUIEditor_Label[2] = guiCreateLabel(270,398,94,46,"",false,GUIEditor_Window[2]) GUIEditor_Button[2] = guiCreateButton(280,401,194,92,"Lets get to Work Pilot!",false,GUIEditor_Window[2]) end ) function MarkerHit ( hitPlayer, matchingDimension ) if ( hitPlayer == localPlayer ) then guiSetVisible ( GUIEditor_Window[2], true ) showCursor ( true ) end end addEventHandler ( "onClientMarkerHit", spawnmarker, MarkerHit ) addEventHandler ( 'onClientGUIClick', GUIEditor_Button[2], function ( ) setElementPosition ( localPlayer, 1679.3029785156, 1446.3712158203, 11.043098449707 ) setCameraTarget ( localPlayer ) fadeCamera ( true ) guiSetVisible ( GUIEditor_Window[2], false ) --shows GUI showCursor ( false ) --shows cursor end ,false ) Link to comment
Anderl Posted November 15, 2012 Share Posted November 15, 2012 I guess you need GUI element declaration outside of the event to use them in addEventHandler. I'm not using MTA/playing around with Lua in MTA anymore so maybe I'm wrong, but why not try. Btw, fadeCamera is not needed with setElementPosition since it already does that. I guess setCameraTarget is also not needed. Check for debug errors also. Link to comment
Scooby Posted November 16, 2012 Share Posted November 16, 2012 yeah the addEventHandler for GUIEditor_Button[2] needs to be in the same function where u create the button. Link to comment
myonlake Posted November 16, 2012 Share Posted November 16, 2012 Try this. A lot less lines and unnecessary stuff and should work, can't see why it wouldn't. Client-side local spawnmarker = createMarker(1969.9000244141, -1517.8000488281, 970.79998779297 , "cylinder", 2, 9, 30, 213, 255) addEventHandler("onClientMarkerHit", spawnmarker, function(hitElement, matchingDimension) if getElementType(hitElement) == "player" and matchingDimension then if not isElement(GUIEditor_Window[2]) then GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Label = {} GUIEditor_Window[2] = guiCreateWindow(147, 141, 749, 548, "The Aviator Spawn Panel by Robbster", false) GUIEditor_Memo[2] = guiCreateMemo(80,56,627,302,'Welcome to to the Aviators Airline Gamemode!t\n\n-----\nINFO\nINFO \nINFO\nINFO\n-------\n\nHere are the ranks\n\nA student pilot is 0 points : These can fly everything except the Andromada, AT-400, military planes and military helicopters (hydra/hunter)\n\nA Private pilot is 150 points : These can fly everything except the Andromada and AT-400, and military planes and helicopters (hydra/hunter) and flying with the shamal will be x1.5 the amount of money a student pilot earns\n\nA Commercial pilot is 250 points : These can fly everything except the military planes and helicopters (hydra/hunter)\n\nArmy pilots is 500 points : These can fly everything\nIn an airline, all airplanes of the airline can be used not matter what \"level\" you are.', false, GUIEditor_Window[2]) GUIEditor_Label[2] = guiCreateLabel(270, 398, 94, 46, "", false, GUIEditor_Window[2]) GUIEditor_Button[2] = guiCreateButton(280, 401, 194, 92, "Lets get to Work Pilot!", false, GUIEditor_Window[2]) showCursor(true) addEventHandler("onClientGUIClick", GUIEditor_Button[2], function(hitElement) setElementPosition(hitElement, 1679.3029785156, 1446.3712158203, 11.043098449707) setCameraTarget(hitElement) fadeCamera(true) destroyElement(GUIEditor_Window[2]) showCursor(false) end , false) else guiBringToFront(GUIEditor_Window[2]) end end end ) Link to comment
toptional Posted November 16, 2012 Author Share Posted November 16, 2012 Still doesn't work Link to comment
Baseplate Posted November 16, 2012 Share Posted November 16, 2012 (edited) GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Label = {} mainGUI = guiCreateWindow(147,141,749,548,"The Aviator Spawn Panel by Robbster",false) guiSetVisible ( mainGUI, false ) GUIEditor_Memo[2] = guiCreateMemo(80,56,627,302,'Welcome to to the Aviators Airline Gamemode!t\n\n-----\nINFO\nINFO \nINFO\nINFO\n-------\n\nHere are the ranks\n\nA student pilot is 0 points : These can fly everything except the Andromada, AT-400, military planes and military helicopters (hydra/hunter)\n\nA Private pilot is 150 points : These can fly everything except the Andromada and AT-400, and military planes and helicopters (hydra/hunter) and flying with the shamal will be x1.5 the amount of money a student pilot earns\n\nA Commercial pilot is 250 points : These can fly everything except the military planes and helicopters (hydra/hunter)\n\nArmy pilots is 500 points : These can fly everything\nIn an airline, all airplanes of the airline can be used not matter what \"level\" you are.',false,mainGUI) GUIEditor_Label[2] = guiCreateLabel(270,398,94,46,"",false,mainGUI) pilotButton = guiCreateButton(280,401,194,92,"Lets get to Work Pilot!",false,mainGUI) local localPlayer = getLocalPlayer ( ) local spawnmarker = createMarker ( 1969.9000244141, -1517.8000488281, 970.79998779297 , "cylinder", 2, 9, 30, 213, 255 ) function MarkerHit ( hitPlayer, matchingDimension ) if getElementType(hitElement) == "player" and hitElement == localPlayer then guiSetVisible ( mainGUI, true ) showCursor ( true ) end end addEventHandler ( "onClientMarkerHit", spawnmarker, MarkerHit ) function pilotChange() if (source == pilotButton) then setElementPosition ( localPlayer, 1679.3029785156, 1446.3712158203, 11.043098449707 ) guiSetVisible ( mainGUI, false ) --hides GUI showCursor ( false ) --hides cursor end end addEventHandler("onClientGUIClick", getResourceRootElement(getThisResource()), pilotChange) Edited November 16, 2012 by Guest Link to comment
iPrestege Posted November 16, 2012 Share Posted November 16, 2012 Try : GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Label = {} mainGUI = guiCreateWindow(147,141,749,548,"The Aviator Spawn Panel by Robbster",false) guiSetVisible ( mainGUI, false ) GUIEditor_Memo[2] = guiCreateMemo(80,56,627,302,'Welcome to to the Aviators Airline Gamemode!t\n\n-----\nINFO\nINFO \nINFO\nINFO\n-------\n\nHere are the ranks\n\nA student pilot is 0 points : These can fly everything except the Andromada, AT-400, military planes and military helicopters (hydra/hunter)\n\nA Private pilot is 150 points : These can fly everything except the Andromada and AT-400, and military planes and helicopters (hydra/hunter) and flying with the shamal will be x1.5 the amount of money a student pilot earns\n\nA Commercial pilot is 250 points : These can fly everything except the military planes and helicopters (hydra/hunter)\n\nArmy pilots is 500 points : These can fly everything\nIn an airline, all airplanes of the airline can be used not matter what \"level\" you are.',false,mainGUI) GUIEditor_Label[2] = guiCreateLabel(270,398,94,46,"",false,mainGUI) pilotButton = guiCreateButton(280,401,194,92,"Lets get to Work Pilot!",false,mainGUI) local localPlayer = getLocalPlayer ( ) spawnmarker = createMarker ( 1969.9000244141, -1517.8000488281, 970.79998779297 , "cylinder", 2, 9, 30, 213, 255 ) function MarkerHit ( hitPlayer, matchingDimension ) if ( hitPlayer == localPlayer ) then guiSetVisible ( mainGUI, true ) showCursor ( true ) end end addEventHandler ( "onClientMarkerHit", spawnmarker, MarkerHit ) function pilotChange() if (source == pilotButton) then setElementPosition ( localPlayer,1679.3029785156,1446.3712158203,11.043098449707 ) guiSetVisible ( mainGUI, false ) --hides GUI showCursor ( false ) --hides cursor end end addEventHandler("onClientGUIClick", getResourceRootElement(getThisResource()), pilotChange) Link to comment
Baseplate Posted November 16, 2012 Share Posted November 16, 2012 Just really, wtf have you done, on topic, check back the last code Link to comment
iPrestege Posted November 16, 2012 Share Posted November 16, 2012 Just really, wtf have you done, on topic, check back the last code I think that is wrong in this setElementPosition ( localPlayer,1679.3029785156,1446.3712158203,11.043098449707 ) Because it is where the spaces between the numbers Link to comment
Baseplate Posted November 16, 2012 Share Posted November 16, 2012 Still, that won't make any error or problem. so your post was useless Link to comment
myonlake Posted November 16, 2012 Share Posted November 16, 2012 Tested it myself. Works perfectly. Client-side local spawnmarker = createMarker(1969.9000244141, -1517.8000488281, 970.79998779297, "cylinder", 2, 9, 30, 213, 255) addEventHandler("onClientMarkerHit", spawnmarker, function(hitElement, matchingDimension) if getElementType(hitElement) == "player" and matchingDimension then if not isElement(g_window) then g_window = guiCreateWindow(147, 141, 749, 548, "The Aviator Spawn Panel by Robbster", false) g_memo = guiCreateMemo(80,56,627,302,'Welcome to to the Aviators Airline Gamemode!t\n\n-----\nINFO\nINFO \nINFO\nINFO\n-------\n\nHere are the ranks\n\nA student pilot is 0 points : These can fly everything except the Andromada, AT-400, military planes and military helicopters (hydra/hunter)\n\nA Private pilot is 150 points : These can fly everything except the Andromada and AT-400, and military planes and helicopters (hydra/hunter) and flying with the shamal will be x1.5 the amount of money a student pilot earns\n\nA Commercial pilot is 250 points : These can fly everything except the military planes and helicopters (hydra/hunter)\n\nArmy pilots is 500 points : These can fly everything\nIn an airline, all airplanes of the airline can be used not matter what \"level\" you are.', false, g_window) g_label = guiCreateLabel(270, 398, 94, 46, "", false, g_window) g_button = guiCreateButton(280, 401, 194, 92, "Lets get to Work Pilot!", false, g_window) showCursor(true) addEventHandler("onClientGUIClick", g_button, function() setElementPosition(localPlayer, 1679.3029785156, 1446.3712158203, 11.043098449707) setCameraTarget(localPlayer) fadeCamera(true) destroyElement(g_window) showCursor(false) end , false) else guiBringToFront(g_window) end end end ) Link to comment
toptional Posted November 16, 2012 Author Share Posted November 16, 2012 Tested it myself. Works perfectly.Client-side local spawnmarker = createMarker(1969.9000244141, -1517.8000488281, 970.79998779297, "cylinder", 2, 9, 30, 213, 255) addEventHandler("onClientMarkerHit", spawnmarker, function(hitElement, matchingDimension) if getElementType(hitElement) == "player" and matchingDimension then if not isElement(g_window) then g_window = guiCreateWindow(147, 141, 749, 548, "The Aviator Spawn Panel by Robbster", false) g_memo = guiCreateMemo(80,56,627,302,'Welcome to to the Aviators Airline Gamemode!t\n\n-----\nINFO\nINFO \nINFO\nINFO\n-------\n\nHere are the ranks\n\nA student pilot is 0 points : These can fly everything except the Andromada, AT-400, military planes and military helicopters (hydra/hunter)\n\nA Private pilot is 150 points : These can fly everything except the Andromada and AT-400, and military planes and helicopters (hydra/hunter) and flying with the shamal will be x1.5 the amount of money a student pilot earns\n\nA Commercial pilot is 250 points : These can fly everything except the military planes and helicopters (hydra/hunter)\n\nArmy pilots is 500 points : These can fly everything\nIn an airline, all airplanes of the airline can be used not matter what \"level\" you are.', false, g_window) g_label = guiCreateLabel(270, 398, 94, 46, "", false, g_window) g_button = guiCreateButton(280, 401, 194, 92, "Lets get to Work Pilot!", false, g_window) showCursor(true) addEventHandler("onClientGUIClick", g_button, function() setElementPosition(localPlayer, 1679.3029785156, 1446.3712158203, 11.043098449707) setCameraTarget(localPlayer) fadeCamera(true) destroyElement(g_window) showCursor(false) end , false) else guiBringToFront(g_window) end end end ) Trying now Edit- Tested it works but when you spawn the GUI doesnt go away, Im gonna try fixing that ill tell you if it doesnt work thanks! Edit - All working thanks!!! Link to comment
Anderl Posted November 16, 2012 Share Posted November 16, 2012 Just really, wtf have you done, on topic, check back the last code I think that is wrong in this setElementPosition ( localPlayer,1679.3029785156,1446.3712158203,11.043098449707 ) Because it is where the spaces between the numbers http://lua.org 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