Price. Posted November 2, 2014 Share Posted November 2, 2014 I'am having some error, uhm when I open the window I want to make sure that player is in group ACL "PoliceChief" then he could open it, also when I open the window and press on "X" the gui closes but cursor remains on, help please? ------->> -- GUI ------->> --Window local sWidth,sHeight = guiGetScreenSize() local Width,Height = 600,500 local X = (sWidth/2) - (Width/2) local Y = (sHeight/2) - (Height/2) windowJobStats = guiCreateWindow(X,Y,Width,Height,"Police chief",false) guiWindowSetSizable(windowJobStats,false) guiWindowSetMovable(windowJobStats,false) grid = guiCreateGridList(9,30,183,375,false,windowJobStats) guiGridListSetSelectionMode(grid,1) guiGridListAddColumn(grid, "Player", 30) edit = guiCreateEdit(9,406,180,30,"",false,windowJobStats) sackbutton = guiCreateButton(450,33,100,34,"Sack Selected",false,windowJobStats) unsackbutton = guiCreateButton(450,79,100,34,"Unsack Selected",false,windowJobStats) placeAPBbutton = guiCreateButton(450,125,100,34,"Place APB",false,windowJobStats) gochiefbtton = guiCreateButton(450,174,100,34,"/GoChief",false,windowJobStats) closebutton = guiCreateButton(500,450,50,50,"X",false,windowJobStats) guiSetVisible(windowJobStats,false) --[[ Create a function to handle toggling of PC GUI ]]-- function CloseWindowSet () if guiGetVisible (windowJobStats ) ~= true then guiSetVisible (windowJobStats, true ) showCursor ( true ) guiSetInputEnabled( true ) putAllPlayersInList() else showCursor ( false ) guiSetVisible (windowJobStats,false) guiSetInputEnabled( false) outputChatBox("You are not a Police Chief", 255, 255, 255) end end end addCommandHandler("pcpanel", CloseWindowSet) function putAllPlayersInList() guiGridListClear(grid) for i,v in ipairs(getElementsByType("player")) do local row = guiGridListAddRow(grid) guiGridListSetItemText(grid,row,1,getPlayerName(v),false,false) guiGridListSetItemColor(grid,row,1,0,255,0) end end function closeGUI( button, state ) if source ~= windowJobStats then if button == "left" and state == "up" then guiSetVisible( windowJobStats, false ) showCursor ( false ) end end end addEventHandler( "onClientGUIClick", closebutton, closeGUI ) addEventHandler("onClientGUIClick",root, function () local sel = guiGridListGetSelectedItem(grid) local text = guiGridListGetItemText(grid,sel,1) if ( source == unsack ) then -- Unsack if ( sel ~= -1 ) then triggerServerEvent("unsackplr",localPlayer,text) end elseif ( source == placeAPBbutton ) then --- APB if ( sel ~= -1 ) then triggerServerEvent("onDes",localPlayer,text) end elseif ( source == gochiefbtton ) then -- chief if ( sel ~= -1 ) then triggerServerEvent("setteam",localPlayer,text) end end end ) Link to comment
Price. Posted November 4, 2014 Author Share Posted November 4, 2014 I've edited my request, any help? Link to comment
BroadOne Posted November 4, 2014 Share Posted November 4, 2014 I haven't looked at the script properly and don't have time to try it now but there was too many "end"'s, you should use a decent editor like notepad++ and select the language Lua. It will show you mistakes like that. Give it a try not sure if it will work though. ------->> -- GUI ------->> --Window local sWidth,sHeight = guiGetScreenSize() local Width,Height = 600,500 local X = (sWidth/2) - (Width/2) local Y = (sHeight/2) - (Height/2) windowJobStats = guiCreateWindow(X,Y,Width,Height,"Police chief",false) guiWindowSetSizable(windowJobStats,false) guiWindowSetMovable(windowJobStats,false) grid = guiCreateGridList(9,30,183,375,false,windowJobStats) guiGridListSetSelectionMode(grid,1) guiGridListAddColumn(grid, "Player", 30) edit = guiCreateEdit(9,406,180,30,"",false,windowJobStats) sackbutton = guiCreateButton(450,33,100,34,"Sack Selected",false,windowJobStats) unsackbutton = guiCreateButton(450,79,100,34,"Unsack Selected",false,windowJobStats) placeAPBbutton = guiCreateButton(450,125,100,34,"Place APB",false,windowJobStats) gochiefbtton = guiCreateButton(450,174,100,34,"/GoChief",false,windowJobStats) closebutton = guiCreateButton(500,450,50,50,"X",false,windowJobStats) guiSetVisible(windowJobStats,false) --[[ Create a function to handle toggling of PC GUI ]]-- function CloseWindowSet () if guiGetVisible(windowJobStats) ~= true then guiSetVisible (windowJobStats, true ) showCursor ( true ) guiSetInputEnabled( true ) putAllPlayersInList() else showCursor ( false ) guiSetVisible (windowJobStats,false) guiSetInputEnabled( false) outputChatBox("You are not a Police Chief", 255, 255, 255) end end addCommandHandler("pcpanel", CloseWindowSet) function putAllPlayersInList() guiGridListClear(grid) for i,v in ipairs(getElementsByType("player")) do local row = guiGridListAddRow(grid) guiGridListSetItemText(grid,row,1,getPlayerName(v),false,false) guiGridListSetItemColor(grid,row,1,0,255,0) end end function closeGUI( button, state ) if source ~= windowJobStats then if button == "left" and state == "up" then guiSetVisible( windowJobStats, false ) showCursor ( false ) end end end addEventHandler( "onClientGUIClick", closebutton, closeGUI ) addEventHandler("onClientGUIClick",root, function () local sel = guiGridListGetSelectedItem(grid) local text = guiGridListGetItemText(grid,sel,1) if ( source == unsack ) then -- Unsack if ( sel ~= -1 ) then triggerServerEvent("unsackplr",localPlayer,text) end elseif ( source == placeAPBbutton ) then --- APB if ( sel ~= -1 ) then triggerServerEvent("onDes",localPlayer,text) end elseif ( source == gochiefbtton ) then -- chief if ( sel ~= -1 ) then triggerServerEvent("setteam",localPlayer,text) end end end ) Link to comment
Price. Posted November 4, 2014 Author Share Posted November 4, 2014 still, cursor does appears even after i press "X" , also I want to add line to check whether if a player is in ACL Group police chief then he could use this command. Link to comment
WASSIm. Posted November 4, 2014 Share Posted November 4, 2014 you need use triggerServerEvent and triggerClientEvent Link to comment
Price. Posted November 4, 2014 Author Share Posted November 4, 2014 would you give me side event example of what Should be done in the server side?, also how to fix cursor being showed after I pressed on "X"? Link to comment
Price. Posted November 5, 2014 Author Share Posted November 5, 2014 what would I say in the server side? if isobjectinacl group then output? and trigger? Link to comment
Et-win Posted November 5, 2014 Share Posted November 5, 2014 Use bindKey at serverside and then check with isObjectInACLGroup, getAccountName, getPlayerAccount and aclGetGroup or the player is in the correct group to use the function. (Check the example, it's litterly given.) If he has permissions to use it, then trigger towards the client that used the bindKey function and do what you want to do. Link to comment
Price. Posted November 5, 2014 Author Share Posted November 5, 2014 tried doing this but couldn't work I still can open gui without being in PoliceChief ACL group server side function testingpc( thePlayer ) local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "PoliceChief" ) ) then triggerClientEvent(thePlayer, "onCommand", thePlayer) end end client side function CloseWindowSet () if guiGetVisible(windowJobStats) ~= true then guiSetVisible (windowJobStats, true ) showCursor ( true ) guiSetInputEnabled( true ) putAllPlayersInList() else showCursor ( false ) guiSetVisible (windowJobStats,false) guiSetInputEnabled( false) end end addEvent("onCommand", true) addEventHandler("onCommand", getRootElement(), CloseWindowSet) addCommandHandler("pcpanel", CloseWindowSet) Link to comment
Et-win Posted November 5, 2014 Share Posted November 5, 2014 Did you remove the bindKey @ client-side? Also be aware that the commandHandler is still there. Link to comment
Price. Posted November 5, 2014 Author Share Posted November 5, 2014 I don't want bind key I want a command instead, and yea I've just added command handler at client side so if he is a in ACl group policechief he could open the gui, or what's wrong with it? Link to comment
Et-win Posted November 6, 2014 Share Posted November 6, 2014 You should put the commandHandler server-side and attach it to the function which checks or the player is in the ACL Group. Link to comment
Price. Posted November 6, 2014 Author Share Posted November 6, 2014 Well it now works perfectly thanks , I was wondering how to attach this gui GUIEditor = { button = {}, window = {}, progressbar = {}, edit = {} } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[2] = guiCreateWindow(316, 354, 368, 96, "Sack reason", false) guiWindowSetSizable(GUIEditor.window[2], false) GUIEditor.button[1] = guiCreateButton(297, 24, 61, 28, "Sack", false, GUIEditor.window[2]) GUIEditor.button[2] = guiCreateButton(295, 60, 63, 26, "Close window", false, GUIEditor.window[2]) GUIEditor.edit[1] = guiCreateEdit(9, 67, 245, 19, "", false, GUIEditor.window[2]) GUIEditor.progressbar[1] = guiCreateProgressBar(9, 24, 272, 33, false, GUIEditor.window[2]) end ) to my original gui? when I press on sack button? the original gui ------->> -- GUI ------->> --Window local sWidth,sHeight = guiGetScreenSize() local Width,Height = 600,500 local X = (sWidth/2) - (Width/2) local Y = (sHeight/2) - (Height/2) windowJobStats = guiCreateWindow(X,Y,Width,Height,"Police chief",false) guiWindowSetSizable(windowJobStats,false) guiWindowSetMovable(windowJobStats,false) grid = guiCreateGridList(9,30,183,375,false,windowJobStats) guiGridListSetSelectionMode(grid,1) guiGridListAddColumn(grid, "Player", 30) edit = guiCreateEdit(9,406,180,30,"",false,windowJobStats) sackbutton = guiCreateButton(450,33,100,34,"Sack Selected",false,windowJobStats) unsackbutton = guiCreateButton(450,79,100,34,"Unsack Selected",false,windowJobStats) placeAPBbutton = guiCreateButton(450,125,100,34,"Place APB",false,windowJobStats) gochiefbtton = guiCreateButton(450,174,100,34,"/GoChief",false,windowJobStats) closebutton = guiCreateButton(500,450,50,50,"X",false,windowJobStats) guiSetVisible(windowJobStats,false) --[[ Create a function to handle toggling of PC GUI ]]-- function CloseWindowSet () if guiGetVisible(windowJobStats) ~= true then guiSetVisible (windowJobStats, true ) showCursor ( true ) guiSetInputEnabled( true ) putAllPlayersInList() else showCursor ( false ) guiSetVisible (windowJobStats,false) guiSetInputEnabled( false) end end addEvent("onCommand", true) addEventHandler("onCommand", getRootElement(), CloseWindowSet) function putAllPlayersInList() guiGridListClear(grid) for i,v in ipairs(getElementsByType("player")) do local row = guiGridListAddRow(grid) guiGridListSetItemText(grid,row,1,getPlayerName(v),false,false) guiGridListSetItemColor(grid,row,1,0,255,0) end end function closeGUI( button, state ) if source ~= windowJobStats then if button == "left" and state == "up" then guiSetVisible( windowJobStats, false ) showCursor ( false ) end end end addEventHandler( "onClientGUIClick", closebutton, closeGUI ) addEventHandler("onClientGUIClick",root, function () local sel = guiGridListGetSelectedItem(grid) local text = guiGridListGetItemText(grid,sel,1) if ( source == unsack ) then -- Unsack if ( sel ~= -1 ) then triggerServerEvent("unsackplr",localPlayer,text) end elseif ( source == placeAPBbutton ) then --- APB if ( sel ~= -1 ) then triggerServerEvent("onDes",localPlayer,text) end elseif ( source == gochiefbtton ) then -- chief if ( sel ~= -1 ) then triggerServerEvent("setteam",localPlayer,text) end end end ) Link to comment
Price. Posted November 6, 2014 Author Share Posted November 6, 2014 sorry for double post, I get error at client2 (2nd gui) when i attached the first one to the 2nd Function client (1) function Window2Load () if not GUIEditor.window[2] then triggerEvent ("newWindow",source) end if guiGetVisible ( GUIEditor.window[2],true ) then guiSetVisible ( GUIEditor.window[2],false) else guiSetVisible ( GUIEditor.window[2],true) end end addEventHandler ( "onClientGUIClick", sackbutton, Window2Load, false ) 2nd gui GUIEditor = { button = {}, window = {}, progressbar = {}, edit = {} } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[2] = guiCreateWindow(316, 354, 368, 96, "Sack reason", false) guiWindowSetSizable(GUIEditor.window[2], false) GUIEditor.button[1] = guiCreateButton(297, 24, 61, 28, "Sack", false, GUIEditor.window[2]) GUIEditor.edit[1] = guiCreateEdit(9, 67, 245, 19, "", false, GUIEditor.window[2]) GUIEditor.progressbar[1] = guiCreateProgressBar(9, 24, 272, 33, false, GUIEditor.window[2]) end ) function Sack () triggerServerEvent ("sack",localPlayer) end addEventHandler ( "onClientGUIClick", GUIEditor.button[1], Sack, false ) so basically in the 1st gui I Should press on "sack" button then the 2nd gui opens then pressing the button in gui2 does the event of server side, instead i get error at addEventHandler ( "onClientGUIClick", GUIEditor.button[1], Sack, false ) says bad argument expected element at argument 2 , got nil EDIT: server side part where "sack event" is triggered timersTable = { } function banFromLaw(plr, cmd, victim, time, reason, accountName, admin) local accName = getAccountName(getPlayerAccount(plr)) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Police Chief" )) then local vic = getPlayerFromName(victim) if not isElement(vic) then return end if getPlayerTeam(vic) ~= getTeamFromName("Police") then outputChatBox("This player is not a police officer", plr) return end -- Toggle the ban setElementData( vic , "bannedFromLaw", true ) timersTable[vic] = makeCoolDownTimer(300, vic) -- Reset job and team setPlayerTeam(vic, getTeamFromName("Unemployed")) setPlayerNametagColor(vic, 255, 255, 0) setElementModel(vic, 0) setElementData(vic, "Occupation", "Jobless") end end addEvent("sack", true) addEventHandler("sack", getRootElement(), banFromLaw) 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