Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- speakers = {“mlg″, “DevDane″, “T0tallyN0tATr0ll”} — Those who can say the command. change this into the names you want.
- banned = {“EvilPerson”, “BadUsername”, “MrEnemy”} — Those who are banned
- function checkSpeakers(name)
- — check if name matches a speaker
- for i,v in pairs(speakers) do
- — convert names to all upper case, otherwise we will allow
- — “Telamon” but not “telamon” or “tELAMON”
- if (string.upper(name) == string.upper(v)) then return true end
- end
- return false
- end
- function banPlayer(banner, victim)
- — remove if the victim is not also the speaker
- if (victim ~= banner) then
- victim:kick("shrektbyadmin")
- banned[victim.Name] = victim.Name
- end
- end
- function matchPlayer(str)
- — find all players that start with the str
- — if there is only one, match it
- — 0 or 2+, don’t match it
- local result = nil
- local players = game.Players:GetPlayers()
- for i,v in pairs(game.Players:GetPlayers()) do
- if (string.find(string.lower(v.Name), str) == 1) then
- if (result ~= nil) then return nil end
- result = v
- end
- end
- return result
- end
- function onChatted(msg, recipient, speaker)
- — convert to all lower case
- local source = string.lower(speaker.Name)
- msg = string.lower(msg)
- — ban the following players
- — “ban telamon buildman wookong”
- if (string.find(msg, “ban”) == 1) then — msg starts with “ban”
- — words and numbers
- for word in msg:gmatch(“%w+”) do
- local p = matchPlayer(word)
- if (p ~= nil) then
- banPlayer(speaker, p)
- end
- end
- end
- end
- function onPlayerEntered(newPlayer)
- — remove banned player if they try to come back in
- for i,v in pairs(banned) do
- if (v:lower() == newPlayer.Name:lower()) then
- newPlayer:kick("BannedFromServer)
- end
- end
- if checkSpeakers(newPlayer.Name) then
- newPlayer.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end)
- end
- end
- game.Players.PlayerAdded:connect(onPlayerEntered)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement