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
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)