Skip to content

Commit

Permalink
Merge pull request #87 from Bluethefurry/chat-muting
Browse files Browse the repository at this point in the history
Chat muting
  • Loading branch information
Blumlaut authored May 27, 2019
2 parents 518b810 + e2c1690 commit 61704a1
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 2 deletions.
28 changes: 26 additions & 2 deletions admin_server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ permissions = {
screenshot = false,
immune = false,
anon = false,
mute = false,
}
-- Muted Players Table
MutedPlayers = {}


AnonymousAdmins = {}
Expand Down Expand Up @@ -339,7 +342,21 @@ Citizen.CreateThread(function()
SendWebhookMessage(moderationNotification,string.format(GetLocalisedText("adminunbannedplayer"), getName(source), playerId))
end
end)


RegisterServerEvent("EasyAdmin:mutePlayer")
AddEventHandler('EasyAdmin:mutePlayer', function(playerId)
local src = source
if DoesPlayerHavePermission(src,"easyadmin.mute") then
if not MutedPlayers[playerId] then
MutedPlayers[playerId] = true
TriggerClientEvent("chat:addMessage", src, { args = { "EasyAdmin", GetPlayerName(playerId) .. " " .. GetLocalisedText("playermuted") } })
else
MutedPlayers[playerId] = nil
TriggerClientEvent("chat:addMessage", src, { args = { "EasyAdmin", GetPlayerName(playerId) .. " " .. GetLocalisedText("playerunmuted") } })
end
end
end)

