Hell-Mate Posted November 28, 2014 Share Posted November 28, 2014 Hello community, I made a simply script which is Admin speach, simply any one at Admin acl group can open a panel with /talktoplayer and this panel have a memo when u write on it force all players on server to stop and read what u say on another memo ( it force them as it will show cursor to them so they are freezed ) my problem is that, i made it if the memo is empty the whole window get closed, but it don't and another problem is that the window only show to the admin not for all server and also i want it to dont show the another memo to the admin ( just the panel that opened by /talktoplayer ) and finally here is the code .. --Client presWindow = guiCreateWindow(459, 109, 352, 512, "Admin speach panel", false) guiWindowSetSizable(presWindow, false) guiSetVisible ( presWindow, false ) presSpeach = guiCreateMemo(10, 26, 332, 390, "", false, presWindow) clearnclose = guiCreateButton(92, 431, 160, 50, "Clear and Close", false, presWindow) guiSetProperty(clearnclose, "NormalTextColour", "FFAAAAAA") speachWindow = guiCreateWindow(342, 93, 606, 520, "Admin is talking", false) guiWindowSetSizable(speachWindow, false) guiSetVisible ( speachWindow, false ) speachText = guiCreateMemo(13, 30, 583, 480, "", false, speachWindow) guiMemoSetReadOnly ( speachText, true ) guiSetFont(speachText, "default-bold-small") addEvent ( "openPresGui", true ) addEventHandler ( "openPresGui", root, function () if not ( guiGetVisible ( presWindow ) == true ) then guiSetVisible ( presWindow, true ) showCursor ( true ) else return end end) addEventHandler ( "onClientGUIClick", root, function () if source == clearnclose then guiSetVisible ( presWindow, false ) guiSetVisible ( speachWindow, false ) guiSetText ( presSpeach, "" ) showCursor ( false ) end end) addEventHandler ( "onClientGUIChanged", presSpeach, function () local Speach = guiGetText (source) local Speach2 = guiGetText ( speachText ) if (Speach ~= ("")) then guiSetVisible ( speachWindow, true ) showCursor ( true ) guiSetText ( speachText, Speach ) end if ( Speach2 == ("")) then guiSetVisible ( speachWindow, false ) showCursor ( false ) end end) --Server function presGUIOpen ( thePlayer ) local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then triggerClientEvent ( thePlayer, "openPresGui", thePlayer ) end end addCommandHandler ( "talktoplayers", presGUIOpen ) Regards, Hell-Mate. Link to comment
Atton Posted November 28, 2014 Share Posted November 28, 2014 Try implementing the code below. -- Server function serverRun (thePlayer) local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then triggerClientEvent("name",getRootElement(),thePlayer) end end addCommandHandler ( "talktoplayers", serverRun) -- Client function theClient () end addEvent("name",true) addEventHandler("name",localPlayer,edit) Link to comment
Hell-Mate Posted November 28, 2014 Author Share Posted November 28, 2014 You changed nothing .. Link to comment
Dealman Posted November 28, 2014 Share Posted November 28, 2014 If you pay attention, he did. You really need to study the MTA Wiki a bit more. The reason it only triggers for one player, is because of this; triggerClientEvent ( thePlayer, "openPresGui", thePlayer ) Now go to the wikipage of triggerClientEvent and look at the arguments for it. Currently the Send To argument is a player element. That means one player. If you change that to root instead, you'll send it to all players. For example; triggerClientEvent(root, "openPresGui", resourceRoot); -- Argument 1(Optional): Should it trigger for specific players, or all of them? -- Argument 2: The event to trigger. -- Argument 3: The source element. Link to comment
Hell-Mate Posted November 28, 2014 Author Share Posted November 28, 2014 guys -.- take a minute to read all the code, if i triggered this to all players so if an admin do /talktoplayer, the gui will appear for all not for only the one who typed /talktoplayers the problem is not here, the problem is at onClientChanged thingy, read it carefully and tell me why the gui ( the another gui which only have a memo ) only appear to the admin which is typing on the memo but i want it not to appear to the admin which is typing at /talktoplayers gui and appear to all. 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