will briggs Posted June 8, 2011 Share Posted June 8, 2011 Hi, Im trying to make a gui open on marker enter, but close when you press the ok button. This is what i got, local Police = createTeam("Police", 0, 0, 255) -- this will create the team everytime the local teamMarker = createMarker(1553.33, -1677.37, 15, 'cylinder', 1.5, 0, 0, 255, 150 ) function teamMarkerHit( hitElement, matchingDimension ) if getElementType( hitElement ) == "player" and not isPedInVehicle(hitElement) then if getPlayerTeam (hitElement) == Police then outputChatBox("Steven: You are already employed by this department.", hitElement) else local policeWindow = guiCreateWindow ( 0, 0, 0.5, 0.4, "Police Application",true) setPlayerTeam ( hitElement, Police) setPlayerSkin( hitElement, 280) giveWeapon ( hitElement, 3, 1, true ) giveWeapon ( hitElement, 22, 148, true ) giveWeapon ( hitElement, 29, 64, true ) giveWeapon ( hitElement, 25, 10, true ) end end end addEventHandler( "onMarkerHit", teamMarker , teamMarkerHit ) But its stopped everyting else from working. Link to comment
Jaysds1 Posted June 8, 2011 Share Posted June 8, 2011 You have to create the Window in a different function. In the script, when a player enters the marker and the window opens, is there suppose to be a button? Link to comment
Aibo Posted June 8, 2011 Share Posted June 8, 2011 GUI functions are always client-side. this is server script, judging by onMarkerHit. use onClientMarkerHit in a client script. also, if you do it like "local policeWindow = guiCreateWindow" in a handler function, you wont be able to access this gui element when your function finishes. Link to comment
UAEpro Posted June 8, 2011 Share Posted June 8, 2011 this will work ( i think ) client-side ^^ Police = createTeam("Police", 0, 0, 255) -- this will create the team everytime the teamMarker = createMarker(1553.33, -1677.37, 15, 'cylinder', 1.5, 0, 0, 255, 150 ) policeWindow = guiCreateWindow ( 0, 0, 0.5, 0.4, "Police Application",true) guiSetVisible ( policeWindow, false ) function teamMarkerHit( hitElement, matchingDimension ) if getElementType( hitElement ) == "player" and not isPedInVehicle(hitElement) then if getPlayerTeam (hitElement) == Police then outputChatBox("Steven: You are already employed by this department.", hitElement) else guiSetVisible ( policeWindow, true ) setPlayerTeam ( hitElement, Police) setPlayerSkin( hitElement, 280) giveWeapon ( hitElement, 3, 1, true ) giveWeapon ( hitElement, 22, 148, true ) giveWeapon ( hitElement, 29, 64, true ) giveWeapon ( hitElement, 25, 10, true ) end end end addEventHandler( "onClientMarkerHit", teamMarker , teamMarkerHit ) Link to comment
Castillo Posted June 9, 2011 Share Posted June 9, 2011 giveWeapon is only server side. Link to comment
UAEpro Posted June 9, 2011 Share Posted June 9, 2011 (edited) ok c-side use Solidsnake14 c-side >> down s-side function GiveWeapon2 ( hitElement ) giveWeapon ( hitElement, 3, 1, true ) giveWeapon ( hitElement, 22, 148, true ) giveWeapon ( hitElement, 29, 64, true ) giveWeapon ( hitElement, 25, 10, true ) end addEvent( "GiveWeapon", true ) addEventHandler ( "GiveWeapon", getRootElement(), GiveWeapon2) Edited June 9, 2011 by Guest Link to comment
Castillo Posted June 9, 2011 Share Posted June 9, 2011 Wrong client side. Police = createTeam("Police", 0, 0, 255) -- this will create the team everytime the teamMarker = createMarker(1553.33, -1677.37, 15, 'cylinder', 1.5, 0, 0, 255, 150 ) policeWindow = guiCreateWindow ( 0, 0, 0.5, 0.4, "Police Application",true) guiSetVisible ( policeWindow, false ) function teamMarkerHit( hitElement, matchingDimension ) if getElementType( hitElement ) == "player" and not isPedInVehicle(hitElement) then if getPlayerTeam (hitElement) == Police then outputChatBox("Steven: You are already employed by this department.", hitElement) else guiSetVisible ( policeWindow, true ) setPlayerTeam ( hitElement, Police) setPlayerSkin( hitElement, 280) triggerServerEvent ("GiveWeapon", hitElement, hitElement) -- If you don't pass twice hitElement it won't work for server side: hitElement. end end end addEventHandler( "onClientMarkerHit", teamMarker , teamMarkerHit ) 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