Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local shell=require("shell")
- local component = require("component")
- local debug = component.debug
- local args, options = shell.parse(...)
- -------------- Functions --------------
- local function setGamemode(player, gamemode)
- if player ~= nil and gamemode ~= nil then
- if gamemode == "survival" or gamemode == "creative" or gamemode == "adventure" or gamemode == "spectator" then
- local p1 = debug.getPlayer(player)
- local players = debug.getPlayers()
- local f1 = false, false
- for i, v in ipairs(players) do
- if v == player then f1 = true end
- end
- if f1 then
- p1.setGameType(gamemode)
- else
- print("Player not found!")
- end
- else
- print("Invalid gamemode!")
- end
- else
- print("Player or gamemode can't be nil!")
- end
- end
- local function getGamemode(player)
- if player ~= nil then
- local p1 = debug.getPlayer(player)
- local players = debug.getPlayers()
- local f1 = false, false
- for i, v in ipairs(players) do
- if v == player then f1 = true end
- end
- if f1 then
- return p1.getGameType()
- else
- print("Player not found!")
- return nil
- end
- else
- print("Player can't be nil!")
- return nil
- end
- end
- -------------- Main Code --------------
- if #args == 1 then
- local gm = getGamemode(args[1])
- if gm ~= nil then
- print(gm)
- end
- elseif #args == 2 then
- if args[2] == "0" then
- args[2] = "survival"
- elseif args[2] == "1" then
- args[2] = "creative"
- elseif args[2] == "2" then
- args[2] = "adventure"
- elseif args[2] == "3" then
- args[2] = "spectator"
- end
- setGamemode(args[1], args[2])
- else
- print("Usage:")
- print("gamemode <username> [gamemode]")
- return 1
- end
Add Comment
Please, Sign In to add comment