maskatchi Posted August 7, 2011 Share Posted August 7, 2011 ok so the script is: function initGUI( ) btnOutput = guiCreateButton( 0.7, 0.1, 0.2, 0.1, "Output!", true ) addEventHandler ( "onClientGUIClick", btnOutput, outputEditBox, false ) editBox = guiCreateEdit( 0.3, 0.1, 0.4, 0.1, "Type your message here!", true ) guiEditSetMaxLength ( editBox, 128 ) end addEventHandler( "onClientResourceStart", getResourceRootElement( getThisResource( ) ), initGUI ) function outputEditBox ( button ) if button == "left" then local text = guiGetText ( editBox ) outputChatBox ( text ) end end how would i make it so the gui only pops up for admins? Link to comment
JR10 Posted August 7, 2011 Share Posted August 7, 2011 Server side: addEvent ( "onPlayerDownloadResource" , true ) addEventHandler ( "onPlayerDownloadResource" , root , function ( ) if hasObjectPermissionTo ( source , "function.banPlayer" , false ) then triggerClientEvent ( source , "initGUI" , source ) end end ) Client side: function initGUI( ) btnOutput = guiCreateButton( 0.7, 0.1, 0.2, 0.1, "Output!", true ) addEventHandler ( "onClientGUIClick", btnOutput, outputEditBox, false ) editBox = guiCreateEdit( 0.3, 0.1, 0.4, 0.1, "Type your message here!", true ) guiEditSetMaxLength ( editBox, 128 ) end addEvent ( "initGUI" , true ) addEventHandler ( "initGUI" , root , initGUI ) addEventHandler( "onClientResourceStart", getResourceRootElement( getThisResource( ) ), function ( ) triggerServerEvent ( "onPlayerDownloadResource" , getLocalPlayer()) end) function outputEditBox ( button ) if button == "left" then local text = guiGetText ( editBox ) outputChatBox ( text ) end end Link to comment
Castillo Posted August 7, 2011 Share Posted August 7, 2011 Well, firstly, you'll need a server & a client side script, but, I done the job for you, and seems to be working . -- client side addEventHandler( "onClientResourceStart", getResourceRootElement( getThisResource( ) ), function () triggerServerEvent("isPlayerAdmin",getLocalPlayer(),getLocalPlayer()) end) function initGUI() btnOutput = guiCreateButton( 0.7, 0.1, 0.2, 0.1, "Output!", true ) addEventHandler ( "onClientGUIClick", btnOutput, outputEditBox, false ) editBox = guiCreateEdit( 0.3, 0.1, 0.4, 0.1, "Type your message here!", true ) guiEditSetMaxLength ( editBox, 128 ) end addEvent("returnIsPlayerAdmin",true) addEventHandler("returnIsPlayerAdmin",root,initGUI) function outputEditBox ( button ) if button == "left" then local text = guiGetText ( editBox ) triggerServerEvent("outputAdminText",getLocalPlayer(),text) end end -- server side addEvent("isPlayerAdmin",true) addEventHandler("isPlayerAdmin",root, function (client) local account = getPlayerAccount(client) if not account or isGuestAccount(account) then return end local accountName = getAccountName(account) if isObjectInACLGroup("user."..accountName,aclGetGroup("Admin")) then triggerClientEvent(client,"returnIsPlayerAdmin",client) end end) addEvent("outputAdminText",true) addEventHandler("outputAdminText",root, function (text) outputChatBox(tostring(text)) end) P.S: I added the outputChatBox server-sided because, it would have been output only to the client with your way. 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