Sora Posted February 23, 2012 Share Posted February 23, 2012 (edited) hi guys i made Give Permissions Panel with gui editor and i added command to show the panel only for who is in Console Group and the script works fine , but the problem is when i wrote /gpp to open the panel it's opening for all players the codes Client Side : GppWindow = guiCreateWindow(545,151,243,262,"Give Permissions Panel By |S.s|SoRa",false) guiWindowSetSizable(GppWindow,false) Gpedit = guiCreateEdit(16,46,203,33,"",false,GppWindow) GiveModeratorButton = guiCreateButton(13,102,215,40,"Give Moderator Permissions",false,GppWindow) GiveSuperModeratorButton = guiCreateButton(12,153,215,40,"Give SuperModerator Permissions",false,GppWindow) GiveAdminsButton = guiCreateButton(11,205,215,40,"Give Admins Permissions",false,GppWindow) label = guiCreateLabel(20,21,154,17,"Player Username :",false,GppWindow) CloseButton = guiCreateButton(213,24,18,16,"X",false,GppWindow) function onresourceStart () -- outputChatBox ("Give Permissions Panel By |S.s|SoRa", 0, 255, 0, true) guiSetVisible (GppWindow, false) showCursor (false) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), onresourceStart) function showPanel () guiSetVisible (GppWindow, true) showCursor (true) end addEvent( "showPanel", true ) addEventHandler ( "showPanel", getRootElement(), showPanel) function onGuiClick (button, state, absoluteX, absoluteY) if (source == GiveModeratorButton) then GiveModerator = guiGetText ( Gpedit ) triggerServerEvent ("GiveModerator", getLocalPlayer(), GiveModerator) playSound("sec.wav",false) elseif (source == GiveSuperModeratorButton) then GiveSuperModerator = guiGetText ( Gpedit ) triggerServerEvent ("GiveSuperModerator", getLocalPlayer(), GiveSuperModerator) playSound("sec.wav",false) elseif (source == GiveAdminsButton) then GiveAdmins = guiGetText ( Gpedit ) triggerServerEvent ("GiveAdmins", getLocalPlayer(), GiveAdmins) playSound("sec.wav",false) elseif (source == CloseButton) then guiSetVisible (GppWindow, false) showCursor (false) end end addEventHandler ("onClientGUIClick", getRootElement(), onGuiClick) function GetPermission() triggerServerEvent ("OpenPanel", getLocalPlayer(), OpenPanel) end addCommandHandler ( "gpp", GetPermission ) Server Side : local rootElement = getRootElement() function GiveModerator ( GiveModerator ) if GiveModerator then aclGroupAddObject (aclGetGroup("Moderator"), "user."..GiveModerator) outputChatBox ("Account '"..GiveModerator.."' succesfully added to the Moderator group", source, 0, 255, 0, true) else outputChatBox ("No account name specified.", source, 255, 0, 0, true) end end addEvent( "GiveModerator", true ) addEventHandler ( "GiveModerator", rootElement, GiveModerator) function GiveSuperModerator ( GiveSuperModerator ) if GiveSuperModerator then aclGroupAddObject (aclGetGroup("SuperModerator"), "user."..GiveSuperModerator) outputChatBox ("Account '"..GiveSuperModerator.."' succesfully added to the SuperModerator group", source, 0, 255, 0, true) else outputChatBox ("No account name specified.", source, 255, 0, 0, true) end end addEvent( "GiveSuperModerator", true ) addEventHandler ( "GiveSuperModerator", rootElement, GiveSuperModerator) function GiveAdmins ( GiveAdmins ) aclGroupAddObject (aclGetGroup("Admins"), "user."..GiveAdmins) outputChatBox ("Account '"..GiveAdmins.."' succesfully added to the admins group", source, 0, 255, 0, true) end addEvent( "GiveAdmins", true ) addEventHandler ( "GiveAdmins", rootElement, GiveAdmins) function OpenPanel (source) local accountname = getAccountName(getPlayerAccount(source)) if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Console" )) then triggerClientEvent ( "showPanel", rootElement, showPanel ) else outputChatBox ("You Don't Have Permission For This Command", source, 255, 0, 0, true) end end addEvent( "OpenPanel", true ) addEventHandler ( "OpenPanel", OpenPanel) function check() local accountname = getAccountName(getPlayerAccount(source)) if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Console" )) then outputChatBox ("Type /gpp to open give permissions panel", source, 255, 0, 0, true) end end addEventHandler("onPlayerLogin",getRootElement(),check ) Edited February 23, 2012 by Guest Link to comment
Kenix Posted February 23, 2012 Share Posted February 23, 2012 triggerClientEvent ( "showPanel", rootElement, showPanel ) You trigger for all elements. See in arguments. And you trigger function nil value. Server function OpenPanel ( player ) local player = player or source local accountname = getAccountName( getPlayerAccount( player ) ) if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Console" )) then triggerClientEvent ( player,"showPanel", player ) else outputChatBox ("You Don't Have Permission For This Command", player, 255, 0, 0, true) end end addEvent( "OpenPanel", true ) addEventHandler ( "OpenPanel",root, OpenPanel ) addCommandHandler ( "gpp", OpenPanel ) Updated. Tabulate your code please! Link to comment
Sora Posted February 23, 2012 Author Share Posted February 23, 2012 (edited) oh sorry for this i'm normal scripter and i don't understand lua language so much and thanks so much for your help , the problem have been solved ^^ Edited February 23, 2012 by Guest 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