waqaarali Posted May 22, 2014 Share Posted May 22, 2014 Well i made 2 markers in seperate script with different functions but when i enter one marker it shows same GUI as the other one, why ? Link to comment
waqaarali Posted May 22, 2014 Author Share Posted May 22, 2014 Client Side function onMarkerHit() vehicleGUI = guiCreateWindow(314, 215, 160, 211, "", false) guiWindowSetSizable(vehicleGUI, false) vehLabelOne = guiCreateLabel(13, 36, 15, 15, "1.", false, vehicleGUI) vehButtonOne = guiCreateButton(38, 26, 107, 36, "LSPD Vehicle", false, vehicleGUI) vehLabelTwo = guiCreateLabel(13, 86, 15, 15, "2.", false, vehicleGUI) vehButtonTwo = guiCreateButton(38, 76, 107, 36, "LSPD Rancher", false, vehicleGUI) vehLabelThree = guiCreateLabel(13, 138, 15, 15, "3.", false, vehicleGUI) vehButtonThree = guiCreateButton(38, 128, 107, 36, "LSPD Motorbike", false, vehicleGUI) vehClose = guiCreateButton(86, 179, 64, 22, "Close", false, vehicleGUI) if source == vehMarker then guiSetVisible(vehicleGUI,true) showCursor ( true ) end end addEventHandler("onClientMarkerHit",root,onMarkerHit) Link to comment
waqaarali Posted May 22, 2014 Author Share Posted May 22, 2014 Well i have another script but it's seperate i don't want to post it, and when i enter this marker it appears the other markers GUI why ? Link to comment
justn Posted May 22, 2014 Share Posted May 22, 2014 This should work, if you are still having this problem, then show me your next code when the player hits the marker vehicleGUI = guiCreateWindow(314, 215, 160, 211, "", false) guiWindowSetSizable(vehicleGUI, false) guiSetVisible(vehicleGUI,false) vehLabelOne = guiCreateLabel(13, 36, 15, 15, "1.", false, vehicleGUI) vehButtonOne = guiCreateButton(38, 26, 107, 36, "LSPD Vehicle", false, vehicleGUI) vehLabelTwo = guiCreateLabel(13, 86, 15, 15, "2.", false, vehicleGUI) vehButtonTwo = guiCreateButton(38, 76, 107, 36, "LSPD Rancher", false, vehicleGUI) vehLabelThree = guiCreateLabel(13, 138, 15, 15, "3.", false, vehicleGUI) vehButtonThree = guiCreateButton(38, 128, 107, 36, "LSPD Motorbike", false, vehicleGUI) vehClose = guiCreateButton(86, 179, 64, 22, "Close", false, vehicleGUI) function onMarkerHit(hitElement,matchingDimension) if ( hitElement == localPlayer) then if source == vehMarker then guiSetVisible(vehicleGUI,true) showCursor ( true ) end end end addEventHandler("onClientMarkerHit",root,onMarkerHit) Link to comment
Karuzo Posted May 23, 2014 Share Posted May 23, 2014 If you still have problems regarding to the gui which pops up just make those variables local. Link to comment
Mr_Moose Posted May 23, 2014 Share Posted May 23, 2014 Maybe this can help you: https://community.multitheftauto.com/index.php?p=resources&s=details&id=8338. A full vehicle spawn system in open source, if you don't want to use it you might just copy some parts of the code to solve any problem you find in your script. Link to comment
waqaarali Posted May 23, 2014 Author Share Posted May 23, 2014 Well what i am trying to do is solve this problem from yestarday, when i enter a different marker it's meant to do something else seperately but for some reason it is showing another markers GUI but for this marker a 'Gate' opens, help please ;(, local lspdTeam = createTeam ( "San Andreas Police",13,0,255) function setTeam() setPlayerTeam ( source, lspdTeam ) setElementModel ( source, 280 ) giveWeapon ( source, 31, 500 ) giveWeapon ( source, 3, 1 ) giveWeapon ( source, 29, 500 ) end addEvent("lspdTeam",true) addEventHandler("lspdTeam",getRootElement(),setTeam) local gate = createObject(976 , 1544.4000244141, -1630.6999511719 , 12.5, 0 ,0 ,92) local marker = createMarker(1540.98633, -1627.65710, 13.38281, "cylinder", 6, 255, 255, 255, 0) function moveGate(hitPlayer, matchingDimension) if getPlayerTeam(hitPlayer) == lspdTeam then moveObject(gate, 2000, 1544.4000244141 , -1638.6999511719 , 12.5) setTimer(moveBack, 2000, 1) end end addEventHandler("onMarkerHit", marker, moveGate) function moveBack() moveObject(gate, 2000, 1544.4000244141, -1630.6999511719 , 12.5) end All i want to do is make this gate open, the gate opens but the other script's GUI opens too. Link to comment
TAPL Posted May 23, 2014 Share Posted May 23, 2014 Post all your onClientMarkerHit codes you doing something wrong here. Link to comment
waqaarali Posted May 23, 2014 Author Share Posted May 23, 2014 This is the only client marker hit code i have in client side local lspdMarker = createMarker(1553.77661, -1675.02612, 15.19531,"cylinder",1) function onMarkerEnter() mainGUI = guiCreateWindow(262, 215, 314, 206, "Job System v1.0 By FlowZ", false) guiWindowSetSizable(mainGUI, false) mainMemo = guiCreateMemo(10, 41, 290, 110, "Welcome to Los Santos Police Department v1.0 Job System. This job was created by FlowZ and has been made from scratch it has a lot of features. If you would like to take this job go ahead and hit 'Accept' or if you don't want this job hit 'Decline'.", false, mainGUI) guiMemoSetReadOnly(mainMemo, true) mainAccept = guiCreateButton(16, 165, 93, 27, "Accept", false, mainGUI) mainDecline = guiCreateButton(207, 165, 93, 27, "Decline", false, mainGUI) if source == lspdMarker then guiSetVisible(mainGUI,true) showCursor(true) end end addEventHandler("onClientMarkerHit",getRootElement(),onMarkerEnter) Link to comment
TAPL Posted May 23, 2014 Share Posted May 23, 2014 What you did here is creating the gui inside the event onClientMarkerHit before you even check what marker was hit, you kidding? huh. Link to comment
waqaarali Posted May 23, 2014 Author Share Posted May 23, 2014 Sorry man, i am still a learning to script Link to comment
waqaarali Posted May 23, 2014 Author Share Posted May 23, 2014 So i need to make the codes seperate? Link to comment
TAPL Posted May 23, 2014 Share Posted May 23, 2014 Move this line to top, so it wont create the gui unless the marker hit was lspdMarker. if source == lspdMarker then function onMarkerEnter() if source == lspdMarker then oh and make sure who hit the marker was localPlayer function onMarkerEnter(hitPlayer) if hitPlayer == localPlayer and source == lspdMarker then OR create the gui out side the event. Link to comment
waqaarali Posted May 23, 2014 Author Share Posted May 23, 2014 Thank you it worked =D <3 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