Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- _G.CCSession = (_G.CCSession or 0) + 1
- returnList = {
- session = _G.CCSession,
- commandSymbol = ';',
- commandsList = {},
- started = false,
- enabled = true,
- deleteMessages = true
- }
- function returnList:setCommand(commandName, ...) --lowerString, helpText, Callback
- local settings;
- local Callback;
- local lowerString;
- local description;
- local helpText;
- if type(commandName) == 'table' then
- settings = commandName
- commandName = settings.Name
- Callback = settings.Callback
- lowerString = settings.lowerString
- description = settings.description or ''
- helpText = settings.helpText or description
- else
- settings = {...}
- Callback = settings[#settings]
- settings[#settings] = nil
- lowerString = settings[1]
- description = settings[2] or ''
- helpText = settings[3] or description
- end
- if type(commandName) == 'string' and type(Callback) == 'function' then
- if commandName ~= '' then
- returnList.commandsList[commandName] = {Callback = Callback, lowerString = lowerString, description = description, helpText = helpText}
- return returnList.commandsList[commandName]
- end
- end
- return 'error'
- end
- function returnList:getCommand(commandName)
- if commandName then
- if returnList.commandsList[commandName] then
- return returnList.commandsList[commandName]
- end
- for cmdName, settings in pairs(returnList.commandsList) do
- if string.lower(cmdName) == string.lower(commandName) and settings.lowerString then
- return returnList.commandsList[cmdName]
- end
- end
- end
- return nil
- end
- function returnList:systemMessage(msg)
- game.StarterGui:SetCore("ChatMakeSystemMessage", {
- Text = "[CC] "..tostring(msg),
- Color = Color3.fromRGB(255,255,255),
- Font = Enum.Font.Cartoon,
- FontSize = Enum.FontSize.Size24,
- })
- end
- function returnList:Start()
- returnList.started = true
- returnList.Start = function() returnList:systemMessage('Alredy started') end
- returnList.commandsList[''] = {Callback = function() returnList:systemMessage('Chat Commands by RomashkaHEHE') end}
- returnList:setCommand('list', true, 'print all commands', function()
- print()
- for cmdName, settings in pairs(returnList.commandsList) do
- if cmdName ~= '' then
- print(cmdName, settings.description ~= '' and '- '..settings.description or '')
- end
- end
- print()
- end)
- returnList:setCommand('help', true, 'saying helpText', function(command)
- local command = returnList:getCommand(command)
- if command then
- returnList:systemMessage(command.helpText ~= '' and command.helpText or "There's no helpText :(")
- else
- returnList:systemMessage('Wrong command name :( U can use list for more information')
- end
- end)
- returnList:systemMessage('Command symbole: '..returnList.commandSymbol)
- returnList:systemMessage('Use the "list" to print all commands in DEV console (F9)')
- returnList:systemMessage('Use the "help Command_Name" to get a description of the command')
- _G.chatHookFunc = function(self, ...)
- local arguments = {...}
- if returnList.enabled and self.Name == 'SayMessageRequest' and string.lower(getnamecallmethod()) == 'fireserver' and type(returnList.commandSymbol) == 'string' and arguments[1] then
- local message = arguments[1]
- if string.sub(message, 1, #returnList.commandSymbol) == returnList.commandSymbol then
- message = string.sub(message, #returnList.commandSymbol+1, #message)
- local gmatch = string.gmatch(message, '%S+')
- local command = gmatch() or ''
- local commandArguments = {}
- for word in gmatch do
- table.insert(commandArguments, word)
- end
- local command = returnList:getCommand(command)
- if command then
- command.Callback(unpack(commandArguments))
- end
- if returnList.deleteMessages then
- return nil
- end
- end
- end
- return _G.chatHook(self, ...)
- end
- if not _G.chatHook then
- _G.chatHook = hookmetamethod(game, '__namecall', function(self, ...)
- if _G.chatHookFunc then
- return _G.chatHookFunc(self, ...)
- end
- return _G.chatHook(self, ...)
- end)
- end
- end
- return returnList
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement