[RELEASE] vRP_disablechat | Admins can disable & clear the chat!

Also tired of kids spamming the OOC chat? Then this resource is for you.

This resource lets admins access following commands:

/disablechat - This disables the chat for everyone, except players who have the bypass permission. Enter this command again to re-enable the chat.

/clearchat - This clears the chat for everyone. Uses same permission as disablechat.

Installation instructions are in the readme.md on the github, and are pretty straight forward. This resource is in danish by default, but you can translate it in vrp_disablechat/cfg.lua

Preview

Admin Perspective: https://gyazo.com/05bbd9bf143cd7a9ecc9ad25aacca77e
Player Perspective: https://gyazo.com/3f5b80bb0e39b38449354f09d0eae8ce (These messages only show for the player, and not for the whole server)
Clear Chat: https://gyazo.com/5e1bb2ac275b24948cb7ee5a24c0f919

This can be downloaded here: https://github.com/oMarkez/vrp_disablechat

2 Likes

Thanks for this as now my chat will not be spammed

1 Like

Can it be made so it only get’s disabled for users group?

Well, either you have to add a permission to all of the other groups, else make a table with allowed groups/permissions, or simply check for a specific job.

heres the English version vrp_disablechat_en.zip (24.0 KB)

This is really helpful ,but I think someone have released it before.

why is there a need for vRP for this isn’t this easy to have standalone

Eh, to make it permission based so everyone cannot use the commads?

Honestly, I don’t know and couldn’t care. All of the code is written by me.

Thanks mate :slight_smile:

Well /clearchat does already exist, but /disablechat is awesome! Good one! :wink:

If you want I could take a look at your code and rewrite it for add_ace permissions. I wouldn’t upload it again, just post a comment to make it a standalone, If this is ok for you :wink:

Take a :hamburger:

1 Like

Thanks mate :slight_smile:

Yeah sure, go ahead. I will include the add_ace permission download link in the topic

1 Like

Ahh okay thanks for the info i don’t use vRP that much so yeah can you please make 1 ace permitions version

So, here is the Standalone-version, but you have to know that if the chat is disabled there will be twice messages that will be shown, maybe you can fix this, I need to work on my own project sorry :sweat_smile:

Server.lua

Do paste this into your server.cfg, then it should work:

------------------------CREDITS------------------------
-------- Script made by oMarkez --------
– Script made for ByensRP 11/02/2019 –
– Copyright 2019 ©oMarkez. All rights reserved –
– Standalone Version by Real-RP –

–[[

  How to add a new admin:
  add these lines to you're server.cfg at the very top:
  
  add_ace group.disable disable allow
  
  add_principal identifier.steam:110000000abcd12 group.disable 
  
  paste your steam identifier after steam: HEXID
  this will give access to disable the chat, enable it, write when you've disabled the chat.
  how to get your steam Identifier:
  
  To find your steam ID, go to the steam interface, hover over your name and select profile.
  From here right click anywhere on the page and select 'copy url'. Open a web browser and paste
  it into the URL box. The string of numbers is your profile ID / community ID / Identifier / HEXID.

]]–

 cfg = getConfig()
 local disabled = false
 
 RegisterServerEvent('_chat:messageEntered')
 
 
 RegisterServerEvent("disableChat") --gives message of active or not
 AddEventHandler("disableChat", function()
 	if IsPlayerAceAllowed(source, "disable") then
 			disabled = not disabled
 			if disabled then
 				TriggerClientEvent('chatMessage', -1, cfg.messages.name,  {249, 77, 20}, cfg.messages.off)
 			else
 				TriggerClientEvent('chatMessage', -1, cfg.messages.name,  {249, 77, 20}, cfg.messages.on)
 		end
 	end
 end)
 	
 RegisterServerEvent("disableChat")
 AddEventHandler("disableChat", function()	
 	if not IsPlayerAceAllowed(source, "disable") then
 		TriggerClientEvent('chatMessage', source, cfg.messages.noperm, {249, 77, 20})
 	end
 end)
 
 RegisterServerEvent("clearChat")
 AddEventHandler("clearChat", function()
 	    if IsPlayerAceAllowed(source, "disable") then --took the same perms name here, so you don't need to give 2 permissions
 			TriggerClientEvent("chat:clear", -1)
 			TriggerClientEvent('chatMessage', -1, cfg.messages.name, {249, 77, 20}, cfg.messages.clearedchat)
 		end
 	end)
 	
 RegisterServerEvent("clearChat")
 AddEventHandler("clearChat", function()
 	if not IsPlayerAceAllowed(source, "disable") then
 		TriggerClientEvent('chatMessage', source, cfg.messages.noperm, {249, 77, 20})
 	end
 end)
 
 
 		
 AddEventHandler("_chat:messageEntered", function(author, color, message)
 	if not message or not author then
         return
 	end
 	
 author = " "
 user_id = " "
 
 	TriggerEvent('chatMessage', source, author, message)
 
 	if disabled then
 		if not IsPlayerAceAllowed(source, "disable") then
 			CancelEvent()
 			TriggerClientEvent('chatMessage', source, cfg.messages.name, {249, 77, 20}, cfg.messages.currentlyoff)
 		else
 			TriggerClientEvent('chatMessage', -1, "^0[^1STAFF^0] " .. author .. " | ^0(^1" .. user_id .. "^0): ",  { 128, 128, 128 }, message)
 			CancelEvent()
 		end
 	end
 		
 	if not WasEventCanceled() and not disabled then
 		TriggerClientEvent('chatMessage', -1, "^0[^1OOC^0] " .. author .. " | ^0(^1" .. user_id .. "^0): ",  { 128, 128, 128 }, message)
 	end
 	
 	CancelEvent()
 end)

Have a nice day and don’t forget your :hamburger: :smiley:
@godgutten
@oMarkez

2 Likes