Vanlot Posted July 6, 2012 Share Posted July 6, 2012 Hi Every One.I Have A Script To make SWAT Team.To Join The team The Player Must Enter a marker Then A Panel Appears in it he will find Take Job or Cancel. 1-Take job is Work But Cancel Didn't Work 2-The Panel Appear Every Time I Open The Resource But I want it to appear only when The Player enter the Marker. The Client sIDE: local marker = createMarker( 1954.3000488281, -2174.5, 12.5, "Cylinder", 1.5, 0, 0, 255, 150) GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Window[1] = guiCreateWindow(204,89,235,437,"SWAT Job",false) GUIEditor_Button[1] = guiCreateButton(11,384,79,39,"Take Job",false,GUIEditor_Window[1]) GUIEditor_Memo[1] = guiCreateMemo(9,28,217,321,"Welcome To Swat Job.To Take This Job Press \"Take Job\".IF you want to close this window press \"Cancel\"",false,GUIEditor_Window[1]) guiMemoSetReadOnly(GUIEditor_Memo[1],true) GUIEditor_Button[2] = guiCreateButton(103,384,79,39,"Cancel",false,GUIEditor_Window[1]) function SAWATjob(hitElement) if getElementType(hitElement) == "player" and (hitElement == localPlayer) then if not guiGetVisible(windowjob) then guiSetVisible(windowjob, true) showCursor(true) end end end addEventHandler("onClientMarkerHit", marker, SWATjob) function FBIjobleave(leaveElement) if getElementType(leaveElement) == "player" and (leaveElement == localPlayer) then if guiGetVisible(windowjob) then guiSetVisible(windowjob, false) showCursor(false) end end end addEventHandler("onClientMarkerLeave", marker, SWATjobleave) function joinTeam() triggerServerEvent("setSWAT",localPlayer) guiSetVisible(windowjob, false) showCursor(false) end addEventHandler("onClientGUIClick", GUIEditor_Button[1] , joinTeam, false) function removeSWATWindow() guiSetVisible(windowjob, false) showCursor(false) end addEventHandler("onClientGUIClick", GUIEditor_Button[2] , removeSWATWindow, false) Server Side: createBlip ( 1954.3000488281, -2174.5, 12.5, 30 ) function createSWATTeam () SAPDteam = createTeam ("SWAT", 100, 149, 237) end addEventHandler ("onResourceStart", resourceRoot, createSWATTeam) function joinSWAT() setPlayerTeam(source,SWATteam) setElementModel(source, 280) giveWeapon ( source, 3 ) setElementData( source, "Occupation", "Copteam", true ) outputChatBox("You Are Now SWAT Member.",source,0,255,0) end addEvent("setSWAT", true) addEventHandler("setSWAT",root,joinSWAT) function policeJob ( attacker, attackerweapon, bodypart, loss ) theTeam = getPlayerTeam ( attacker ) if (attackerweapon == 3) and (loss > 2 ) then setElementPosition (source, 219, 110, 999, true) setTimer ( setElementPosition, 100000, 1, source, 236.32, 110.4, 1003.2) takePlayerMoney (source, 50) givePlayerMoney (attacker, 100) end end addEventHandler ("onPlayerDamage", getRootElement(), policeJob) The Wanted Script: addEventHandler("onPlayerJoin", root, function ( ) setPlayerNametagText ( source, getPlayerName ( source ) .."[".. getPlayerWantedLevel ( source ) .."]" ) end ) function updateNametagWantedLevel ( ) for index, player in ipairs ( getElementsByType ( "player" ) ) do setPlayerNametagText ( player, getPlayerName ( player ) .."[".. getPlayerWantedLevel ( player ) .."]" ) end end setTimer ( updateNametagWantedLevel, 3000, 0 ) Link to comment
Castillo Posted July 6, 2012 Share Posted July 6, 2012 1: The problem is that you set as window variable name: "windowjob", but is: "GUIEditor_Window[1]". 2: You must hide the window just after created. local marker = createMarker( 1954.3000488281, -2174.5, 12.5, "Cylinder", 1.5, 0, 0, 255, 150) GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Window[1] = guiCreateWindow(204,89,235,437,"SWAT Job",false) guiSetVisible ( GUIEditor_Window[1], false ) GUIEditor_Button[1] = guiCreateButton(11,384,79,39,"Take Job",false,GUIEditor_Window[1]) GUIEditor_Memo[1] = guiCreateMemo(9,28,217,321,"Welcome To Swat Job.To Take This Job Press \"Take Job\".IF you want to close this window press \"Cancel\"",false,GUIEditor_Window[1]) guiMemoSetReadOnly(GUIEditor_Memo[1],true) GUIEditor_Button[2] = guiCreateButton(103,384,79,39,"Cancel",false,GUIEditor_Window[1]) function SWATjob(hitElement) if getElementType(hitElement) == "player" and (hitElement == localPlayer) then if not guiGetVisible(GUIEditor_Window[1]) then guiSetVisible(GUIEditor_Window[1], true) showCursor(true) end end end addEventHandler("onClientMarkerHit", marker, SWATjob) function SWATjobleave(leaveElement) if getElementType(leaveElement) == "player" and (leaveElement == localPlayer) then if guiGetVisible(GUIEditor_Window[1]) then guiSetVisible ( GUIEditor_Window[1], false ) showCursor(false) end end end addEventHandler("onClientMarkerLeave", marker, SWATjobleave) function joinTeam() triggerServerEvent("setSWAT",localPlayer) guiSetVisible ( GUIEditor_Window[1], false ) showCursor(false) end addEventHandler("onClientGUIClick", GUIEditor_Button[1] , joinTeam, false) function removeSWATWindow() guiSetVisible ( GUIEditor_Window[1], false ) showCursor(false) end addEventHandler("onClientGUIClick", GUIEditor_Button[2] , removeSWATWindow, false) Link to comment
Vanlot Posted July 6, 2012 Author Share Posted July 6, 2012 I Use The Script AFTER You Fix It.But When I Enter The Marker,The Panel Can't Appear anyMore. Link to comment
Vanlot Posted July 6, 2012 Author Share Posted July 6, 2012 Thanx It's Work.Thanx Again. 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