Hello, guys, I’m back with another script. This is a very simple script but I hope it can help you out . This script deletes any misspelled or unknown commands from displaying in chat like:
to displaying nothing. All commands will still work if executed, this is to remove the /help’s when there’s a full server or something similar.
AddEventHandler('chatMessage', function(Source, Name, Msg)
args = stringsplit(Msg, " ")
CancelEvent()
if string.find(args[1], "/") then
local cmd = args[1]
table.remove(args, 1)
end
end)
wtf am I reading? Why split the string? Why cancel the event without checking if it starts with a “/” (wouldn’'t this stop all messages)? Why are you storing the first argument in a variable which is never used? Why are you removing the first argument?
It does cancel out everything. I tried it on my server, but people could no longer use the chat, unless using an actual working command (/ooc, /me, /say etc.).
Since you are looking into it anyways, could you also add a little error message when someone types an unknown/mis-spelled command? Something like: “Unknown command. Are you sure you typed the command correctly?”.
Maybe an extra challenge, for you, or someone else, maybe have a feature/resource which would ‘disable capitalization on commands’. So let’s say a player types /RESPAWN instead of /respawn, and that the command will still work. (sorry if there is already a resource out there for this, couldn’t find it.)
Well for the capitalisation you can do that in a script already by using the RegisterCommand function. To memory this will send the command as a lowercase it this is used for each command.