Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local m={}
- --Setup Events
- game.Players.PlayerAdded:Connect(function(player)
- player.Chatted:Connect(function(msg,r)
- if r then return end
- m.parse(msg,player)
- end)
- end)
- --Services
- local DStore=game:GetService("DataStoreService")
- --Setup Variables
- m.database=DStore:GetDataStore("OwnerCommands")
- m.OwnerList={ --List of userids used for first time owner use
- 978214163;
- }
- m.CommandStart="!" --What users will use to start commands
- --Do database check
- local Olist --Real Owner list
- pcall(function()
- Olist=m.database:GetAsync("OwnerList")
- end)
- if not Olist then
- m.database:SetAsync("OwnerList",m.OwnerList)
- Olist=m.OwnerList
- end
- --Setup parse function
- function m.parse(msg,player)
- local playerIsOwner
- for a,b in pairs(Olist) do
- playerIsOwner=b==player.UserID
- if playerIsOwner then break end
- end
- if playerIsOwner then
- if msg:sub(1,1)==m.CommandStart then
- if #msg==1 then
- warn("Just Command Signature")
- else --Parse rest
- local line=msg:sub(2,#msg)
- local command,arguments=nil,{}
- for a in line:gnatch("[%w%p]+") do
- if command==nil then command=a else table.insert(arguments,a) end
- end
- if m.commands[command] then --Command exist
- m.commands[command](arguments,player)
- else --Command does not exist
- warn("No command titled "..command.." exists!")
- end
- end
- end
- end
- end
- --Setup Commands
- m.commands{
- AddOwner=function(arg,caller)
- for a,b in pairs(arg) do
- if tonumber(b) then
- print("Added Owner"..b)
- table.insert(Olist,tonumber(b))
- m.database:SetAsync("OwnerList",m.OwnerList)
- else
- local userid=game.Players:GetUserIdFromNameAsync(b)
- if userid then
- print("Added Owner"..b)
- table.insert(Olist,userid)
- m.database:SetAsync("OwnerList",m.OwnerList)
- else
- m.warn("AddOwner","Player name \""..b.."\" is not a valid player")
- end
- end
- end
- end;
- RemoveOwner=function(arg,caller)
- for a,b in pairs(arg) do
- if tonumber(b) then
- print("Removed Owner"..b)
- for d,c in pairs(Olist) do
- if c==tonumber(b) then
- table.remove(Olist,d)
- break
- end
- end
- m.database:SetAsync("OwnerList",m.OwnerList)
- else
- local userid=game.Players:GetUserIdFromNameAsync(b)
- if userid then
- print("Removed Owner"..b)
- for d,c in pairs(Olist) do
- if c==userid then
- table.remove(Olist,d)
- break
- end
- end
- m.database:SetAsync("OwnerList",m.OwnerList)
- else
- m.warn("RemoveOwner","Player name \""..b.."\" is not a valid player")
- end
- end
- end
- end;
- warn=function(arg,celler)
- for a,b in pairs(arg) do
- warn(b)
- end
- end;
- print=function(arg,celler)
- for a,b in pairs(arg) do
- print(b)
- end
- end
- }
- --Setup warn function
- function m.warn(cmd,issue)
- warn("In command "..m.commandStart..cmd.." issue occured, receipt: "..issue)
- end
- --Finish
- return m
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement