Microphone - iimurpyh/pilot-lua GitHub Wiki
A device which allows you to recieve player chat messages.
Table of contents
Events
Event "Chatted" (string Player, string message)
An event which fires when a Player sends a chat message.
Code example
Runs a command only if the whitelisted player wrote it.
local mic = GetPartFromPort(1, "Microphone")
local whitelisted = {
["Your_name_here"] = true
}
local commands = {
-- ...
}
local function runCommand(msg)
local args = msg:split(" ")
local cmd = args[1]
table.remove(args, 1)
if(commands[cmd])then
commands[cmd](args)
end
end
mic:Connect("Chatted", function(Player, msg)
if(whitelisted[Player])then
runCommand(msg)
end
end)