Gastonito Posted July 21, 2017 Share Posted July 21, 2017 (edited) So, hey guys. I've been working on a staff panel lately, its like a panel for trial admins. There is Something that i couldnt do This is the panel : Quote I've made all the functions except one, the mute thing, i didnt know how to do it, so can you help me with it ? I could only do the gui thing, here is it : https://pastebin.com/fpPpuryw I will appreciate it alot if you do the whole thing for me Edited July 21, 2017 by Gastonito Link to comment
koragg Posted July 22, 2017 Share Posted July 22, 2017 Shouldn't it be similar to the Kick one? I can't do code cuz it's 7am and I'm in bed but... 1. You click a player name in a grid in your panel. 2. You use 'getPlayerFromPartialName' to get the player with that nickname. Remember: this is a useful function so you need it's code from the wiki before using it. 3. Then you do 'setPlayerMuted' on the guy you just found in step 2. Link to comment
NeXuS™ Posted July 22, 2017 Share Posted July 22, 2017 Usually we won't make the whole script for you, we help with errors, and give instructions. Try to do it yourself, and if you happen to be stuck, ask here. Link to comment
Gastonito Posted July 22, 2017 Author Share Posted July 22, 2017 2 hours ago, NeXuS™ said: Usually we won't make the whole script for you, we help with errors, and give instructions. Try to do it yourself, and if you happen to be stuck, ask here. This is what i could do : server side : addEvent( "onPlayerMuteClient", true ) local function handle_mute( thePlayer, theTime ) if ( ( thePlayer ) and ( theTime or 0 ) ) then theTime = theTime or 480000 setPlayerMuted( thePlayer, true ) setTimer( function( thePlayer ) setPlayerMuted( thePlayer, false ) end, theTime, 1, thePlayer ) end end -- EVENT HANDLERS addEventHandler( "onPlayerMuteClient", root, handle_mute ) Client side : if source == mywind[18] then nameplayermute = guiGridListGetItemText ( mywind[2], guiGridListGetSelectedItem ( mywind[16] ), 1 ) jail = guiGridListGetItemText ( mywind[16], guiGridListGetSelectedItem ( mywind[16] ), 1 ) if jail and nameplayerjail then triggerServerEvent( "onPlayerMuteClient", thePlayerBeingMuted, thePlayerBeingMuted, theTime ) end Link to comment
Gastonito Posted July 23, 2017 Author Share Posted July 23, 2017 9 hours ago, NeXuS™ said: What's not working about it? Which is not working is that as you can see in the SS there are many options of the mute time, 1 mins, 2 mins, 1 hour, etc .. anywas, the script that i've made works only for 480000 which should be 8 mins Link to comment
Gastonito Posted July 24, 2017 Author Share Posted July 24, 2017 Well guys thanks to @Tomas the script is done, here is it : Server side : Quote Client Side : Quote But the weird thing that i'm getting this error : Quote Any idea how o fix it please ? Link to comment
Dimos7 Posted July 24, 2017 Share Posted July 24, 2017 (edited) on clientGUIClick is root not resourceRoot leson 1 also same with onAdminMute same root not resourceRoot Edited July 24, 2017 by Dimos7 Link to comment
Tomas Posted July 25, 2017 Share Posted July 25, 2017 (edited) 15 hours ago, Dimos7 said: on clientGUIClick is root not resourceRoot leson 1 also same with onAdminMute same root not resourceRoot resourceRoot works perfectly with onClientGUIClick, the problem here is the code's indentation, it's very messed. If you adjust it, it should work. Edited July 25, 2017 by Tomas Link to comment
Gastonito Posted July 30, 2017 Author Share Posted July 30, 2017 (edited) Bump, this is the final thing : Server : local mute_time = {} addEvent("onAdminMute", true) addEventHandler("onAdminMute", root, function (player, time) iprint("OK") if (not isElement(player)) then return end if (mute_time[player] or not time) then mute_time[player] = nil setPlayerMuted(player, false) outputChatBox(getPlayerName(player).. " has been unmuted by "..getPlayerName(client)) return end setPlayerMuted(player, true) mute_time[player] = getRealTime().timestamp + time end ) setTimer( function () for player, time in pairs(mute_time) do if (not isElement(player)) then mute_time[player] = nil else if (getRealTime().timestamp >= time) then outputChatBox(getPlayerName(player).. " has been unmuted by Console") setPlayerMuted(player, false) mute_time[player] = nil end end end end, 1000, 0) Client : addEventHandler("onClientGUIClick", root, function() if (source == mywind[18]) then local time = guiGridListGetSelectedItem(mywind[2]) local player = guiGridListGetItemText(mywind[16], guiGridListGetSelectedItem(mywind[16], 1)) if (time and player) then player = getPlayerFromName(player) if (not isElement(player)) then return end time = (time == 0 and 60*1000 or time == 1 and 120*1000 or time == 2 and 180*1000 or time == 3 and 240*1000 or time == 4 and 300*1000 or time == 5 ) triggerServerEvent("onAdminMute", root, player, time) return end elseif (source == mywind[17]) then local player = guiGridListGetItemText(mywind[16], guiGridListGetSelectedItem(mywind[16], 1)) if (player) then player = getPlayerFromName(player) if (not isElement(player)) then return end triggerServerEvent("onAdminMute", root, player) end end end ) The script isnt showing any error, but the mute thing isnt getting triggered, any help please ? i keep pressing on "Mute" button but Nothing happpens nor i'm getting any errors Edited July 30, 2017 by Gastonito Link to comment
Dimos7 Posted July 31, 2017 Share Posted July 31, 2017 addEventHandler("onClientGUIClick", root, function() if (source == mywind[18]) then local selectedTime = guiGridListGetSelectedItem(mywind[2]) local selectedPlayer = guiGridListGetItemText(mywind[16], guiGridListGetSelectedItem(mywind[16], 1)) if (selectedTime and selectedPlayer) then theselectedPlayer = getPlayerFromName(selectedPlayer) if (not isElement(theselectedPlayer)) then return end muteTime = (selectedTime == 0 and 60*1000 or selectedTime == 1 and 120*1000 or selectedTime == 2 and 180*1000 or selectedTime == 3 and 240*1000 or selectedTime == 4 and 300*1000 or selectedTime == 5 ) triggerServerEvent("onAdminMute", root, theselectedPlayer, muteTime) return end elseif (source == mywind[17]) then local selectedPlayer = guiGridListGetItemText(mywind[16], guiGridListGetSelectedItem(mywind[16], 1)) if (selectedPlayer) then theselectedPlayer = getPlayerFromName(selectedPlayer) if (not isElement(theselectedPlayer)) then return end triggerServerEvent("onAdminMute", root, theselectedPlayer) end end end ) dont put player and again player its confused try it like this its better 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