Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create antichat.lua #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions antichat/antichat.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
modname="Antichat"
version="1.0"

function et_InitGame()
et.RegisterModname(modname.." "..version)
end
-- Antichat by Ryven
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait what? I have no memory of this script D:

-- Allow only wolfadmin commands to be passed

local blackList = { "say", "say_team", "say_buddy", "say_teamnl", "m", "pm" }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this mod could be effectively called vsay fest :D

local whitelist = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the point in hardcoding wolfadmin stuff, like why being responsible for maintaining the list? Instead you could just suggest people to put wofladmin first to load in the lua modules list, then it will be able to parse its own stuff first, then passing control further here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, there is blackList with uppercase L and also whitelist with lowercase l. This should be standarized to lowercase probably ;)

"!help",
"!admintest",
"!greeting",
"!rules",
"!stats",
"!sprees",
"!listmaps",
"!time",
"!listplayers",
"!finger",
"!listaliases",
"!listlevels",
"!showwarns",
"!showhistory",
"!dewarn",
"!showbans",
"!warn",
"!put",
"!mute",
"!unmute",
"!vmute",
"!vunmute",
"!plock",
"!punlock",
"!kick",
"!ban",
"!unban",
"!slap",
"!gib",
"!setlevel",
"!incognito",
"!balance",
"!lock",
"!unlock",
"!shuffle",
"!shufflesr",
"!spec999",
"!swap",
"!cointoss",
"!nextmap",
"!pause",
"!unpause",
"!reset",
"!restart",
"!enablevote",
"!needbots",
"!kickbots",
"!putbots",
"!readconfig",
"!listlevels",
"!resetsprees"
}

local function contains(table, value)
if value == "" then
return false
end
for i = 1, #table do
if table[i] == value then
return true
end
end
return false
end

function et_ClientCommand(clientNum, command)
if contains(blackList, command) then
local arg = et.trap_Argv(1)
if not contains(whitelist, arg) then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't work in case shrub command will have arguments. Argv 1 will return full text string passed to say or other command, not just the first word of it, instead you would have to partially match the sub string.

return 1
end
end
return 0
end