Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function DenyCommand(errorCode, client)
- local text = {}
- text["DEAD"] = "You need to be alive to use this command."
- text["HEADSET"] = "You need a working headset to use this command."
- text["NOSPEAK"] = "You need to be able to speak to use this command."
- text["SPAM"] = "You need to wait a little bit to use this command again."
- Game.SendDirectChatMessage("", text[errorCode], nil, ChatMessageType.ServerMessageBox, client)
- return true
- end
- local spamLimit = 0
- Hook.Add("chatMessage", "captainAnnounce", function (message, client)
- local split = {}
- for w in string.gmatch(message, "[^%s]+") do
- table.insert(split, w)
- end
- local command = table.remove(split, 1)
- if command ~= "!g" then return end
- if Timer.GetTime() < spamLimit then return DenyCommand("SPAM", client) end
- if client.Character == nil or client.Character.IsDead or not client.Character.IsHuman then
- return DenyCommand("DEAD", client)
- end
- if client.Character.SpeechImpediment > 99 then return DenyCommand("NOSPEAK", client) end
- local headsetSlot = client.Character.Inventory.GetItemInLimbSlot(InvSlotType.Headset)
- if headsetSlot == nil then return DenyCommand("HEADSET", client) end
- local wifiComponent = headsetSlot.GetComponentString("WifiComponent")
- if wifiComponent == nil or not wifiComponent.CanTransmit() then
- return DenyCommand("HEADSET", client)
- end
- local captainMessage = table.concat(split, ' ')
- if captainMessage == nil then return end
- local chatMessage = ChatMessage.Create(client.Name, captainMessage, ChatMessageType.Private, nil)
- chatMessage.Color = Color(255, 255, 0, 255)
- for key, value in pairs(Client.ClientList) do
- Game.SendDirectChatMessage("GLOBAL: " .. chatMessage, value)
- end
- Game.Log(client.Name .. " sent a global message: " .. captainMessage, ServerLogMessageType.Chat)
- spamLimit = Timer.GetTime() + 1
- return true
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement