yousseftawab Posted May 24, 2012 Share Posted May 24, 2012 I want to restrict the job to Armed forces ACL but it doesn't work it what is wrong. it works fine with no restriction but with the restriction it wont work what is wrong? CLIENT SIDE local marker = createMarker( 94.800003051758, 1925.1999511719, 17, "Cylinder", 2, 40, 73, 0, 200) GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Label = {} windowjob = guiCreateWindow(531,232,301,397,"Armed Forces",false) guiSetVisible(windowjob, false) GUIEditor_Button[1] = guiCreateButton(22,352,108,35,"Take job",false,windowjob) GUIEditor_Label[1] = guiCreateLabel(193,-103,5,5,"",false,windowjob) GUIEditor_Button[2] = guiCreateButton(179,352,110,36,"Cancel",false,windowjob) GUIEditor_Memo[1] = guiCreateMemo(19,33,273,215,"Welcome To Armed Forces\n\nTo take Armed Forces job, press Take job.\n\nIf you don't want to, press Cancel.",false,windowjob) function AFjob( pPlayer ) if local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Armed Forces" ) ) then if pPlayer == localPlayer then if not guiGetVisible(windowjob) then guiSetVisible(windowjob, true) showCursor(true) end end end end end addEventHandler("onClientMarkerHit", marker, AFjob) function AFjobleave( pPlayer ) if pPlayer == localPlayer then if guiGetVisible(windowjob) then guiSetVisible(windowjob, false) showCursor(false) end end end addEventHandler("onClientMarkerLeave", marker, AFjobleave) function joinTeam() triggerServerEvent("setAF",localPlayer) guiSetVisible(windowjob, false) showCursor(false) end addEventHandler("onClientGUIClick", GUIEditor_Button[1] , joinTeam, false) function removeAFWindow() guiSetVisible(windowjob, false) showCursor(false) end addEventHandler("onClientGUIClick", GUIEditor_Button[2] , removeAFWindow, false) SERVER SIDE function createTeamsOnStart () teamAF = createTeam ( "Armed Forces", 40, 73, 0 ) setTeamFriendlyFire ( teamAF, false ) end addEventHandler("onResourceStart", resourceRoot, createTeamsOnStart) function joinAF(hitElement) setPlayerTeam(source,teamAF) setBlipColor ( source, 40, 73, 0, 255 ) setElementModel(source,287) setPlayerNametagColor (source, 40, 73, 0 ) giveWeapon ( source, 3, 1 ) setElementData( source, "Occupation", "Armed Forces", true ) outputChatBox("You have been employed as Armed Forces.",source,0,255,0) end addEvent("setAF", true) addEventHandler("setAF",root,joinAF) Link to comment
Alpha Posted May 24, 2012 Share Posted May 24, 2012 Try: Server: local marker = createMarker( 94.800003051758, 1925.1999511719, 17, "Cylinder", 2, 40, 73, 0, 200) function createTeamsOnStart () teamAF = createTeam ( "Armed Forces", 40, 73, 0 ) setTeamFriendlyFire ( teamAF, false ) end addEventHandler("onResourceStart", resourceRoot, createTeamsOnStart) function joinAF() setPlayerTeam(source,teamAF) setBlipColor ( source, 40, 73, 0, 255 ) setElementModel(source,287) setPlayerNametagColor (source, 40, 73, 0 ) giveWeapon ( source, 3, 1 ) setElementData( source, "Occupation", "Armed Forces", true ) outputChatBox("You have been employed as Armed Forces.",source,0,255,0) end addEvent("setAF", true) addEventHandler("setAF",root,joinAF) function AFjob( pPlayer ) local accName = getAccountName ( getPlayerAccount ( pPlayer ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Armed Forces" ) ) then if not guiGetVisible(windowjob) then triggerClientEvent(pPlayer, "hideWindow", pPlayer) end end end addEventHandler("onMarkerHit", marker, AFjob) Client: GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Label = {} windowjob = guiCreateWindow(531,232,301,397,"Armed Forces",false) guiSetVisible(windowjob, false) GUIEditor_Button[1] = guiCreateButton(22,352,108,35,"Take job",false,windowjob) GUIEditor_Label[1] = guiCreateLabel(193,-103,5,5,"",false,windowjob) GUIEditor_Button[2] = guiCreateButton(179,352,110,36,"Cancel",false,windowjob) GUIEditor_Memo[1] = guiCreateMemo(19,33,273,215,"Welcome To Armed Forces\n\nTo take Armed Forces job, press Take job.\n\nIf you don't want to, press Cancel.",false,windowjob) function AFjobleave( pPlayer ) if pPlayer == localPlayer then if guiGetVisible(windowjob) then guiSetVisible(windowjob, false) showCursor(false) end end end addEventHandler("onClientMarkerLeave", marker, AFjobleave) function joinTeam() triggerServerEvent("setAF",localPlayer) guiSetVisible(windowjob, false) showCursor(false) end addEventHandler("onClientGUIClick", GUIEditor_Button[1] , joinTeam, false) function removeAFWindow() guiSetVisible(windowjob, false) showCursor(false) end addEventHandler("onClientGUIClick", GUIEditor_Button[2] , removeAFWindow, false) addEvent("hideWindow", true) addEventHandler("hideWindow", root, function() guiSetVisible(windowjob, true) showCursor(true) end) Link to comment
yousseftawab Posted May 24, 2012 Author Share Posted May 24, 2012 Still not working I don't know what to do Link to comment
myonlake Posted May 24, 2012 Share Posted May 24, 2012 (edited) You had a lot of wrong arguments and unnecessary checks there. I also minimized a few things and corrected a client/server mixup. Client-side local marker = createMarker(94.800003051758, 1925.1999511719, 17, "Cylinder", 2, 40, 73, 0, 200) addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Label = {} windowjob = guiCreateWindow(531, 232, 301, 397, "Armed Forces", false) guiSetVisible(windowjob, false) GUIEditor_Button[1] = guiCreateButton(22, 352, 108, 35, "Take job", false, windowjob) GUIEditor_Label[1] = guiCreateLabel(193, -103, 5, 5, "", false, windowjob) GUIEditor_Button[2] = guiCreateButton(179, 352, 110, 36, "Cancel", false, windowjob) GUIEditor_Memo[1] = guiCreateMemo(19, 33, 273, 215, "Welcome To Armed Forces\n\nTo take Armed Forces job, press Take job.\n\nIf you don't want to, press Cancel.", false, windowjob) end ) addEventHandler("onClientMarkerHit", marker, function(hitElement, matchingDimension) if getElementType(leaveElement) == "player" then if matchingDimension then if getElementData(hitElement, "Occupation") and getElementData(hitElement, "Occupation") == "Armed Forces" then if not guiGetVisible(windowjob) then guiSetVisible(windowjob, true) showCursor(true) end end end end end ) addEventHandler("onClientMarkerLeave", marker, function(leaveElement, matchingDimension) if getElementType(leaveElement) == "player" then if matchingDimension then if getElementData(leaveElement, "Occupation") and getElementData(leaveElement, "Occupation") == "Armed Forces" then if guiGetVisible(windowjob) then guiSetVisible(windowjob, false) showCursor(false) end end end end end ) addEventHandler("onClientGUIClick", GUIEditor_Button[1], function() triggerServerEvent("setAF", localPlayer) guiSetVisible(windowjob, false) showCursor(false) end, false ) addEventHandler("onClientGUIClick", GUIEditor_Button[2], function() guiSetVisible(windowjob, false) showCursor(false) end, false ) Server-side addEventHandler("onResourceStart", resourceRoot, function() teamAF = createTeam("Armed Forces", 40, 73, 0) setTeamFriendlyFire(teamAF, false) for i,v in ipairs(getElementsByType("player")) do if isGuestAccount(getPlayerAccount(v)) then return end if isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(v)), aclGetGroup("Armed Forces")) then setElementData(v, "Occupation", "Armed Forces", true) end end end ) addEvent("setAF", true) addEventHandler("setAF", root, function() setPlayerTeam(source, teamAF) setBlipColor(source, 40, 73, 0, 255) setElementModel(source, 287) setPlayerNametagColor(source, 40, 73, 0) giveWeapon(source, 3, 1) setElementData(source, "Occupation", "Armed Forces", true) outputChatBox("You have been employed as Armed Forces.", source, 0, 255, 0, false) end ) Edited May 24, 2012 by Guest Link to comment
Alpha Posted May 24, 2012 Share Posted May 24, 2012 My bad: Server: local marker = createMarker( 94.800003051758, 1925.1999511719, 17, "Cylinder", 2, 40, 73, 0, 200) function createTeamsOnStart () teamAF = createTeam ( "Armed Forces", 40, 73, 0 ) setTeamFriendlyFire ( teamAF, false ) end addEventHandler("onResourceStart", resourceRoot, createTeamsOnStart) function joinAF() setPlayerTeam(source,teamAF) setBlipColor ( source, 40, 73, 0, 255 ) setElementModel(source,287) setPlayerNametagColor (source, 40, 73, 0 ) giveWeapon ( source, 3, 1 ) setElementData( source, "Occupation", "Armed Forces", true ) outputChatBox("You have been employed as Armed Forces.",source,0,255,0) end addEvent("setAF", true) addEventHandler("setAF",root,joinAF) function AFjob( pPlayer ) local accName = getAccountName ( getPlayerAccount ( pPlayer ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Armed Forces" ) ) then triggerClientEvent(pPlayer, "hideWindow", pPlayer) end end addEventHandler("onMarkerHit", marker, AFjob) Client: GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Label = {} windowjob = guiCreateWindow(531,232,301,397,"Armed Forces",false) guiSetVisible(windowjob, false) GUIEditor_Button[1] = guiCreateButton(22,352,108,35,"Take job",false,windowjob) GUIEditor_Label[1] = guiCreateLabel(193,-103,5,5,"",false,windowjob) GUIEditor_Button[2] = guiCreateButton(179,352,110,36,"Cancel",false,windowjob) GUIEditor_Memo[1] = guiCreateMemo(19,33,273,215,"Welcome To Armed Forces\n\nTo take Armed Forces job, press Take job.\n\nIf you don't want to, press Cancel.",false,windowjob) function AFjobleave( pPlayer ) if pPlayer == localPlayer then if guiGetVisible(windowjob) then guiSetVisible(windowjob, false) showCursor(false) end end end addEventHandler("onClientMarkerLeave", marker, AFjobleave) function joinTeam() triggerServerEvent("setAF",localPlayer) guiSetVisible(windowjob, false) showCursor(false) end addEventHandler("onClientGUIClick", GUIEditor_Button[1] , joinTeam, false) function removeAFWindow() guiSetVisible(windowjob, false) showCursor(false) end addEventHandler("onClientGUIClick", GUIEditor_Button[2] , removeAFWindow, false) addEvent("hideWindow", true) addEventHandler("hideWindow", root, function() if not guiGetVisible(windowJob) then guiSetVisible(windowjob, true) showCursor(true) end end) Link to comment
yousseftawab Posted May 24, 2012 Author Share Posted May 24, 2012 Still Not Working the gui opens when I press take job it doesn't do anything Link to comment
yousseftawab Posted May 24, 2012 Author Share Posted May 24, 2012 it says incorrect client type for this command EDIT: it's still not working and i tried everything Link to comment
Jaysds1 Posted May 24, 2012 Share Posted May 24, 2012 (edited) Client-side: -- CLIENT SIDE --Don't leave this with out -- or the script will return false local marker = createMarker( 94.800003051758, 1925.1999511719, 17, "Cylinder", 2, 40, 73, 0, 200) GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Label = {} windowjob = guiCreateWindow(531,232,301,397,"Armed Forces",false) guiSetVisible(windowjob, false) GUIEditor_Button[1] = guiCreateButton(22,352,108,35,"Take job",false,windowjob) GUIEditor_Label[1] = guiCreateLabel(193,-103,5,5,"",false,windowjob) GUIEditor_Button[2] = guiCreateButton(179,352,110,36,"Cancel",false,windowjob) GUIEditor_Memo[1] = guiCreateMemo(19,33,273,215,"Welcome To Armed Forces\n\nTo take Armed Forces job, press Take job.\n\nIf you don't want to, press Cancel.",false,windowjob) addEvent("window",true) addEventHandler("window",root,function(oc) guiSetVisible(windowjob,oc) showCursor(oc) if(oc==true)then addEventHandler("onClientGUIClick", GUIEditor_Button[1] , joinTeam, false) addEventHandler("onClientGUIClick", GUIEditor_Button[2] , removeAFWindow, false) end end) function joinTeam() triggerServerEvent("setAF",locaPlayer) guiSetVisible(windowjob,false) showCursor(false) end function removeAFWindow() guiSetVisible(windowjob, false) showCursor(false) end Server: -- SERVER SIDE --Samething here function createTeamsOnStart () teamAF = createTeam ( "Armed Forces", 40, 73, 0 ) setTeamFriendlyFire ( teamAF, false ) end addEventHandler("onResourceStart", resourceRoot, createTeamsOnStart) function joinAF() --Don't include anything in the brackets if you never sent/added any arguments setPlayerTeam(client,teamAF) setBlipColor ( client, 40, 73, 0, 255 ) setElementModel(client,287) setPlayerNametagColor (client, 40, 73, 0 ) giveWeapon ( client, 3, 1 ) setElementData( client, "Occupation", "Armed Forces", true ) outputChatBox("You have been employed as Armed Forces.",client,0,255,0) end addEvent("setAF", true) addEventHandler("setAF",root,joinAF) local marker = createMarker( 94.800003051758, 1925.1999511719, 17, "Cylinder", 2, 40, 73, 0, 200) function AFjob( pPlayer ) local accName = getAccountName ( getPlayerAccount ( pPlayer )) --Don't put this in if statements and thePlayer is suppose to be bPlayer if (accName) then if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Armed Forces" ) ) then if getElementType(pPlayer) == "player" then triggerClientEvent(pPlayer,"window",root,true) end end end end addEventHandler("onMarkerHit", marker, AFjob) function AFjobleave( pPlayer ) if getElementType(pPlayer) == "player" then triggerClientEvent(pPlayer,"window",root,false) end end addEventHandler("onMarkerLeave", marker, AFjobleave) BTW, Did you added this to the ACL.xml? Edited May 24, 2012 by Guest Link to comment
Alpha Posted May 24, 2012 Share Posted May 24, 2012 The client side script has server sided function. Link to comment
Jaysds1 Posted May 24, 2012 Share Posted May 24, 2012 thanks, it's been a ruff day for me... I've edited it BTW 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