RegisterServerEvent("EasyAdmin:SetAnonymous")
AddEventHandler('EasyAdmin:SetAnonymous', function(playerId)
if DoesPlayerHavePermission(source,"easyadmin.anon") then
Expand Down Expand Up @@ -607,11 +624,18 @@ Citizen.CreateThread(function()
end
end
end)


AddEventHandler('chatMessage', function(Source, Name, Msg)
if MutedPlayers[Source] then
CancelEvent()
TriggerClientEvent("chat:addMessage", Source, { args = { "EasyAdmin", GetLocalisedText("playermute") } })
end
end)


---------------------------------- USEFUL


function SendWebhookMessage(webhook,message)
if webhook ~= "false" then
PerformHttpRequest(webhook, function(err, text, headers) end, 'POST', json.encode({content = message}), { ['Content-Type'] = 'application/json' })
Expand Down
9 changes: 9 additions & 0 deletions gui_c.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ permissions = {
screenshot = false,
immune = false,
anon = false,
mute = false,
}

_menuPool = NativeUI.CreatePool()
Expand Down Expand Up @@ -251,6 +252,14 @@ function GenerateMenu() -- this is a big ass function

end

if permissions.mute then
local thisItem = NativeUI.CreateItem(GetLocalisedText("mute"),GetLocalisedText("muteguide"))
thisPlayer:AddItem(thisItem)
thisItem.Activated = function(ParentMenu,SelectedItem)
TriggerServerEvent("EasyAdmin:mutePlayer", GetPlayerServerId( thePlayer ))
end
end

if permissions.spectate then
local thisItem = NativeUI.CreateItem(GetLocalisedText("spectateplayer"), "")
thisPlayer:AddItem(thisItem)
Expand Down
5 changes: 5 additions & 0 deletions language/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
"banlengthguide":"Bis wann soll der Spieler gebannt werden?",
"confirmban":"Ban Bestätigen",
"confirmbanguide":"~r~~h~ACHTUNG:~h~~w~ Bestätigen drücken wird den Spieler mit den angegebenen Daten Bannen.",
"mute":"Spieler stumm schalten",
"muteguide":"~r~~h~NOTE:~h~~w~ Dadurch wird verhindert, dass der Player den Text-Chat verwendet.",
"playermuted":"wurde stumm geschaltet!",
"playerunmuted":"wurde nicht stummgeschaltet!",
"playermute":"Du bist ^8stumm^7!",
"spectateplayer":"Spieler Zuschauen",
"teleporttoplayer":"Zu Spieler Teleportieren",
"teleportplayertome":"Spieler zu mir Teleportieren",
Expand Down
5 changes: 5 additions & 0 deletions language/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
"banlengthguide":"Until when should the Player be banned?",
"confirmban":"Confirm Ban",
"confirmbanguide":"~r~~h~NOTE:~h~~w~ Pressing Confirm will ban this Player with the specified settings.",
"mute":"Mute Player",
"muteguide":"~r~~h~NOTE:~h~~w~ This will prevent the player from using the text chat.",
"playermuted":"has been muted!",
"playerunmuted":"has been un-muted!",
"playermute":"You are ^8muted^7!",
"spectateplayer":"Spectate Player",
"teleporttoplayer":"Teleport to Player",
"teleportplayertome":"Teleport Player to Me",
Expand Down
5 changes: 5 additions & 0 deletions language/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
"banlength":"Temps du bannissement",
"banlengthguide":"Jusqu'à quand le joueur doit être banni?",
"confirmban":"Confirmer le bannissement",
"mute":"Joueur muet",
"muteguide":"~r~~h~NOTE:~h~~w~ Cela empêchera le joueur d’utiliser le chat textuel.",
"playermuted":"a été mis en sourdine!",
"playerunmuted":"a été mis en sans sourdine!",
"playermute":"Vous êtes ^8muet^7!",
"confirmbanguide":"~r~~h~NOTE:~h~~w~ Appuyer sur confirmer va ~r~~h~bannir~h~~w~ le joueur avec les paramètres specifiés.",
"spectateplayer":"Regarder le joueur",
"teleporttoplayer":"Téléportation au joueur",
Expand Down
5 changes: 5 additions & 0 deletions language/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
"banlengthguide":"Fino a quando dovrà essere bandito il giocatore?",
"confirmban":"Conferma il Ban",
"confirmbanguide":"~r~~h~NOTA:~h~~w~ Premendo conferma bandirai il giocatore con le impostazioni correnti.",
"mute":"Giocatore muto",
"muteguide":"~r~~h~NOTE:~h~~w~ Ciò impedirà al giocatore di utilizzare la chat di testo.",
"playermuted":"è stato disattivato!",
"playerunmuted":"è stato un-muted!",
"playermute":"Sei ^8disattivato^7!",
"spectateplayer":"Spetta Giocatore",
"teleporttoplayer":"Teletrasportami al giocatore",
"teleportplayertome":"Teletrasporta il Giocatore da Me",
Expand Down
5 changes: 5 additions & 0 deletions language/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
"noreason": "Geen reden opgegeven",
"confirmkick": "Bevestig Kick",
"confirmkickguide": "~r~~h~NOTE:~h~~w~ Als je op bevestigen drukt wordt deze Speler gekickt.",
"mute":"Demp speler",
"muteguide":"~r~~h~NOTE:~h~~w~ Dit voorkomt dat de speler de tekstchat gebruikt.",
"playermuted":"is gedempt!",
"playerunmuted":"is niet-gedempt!",
"playermute":"Je bent ^8gedempt^7!",
"banreasonguide": "Voeg een reden toe aan de ban.",
"banlength": "Ban Lengte",
"banlengthguide": "Hoelang moet de Speler verbannen worden?",
Expand Down
5 changes: 5 additions & 0 deletions language/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
"banlengthguide":"Do kiedy powinien zostać zbanowany Gracz?",
"confirmban":"Potwierdź bana",
"confirmbanguide":"~r~~h~UWAGA:~h~~w~ Naciśnięcie potwierdź spowoduje zablokowanie tego gracza z określonymi ustawieniami.",
"mute":"Niemy Gracz",
"muteguide":"~r~~h~NOTE:~h~~w~ Uniemożliwi to graczowi korzystanie z czatu tekstowego",
"playermuted":"został wyciszony!",
"playerunmuted":"został bez wyciszenia!",
"playermute":"Jesteś ^8wyciszony^7!",
"spectateplayer":"Obserwuj gracza",
"teleporttoplayer":"Teleport do gracza",
"teleportplayertome":"Teleportuj gracza do mnie",
Expand Down
5 changes: 5 additions & 0 deletions language/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
"banlengthguide":"Até quando o jogador deve ser banido?",
"confirmban":"Confirme Banimento",
"confirmbanguide":"~r~~h~NOTA:~h~~w~ Pressionar Confirmar banirá este Player com as configurações especificadas.",
"mute":"Mudo Jogador",
"muteguide":"~r~~h~NOTE:~h~~w~ Isso impedirá que o jogador use o bate-papo de texto.",
"playermuted":"foi silenciado!",
"playerunmuted":"foi un-silenciado!",
"playermute":"tu es ^8silenciado^7!",
"spectateplayer":"Spectate Jogador",
"teleporttoplayer":"Teleportar para o jogador",
"teleportplayertome":"Teleportar jogador para mim",
Expand Down
5 changes: 5 additions & 0 deletions language/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
"banlengthguide":"Hur länge ska spelaren vara bannad?",
"confirmban":"Konfirmera bannlysning",
"confirmbanguide":"~r~~h~OBS:~h~~w~ Att klicka på Konfirmera kommer bannlysa denna Spelare med de specifierade inställningarna.",
"mute":"Dämpa Spelare",
"muteguide":"~r~~h~NOTE:~h~~w~ Detta förhindrar att spelaren använder textchatten.",
"playermuted":"har blivit dämpad!",
"playerunmuted":"har blivit un-dämpad!",
"playermute":"Du är ^8dämpad^7!",
"spectateplayer":"Åskåda Spelare",
"teleporttoplayer":"Teleportera till Spelare",
"teleportplayertome":"Teleportera Spelare till Mig",
Expand Down

0 comments on commit 61704a1

Please sign in to comment.