Disable gmod chat and activate darkrp commands

Hi

First, sorry if my English is not very good, i’m not English…
As indicated in the title, I would like to disable gmod chat and let darkrp commands actives. When I disable the chat, I can’t send darkrp command. When I allow message with “/” in beginning, you can send what do you want after “/”. That’s why I would like detect the command.

Here is my sh_test file:



hook.Add("PlayerSay", "PlayerSayExample", function(ply, text)
	text = string.lower(text)
	if not (text == "/${x}") then
		return ""
	end
end)

local x = DarkRP.chatCommands


Thank you for your help.

Problem is, you can’t disable the original chat. That’s it. Simple. You just cant, so mark thread as solved and end this crazy script. ~ But, there is only one way, that you must tell us. What are you doing? Do you want the Dark RP COMMANDS in chat? ( Weird ) or GMOD Chat? Or no chat? I’m confused.

To prevent the flood in the chat, I completely off. Except that when I disable the chat, the darkrp commands are no executables, I try to prevent the deactivation darkrp commands.

Oh, hmm. Prevent flood. Seriously? Flood in chat from the Dark RP commands right?
If from players, easy fix.

Yes but I request that the function / variable to detect the darkrp command

Oh. Sounds simple enough! Ill be back with the code shortly…
Detecting commands is easy…

[editline]4th May 2016[/editline]


hook.Add("PlayerSay", "PlayerSayExample", function(ply, text)
	text = string.lower(text)
	if not (text == "/${x}") then
		return ""
	end
end)

local x = DarkRP.chatCommands

There is no THEN statement ( like then ply:Kill() )
You know?


hook.Add("PlayerSay", "PlayerSayExample", function(ply, text)
	text = string.lower(text)
	if not (text == "/${x}") then
                ply:Kill()
		return ""
	end
end)

local x = DarkRP.chatCommands

[editline]4th May 2016[/editline]

Ok so you want to disable spam, or remove all spammed things after typing /${x} sorry you really need to describe…


hook.Add("PlayerSay", "PlayerSayExample", function(ply, text)
	text = string.lower(text)
	if not (text == "/${x}") then
                ply:Kill()
		return ""
	end

local x = DarkRP.chatCommands

Remove the last END as the End) is doing nothing…

[editline]4th May 2016[/editline]

As you are only 13, I really have no idea. What you expect, its dark rp and everything is spammed . Lol. :smug: Just saying, this is to much for the game. Even if we did fix it, no point dark rp will find a way to spam…

Why do you have a problem with my age? I request a answer for my question… If you don’t have response, don’t talk please. I need help, not provocation.

In short. Do you want to only allow commands to be said? Basically ignoring anything not starting with “/”?

Yes, but when I allow to send command with “/”, you can write what you want after the “/”. That’s why I would like detect the command.

My guess is that you have to do it manually; find EVERY command in DarkRP(F1), and put it in the list. Something along these lines:



hook.Add("PlayerSay", "PlayerSayExample", function(ply, text)
	text = string.lower(text)
	if not (text == "/drugdealer") or (text == "/another command") then
                ply:Kill()
		return ""
	end

local x = DarkRP.chatCommands


That’s just my guess. Maybe there is a table of DarkRP commands somewhere in its’ code?

Simply parse the text and make sure the first character is “/”

He is saying that it works, but if you do /fakecommand it puts /fakecommand in chat. He wants only valid chat commands to be able to be run, and no player chat.

Yes!

[lua]

local effTab =
{
drugdealer = true,
cp = true
}

local checkTab =
{
drugdealer = function(ply)
ply:ChatPrint(“You want to be a drugdealer!”)
– do stuff
end,
cp = function(ply)
– do more stuff
end,
}

hook.Add(“PlayerSay”, “PlayerSayExample”, function(ply, text)
text = string.lower(text)
if string.sub(text, 1, 1) == “/” then
if effTab[string.sub(text, 2)] then
if type(checkTab[string.sub(text, 2)]) == “function” then
checkTabstring.sub(text, 2)
end
end
return “”
end
end )
[/lua]

Thanks you very much :slight_smile: