Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PLUGIN.Title = "uberArena"
- PLUGIN.Description = "Automated deathmatch Arena"
- PLUGIN.Author = "Senorderp"
- PLUGIN.Version = "0.6.8b"
- function PLUGIN:Init()
- --Spawns
- self.UArenaSpawnFile = util.GetDatafile("uarenaspawns")
- local json_txt = json.decode(self.UArenaSpawnFile:GetText())
- if not json_txt then
- json_txt = {}
- self.FirstSpawnLoad = true
- end
- self.UArenaSpawn = json_txt
- --ArenaLimbo
- self.ArenaLimboFile = util.GetDatafile("arenalimbo")
- local json_txt2 = json.decode(self.ArenaLimboFile:GetText())
- if not json_txt2 then
- json_txt2 = {}
- end
- self.ArenaLimbo = json_txt2
- --Config
- local b, res = config.Read("uberarena")
- self.Config = res or {}
- if (not b) then
- self:LoadDefaultConfig()
- config.Save( "uberarena" )
- end
- oxmin_Plugin = plugins.Find( "oxmin" )
- if not oxmin_Plugin or not oxmin then
- self.oxminInstalled = false
- else
- self.FLAG_UAControls = oxmin.AddFlag( "canuaconfig" )
- self.oxminInstalled = true
- end
- --Add commands
- self:AddChatCommand ("jt", self.RequestJoin)
- self:AddChatCommand ("ua", self.UArenaCommands)
- self:AddChatCommand ("uaconfig", self.AdminUArenaCommands)
- self:AddChatCommand ("leaveq", self.LeaveQ)
- self:AddChatCommand ("uastatus", self.UAStatusCommands)
- --Tables
- self.Roster = {}
- self.Team = {}
- self.Team[0] = 0
- self.Team[1] = 0
- self.Team[2] = 0
- self.Team[99] = 0
- --Config
- if (not(self.Config.RandomTeams)) then
- self.Config.RandomTeams = false
- end
- self.ArenaOn = self.Config.OnByDefault
- self.QueueTime = self.Config.QueueTime
- self.MinPlayer = self.Config.MinPlayer
- self.MaxPlayer = self.Config.MaxPlayer
- self.ArenaAlert = (self.Config.QueueTime - self.Config.AlertTime)
- self.MatchTime = (self.Config.MatchTime + self.Config.QueueTime)
- self.MinPlayerReward = self.Config.MinPlayerReward
- self.Reward = self.Config.Reward
- self.Medkit = self.Config.Medkit
- self.MedkitQuantity = self.Config.MedkitQuantity
- self.BandageQuantity = self.Config.BandageQuantity --can not be greater than 5
- self.WepAttachments = self.Config.WepAttachments
- self.WepAttachQuan = self.Config.WepAttachQuan
- self.Ammo = self.Config.Ammo
- self.AmmoQuantity = self.Config.AmmoQuantity
- self.T1Armor = self.Config.T1Armor
- self.T1Guns = self.Config.T1Guns
- self.T2Armor = self.Config.T2Armor
- self.T2Guns = self.Config.T2Guns
- self.FriendlyFire = self.Config.FriendlyFire
- self.RandomTeams = self.Config.RandomTeams
- --Globals
- self.PlayerCount = 0
- self.ArenaTock = 0
- --Timer
- disqualtimer = 1
- self.ArenaTimer = timer.Repeat(1, 0, function() self:ArenaTick() end )
- if (self.ArenaOn) and (not(self.FirstSpawnLoad)) then
- self.CanQueue = true
- elseif ((self.ArenaOn) and (self.FirstSpawnLoad == true))then
- self.ArenaOn = nil
- print("uberArena: Set your spawnpoints before turning on!")
- end
- print("uberArena version " .. self.Version .. " successfully loaded!")
- end
- function PLUGIN:UArenaDebug(netuser)
- print("ArenaTock: " .. self.ArenaTock)
- print("user: " .. self.Roster[userID])
- print("netuser: " .. self.Roster[userID].UArenaNetUser)
- print("PlayerCount: " .. self.PlayerCount)
- end
- function PLUGIN:UArenaConfigPull()
- self.QueueTime = self.Config.QueueTime
- self.MinPlayer = self.Config.MinPlayer
- self.MaxPlayer = self.Config.MaxPlayer
- self.ArenaAlert = (self.Config.QueueTime - self.Config.AlertTime)
- self.MatchTime = (self.Config.MatchTime + self.Config.QueueTime)
- self.MinPlayerReward = self.Config.MinPlayerReward
- self.Reward = self.Config.Reward
- self.FriendlyFire = self.Config.FriendlyFire
- self.RandomTeams = self.Config.RandomTeams
- end
- function PLUGIN:LoadDefaultConfig()
- self.Config.OnByDefault = true
- self.Config.FriendlyFire = "on"
- self.Config.QueueTime = 60
- self.Config.MinPlayer = 2
- self.Config.MaxPlayer = 8
- self.Config.AlertTime = 20
- self.Config.MatchTime = 300 -- 5 minutes
- self.Config.MinPlayerReward = 4
- self.Config.Reward = {}
- self.Config.Medkit = "Small Medkit"
- self.Config.MedkitQuantity = 3
- self.Config.BandageQuantity = 5 --can not be greater than 5
- self.Config.WepAttachments = {"Flashlight Mod"}
- self.Config.WepAttachQuan = 1
- self.Config.Ammo = {"9mm Ammo", "Handmade Shell", "Arrow", "Flare"}
- self.Config.AmmoQuantity = 50
- self.Config.T1Armor = {"Leather Boots", "Leather Pants", "Leather Vest", "Leather Helmet"}
- self.Config.T1Guns = {"Hunting Bow", "Revolver", "Pipe Shotgun", "Hand Cannon"}
- self.Config.T2Armor = {"Kevlar Boots", "Kevlar Pants", "Rad Suit Vest", "Rad Suit Helmet"}
- self.Config.T2Guns = {"Hunting Bow", "Revolver", "Pipe Shotgun", "Hand Cannon"}
- self.Config.RandomTeams = false
- end
- function PLUGIN:ArenaTick()
- self.ArenaTock = self.ArenaTock + 1
- if (self.ArenaOn) and (self.CanQueue) then
- self:QueueActive(self.ArenaTock, self.PlayerCount)
- return
- elseif (self.ArenaOn) then
- self:MatchActive(self.ArenaTock)
- return
- end
- return
- end
- function PLUGIN:QueueActive(Tock, playercount)
- if (Tock == self.ArenaAlert) then
- self:PreMatchWarning()
- return
- elseif (Tock == self.QueueTime) then
- if playercount >= self.MinPlayer then
- self:UABroadcastChat("A new round has begun in the Arena!")
- self.CanQueue = nil
- self:StartMatch ()
- return
- else
- local key = self.MinPlayer - playercount
- self:UABroadcastChat ("There are not enough players to start a match. " .. key .. " more players required!")
- self:UABroadcastChat("type /jt 1 or 2 to queue. Use /leaveq to leave the arena")
- self:UABroadcastChat("***WARNING*** Joining the arena will clear your inventory!")
- self:UABroadcastChat("Please be sure to remove all items + armor before joining the arena")
- self.ArenaTock = 0
- return
- end
- return
- end
- return
- end
- function PLUGIN:MatchActive(Tock)
- if (self.MatchTime <= 0) then
- return
- else
- local timeleft = (self.MatchTime - Tock)
- local matchwarning = self.MatchTime - 15
- if (Tock == matchwarning) then
- for i in pairs(self.Roster) do
- if (self.Roster[i].Status == "alive") then
- self:UABroadcastChat ("15 seconds remaining until match ends!")
- return
- end
- end
- elseif (Tock == self.MatchTime) then
- for i in pairs(self.Roster) do
- rust.Notice(self.Roster[i].UArenaNetUser, "Time limit reached! You have FAILED!")
- end
- self:UABroadcastChat("Match ended in a draw! New match begins in " .. self.QueueTime .. " seconds!")
- self:ForceEnd("timelimit")
- self.ArenaTock = 0
- self.CanQueue = true
- return
- end
- return
- end
- return
- end
- function PLUGIN:PreMatchWarning()
- if (self.MinPlayer > self.PlayerCount) then
- local players = self.MinPlayer - self.PlayerCount
- self:UABroadcastChat(self.Config.AlertTime.. " seconds before the next match! " .. players .. " players still needed!")
- return
- else
- self:UABroadcastChat(self.PlayerCount .. " players queued! Next match begins in " .. self.Config.AlertTime.. " seconds!")
- return
- end
- return
- end
- function PLUGIN:RequestJoin(netuser, cmd, args)
- local userID = rust.GetUserID(netuser)
- local teamrequest = 0
- local msg = "derp"
- if (self.ArenaOn) then
- if (self.PlayerCount > self.MaxPlayer) then
- rust.Notice (netuser, "There are too many players! Try again next match.")
- return
- elseif (self.CanQueue) then
- for i in pairs(self.Roster) do
- if i == userID then
- rust.Notice(netuser, "You are already queued!")
- return
- end
- end
- if ((args[1] == "1") or (args[1] == "2")) and (self.RandomTeams == false) then
- teamrequest = tonumber(args[1])
- local accept = self:TeamBalance(netuser, teamrequest)
- if accept then
- self:JoinAccept(netuser, teamrequest)
- return
- end
- elseif (self.RandomTeams) then
- teamrequest = 99
- self:JoinAccept(netuser, teamrequest)
- return
- elseif (not(args[1] == "1") or not(args[1] == "2")) and (self.RandomTeams == false) then
- rust.SendChatToUser(netuser, "You must specify a proper team")
- return
- else
- end
- end
- end
- end
- function PLUGIN:JoinAccept(netuser, request)
- local userID = rust.GetUserID(netuser)
- local current_coords = netuser.playerClient.lastKnownPosition;
- local teamjoin = {}
- teamjoin.Team = request
- teamjoin.Status = "queued"
- teamjoin.x = current_coords.x
- teamjoin.y = current_coords.y
- teamjoin.z = current_coords.z
- teamjoin.UArenaNetUser = netuser
- self.Roster[userID] = teamjoin
- self.PlayerCount = self.PlayerCount + 1
- self.Team[request] = self.Team[request] + 1
- if (request == 99) then
- msg = "You have joined the queue. You will be placed on a random team at the start of the match!"
- else
- msg = "You have successfully joined team " .. self.Roster[userID].Team .. "! EMPTY YOUR INVENTORY!"
- end
- rust.Notice(netuser, msg)
- rust.SendChatToUser(netuser, "If you are victorious; you will respawn where you typed this command.")
- end
- function PLUGIN:TeamBalance(netuser, request)
- for i, v in pairs(self.Team) do
- if (request ~= i) then
- if (self.Team[request] <= v) then
- return true
- else
- rust.Notice(netuser, "Teams unbalanced, try again!")
- return false
- end
- end
- end
- end
- function PLUGIN:StartMatch()
- local check = self.Team[1] + self.Team[2]
- if self.PlayerCount >= self.MinPlayer then
- if (self.RandomTeams == true) then
- self:TeamsRandom()
- end
- for i in pairs(self.Roster) do
- local userID = i
- if (self.Roster[userID].Status == "queued") then
- self:ClearOutInventory(self.Roster[userID].UArenaNetUser, self.Roster[userID].Team)
- self:UArenaTP(self.Roster[userID].UArenaNetUser, userID, self.Roster[userID].Team)
- self:LoadOut(self.Roster[userID].UArenaNetUser, self.Roster[userID].Team)
- self.Roster[userID].Status = "alive"
- end
- end
- else
- return
- end
- end
- function PLUGIN:TeamsRandom()
- local dist = self.Team[99]/2
- for i in pairs(self.Roster) do
- if (self.Roster[i].Status == "queued") then
- if (self.Team[1] >= dist) then
- self.Roster[i].Team = 2
- self.Team[2] = self.Team[2] + 1
- elseif (self.Team[2] >= dist) then
- self.Roster[i].Team = 1
- self.Team[1] = self.Team[1] + 1
- else
- team = math.random(1, 2)
- self.Roster[i].Team = team
- self.Team[team] = self.Team[team] + 1
- end
- end
- end
- return
- end
- function PLUGIN:UArenaTP(netuser, userID, team)
- local coords = netuser.playerClient.lastKnownPosition;
- local key = self.Roster[userID].Team
- coords.x = self.UArenaSpawn[key].x
- coords.y = self.UArenaSpawn[key].y + 3
- coords.z = self.UArenaSpawn[key].z
- rust.ServerManagement():TeleportPlayer(netuser.playerClient.netPlayer, coords)
- end
- function PLUGIN:LoadOut(netuser, team)
- local inv = rust.GetInventory(netuser)
- local item = rust.GetDatablockByName("Rock")
- local belt = rust.InventorySlotPreference(InventorySlotKind.Belt, false, InventorySlotKindFlags.Belt)
- local bag = rust.InventorySlotPreference(InventorySlotKind.Default, false, InventorySlotKindFlags.Belt)
- local pref = rust.InventorySlotPreference( InventorySlotKind.Armor, false, InventorySlotKindFlags.Armor )
- local amount = 1
- local armor = {}
- local guns = {}
- if team == 1 then
- armor = self.T1Armor
- guns = self.T1Guns
- elseif team == 2 then
- armor = self.T2Armor
- guns = self.T2Guns
- end
- for i, v in pairs(armor) do
- item = rust.GetDatablockByName(v)
- inv:AddItemAmount(item, amount, pref)
- end
- pref = belt
- for i, v in pairs(guns) do
- item = rust.GetDatablockByName(v)
- inv:AddItemAmount(item, amount, pref)
- end
- amount = self.MedkitQuantity
- item = rust.GetDatablockByName(self.Medkit)
- inv:AddItemAmount(item, amount, pref)
- amount = 5
- item = rust.GetDatablockByName("Granola Bar")
- inv:AddItemAmount(item, amount, pref)
- item = rust.GetDatablockByName("Bandage")
- inv:AddItemAmount(item, amount, pref)
- pref = bag
- for i, v in pairs(self.Ammo) do
- amount = self.AmmoQuantity
- item = rust.GetDatablockByName(v)
- inv:AddItemAmount(item, amount, pref)
- end
- for i, v in pairs(self.WepAttachments) do
- amount = self.WepAttachQuan
- item = rust.GetDatablockByName(v)
- inv:AddItemAmount(item, amount, pref)
- end
- end
- function PLUGIN:UArenaLeave(userID)
- local netuser = self.Roster[userID].UArenaNetUser
- local coords = netuser.playerClient.lastKnownPosition;
- coords.x = self.Roster[userID].x
- coords.y = self.Roster[userID].y + 3
- coords.z = self.Roster[userID].z
- rust.ServerManagement():TeleportPlayer(netuser.playerClient.netPlayer, coords)
- end
- function PLUGIN:CheckForWinner()
- local active = {}
- local t = 0
- local TCount = 0
- local team = 0
- for team, v in pairs(self.Team) do
- if (v > 0) then
- active[team] = team
- end
- end
- for k = 1, #active do
- TCount = TCount + 1
- end
- if TCount == 0 then
- return true, 2
- end
- if (TCount == 1) then
- return true, active[1]
- else
- return false, 0
- end
- end
- function PLUGIN:WinDetected(winner)
- print(winner)
- for i in pairs(self.Roster) do
- if (self.Roster[i].Team == winner) then
- if (self.Roster[i].Status == "alive") then
- self:ClearOutInventory(self.Roster[i].UArenaNetUser)
- self:UArenaLeave(i)
- end
- self:UArenaRewards(self.Roster[i].UArenaNetUser)
- rust.Notice(self.Roster[i].UArenaNetUser, "Your team won!")
- end
- end
- self:UArenaClear()
- if (self.ArenaOn == true) then
- self:UArenaConfigPull()
- --self.ArenaTimer = timer.Repeat(1, 0, function() self:ArenaTick() end )
- self.CanQueue = true
- end
- self:UABroadcastChat("Team " .. winner .. " has come out victorious!")
- self:UABroadcastChat("A new round will start in " .. self.QueueTime .. " seconds.")
- self.ArenaTock = 0
- end
- function PLUGIN:UArenaRewards(netuser)
- local inv = rust.GetInventory(netuser)
- local pref = rust.InventorySlotPreference(InventorySlotKind.Belt, false, InventorySlotKindFlags.Belt)
- local amount = 1
- local item = rust.GetDatablockByName("Large Medkit")
- inv:AddItemAmount(item, amount, pref)
- local item = rust.GetDatablockByName("Rock")
- inv:AddItemAmount (item, amount, pref)
- if ((self.PlayerCount >= self.MinPlayerReward) and (not(self.Reward == {}))) then
- for i, v in pairs(self.Reward) do
- local amount = v
- local item = rust.GetDatablockByName(i)
- inv:AddItemAmount (item, amount, pref)
- end
- end
- end
- function PLUGIN:LeaveQ(netuser, cmd, args)
- if (self.CanQueue) then
- userID = rust.GetUserID(netuser)
- if (self.Roster[userID]) then
- if (self.Roster[userID].Status == "queued") then
- self:RemoveQueue (netuser)
- rust.SendChatToUser(netuser, "Removed from queue!")
- return
- end
- end
- else
- --rust.SendChatToUser(netuser, "You aren't in the queue!")
- end
- end
- function PLUGIN:ForceEnd(reason, netuser)
- if (reason == "admin") then
- self.ArenaOn = nil
- rust.SendChatToUser(netuser, "Arena forced off!")
- end
- for i in pairs(self.Roster) do
- if (self.Roster[i].Status == "alive") then
- self:ClearOutInventory(self.Roster[i].UArenaNetUser)
- self:UArenaLeave(i)
- end
- end
- self:UArenaClear()
- end
- function PLUGIN:OnKilled(takedamage, damage)
- if (takedamage:GetComponent("HumanController")) then
- userID = rust.GetUserID(damage.victim.client.netUser)
- if (self.Roster[userID]) then
- if (self.Roster[userID].Status == "alive") then
- self.Roster[userID].Status = "dead"
- local key = self.Roster[userID].Team
- self.Team[key] = self.Team[key] - 1
- local victory, team = self:CheckForWinner()
- if (victory) then
- self:WinDetected(team)
- end
- elseif (self.Roster[userID].Status == "queued") then
- self:RemoveQueue (netuser)
- return
- end
- end
- end
- end
- function PLUGIN:OnUserDisconnect(networkplayer)
- local netuser = networkplayer:GetLocalData()
- if (not netuser or netuser:GetType().Name ~= "NetUser") then return end
- local userID = rust.GetUserID(netuser)
- if (self.Roster[userID]) then
- if (self.Roster[userID].Status == "alive") then
- self.Roster[userID].Status = "dc"
- local key = self.Roster[userID].Team
- self.Team[key] = self.Team[key] - 1
- local victory, team = self:CheckForWinner()
- if (victory) then
- self:WinDetected(team)
- end
- self.ArenaLimbo[userID] = true
- self:SaveArenaLimboFile()
- print(netuser.displayName .. " was added to arenalimbo.")
- elseif (self.Roster[userID].Status == "queued") then
- local key = self.Roster[userID].Team
- self.PlayerCount = self.PlayerCount - 1
- self.Team[key] = self.Team[key] - 1
- self.Roster[userID] = nil
- end
- end
- end
- function PLUGIN:RemoveQueue (netuser)
- local key = self.Roster[userID].Team
- self.PlayerCount = self.PlayerCount - 1
- self.Team[key] = self.Team[key] - 1
- self.Roster[userID] = nil
- end
- function PLUGIN:OnSpawnPlayer(playerclient, usecamp, avatar)
- local netuser = playerclient.NetUser
- local userID = rust.GetUserID( playerclient.NetUser )
- if (self.ArenaLimbo[userID]) then
- timer.Once( 1, function()
- self:ClearOutInventory(netuser)
- end)
- self.ArenaLimbo[userID] = nil
- self:SaveArenaLimboFile()
- end
- end
- function PLUGIN:UArenaSetSpawn(netuser, team)
- local coords = {}
- local current_coords = netuser.playerClient.lastKnownPosition;
- coords.x = current_coords.x
- coords.y = current_coords.y + 3
- coords.z = current_coords.z
- self.UArenaSpawn[team] = coords
- self:SaveSpawnFile()
- end
- function PLUGIN:UArenaClear()
- self.Roster = {}
- self.Team = {}
- self.Team[0] = 0
- self.Team[1] = 0
- self.Team[2] = 0
- self.Team[99] = 0
- self.PlayerCount = 0
- --self.ArenaTimer:Destroy()
- end
- function PLUGIN:ClearOutInventory(netuser)
- local inv = rust.GetInventory(netuser)
- for i = 0, 39 do
- inv:RemoveItem(i)
- end
- end
- function PLUGIN:SaveSpawnFile()
- self.UArenaSpawnFile:SetText(json.encode(self.UArenaSpawn))
- self.UArenaSpawnFile:Save()
- end
- function PLUGIN:SaveArenaLimboFile()
- self.ArenaLimboFile:SetText(json.encode(self.ArenaLimbo))
- self.ArenaLimboFile:Save()
- end
- function PLUGIN:SaveConfigFile()
- config.Save( "uberarena" )
- end
- --self:UABroadcastChat
- function PLUGIN:UABroadcastChat(msg)
- rust.BroadcastChat("uberArena", msg)
- end
- function PLUGIN:UArenaDebug(netuser)
- print("ArenaTock: " .. self.ArenaTock)
- end
- function PLUGIN:ModifyDamage(takedamage, damage)
- if (self.FriendlyFire == "off") then
- if (takedamage:GetComponent("HumanController")) and (not(self.CanQueue)) then
- local victimID = rust.GetUserID(damage.victim.client.netUser)
- local attackerID = rust.GetUserID(damage.attacker.client.netUser)
- if (not(victimID == attackerID)) then
- if (self.Roster[victimID].Team == self.Roster[attackerID].Team) then
- damage.amount = 0
- return damage
- end
- end
- end
- end
- end
- function PLUGIN:UArenaCommands(netuser, cmd, args)
- if (args[1] == "status") then
- if (self.ArenaOn) and (self.CanQueue) then
- rust.SendChatToUser(netuser, "You can queue for the next match. There are " .. self.PlayerCount .. " people already queued! Next round begins in " .. self.QueueTime - self.ArenaTock .. " seconds!")
- return
- elseif (self.ArenaOn) then
- rust.SendChatToUser(netuser, "There is a match in progress.")
- rust.SendChatToUser(netuser, "There are " .. self.Team[1] .. " players alive on team one and")
- rust.SendChatToUser(netuser, "There are " .. self.Team[2] .. " players alive on team two!")
- rust.SendChatToUser(netuser, "Time Left: " .. (self.MatchTime - self.ArenaTock) .. " seconds remaining!")
- return
- else
- rust.SendChatToUser (netuser, "The arena is currently disabled!")
- return
- end
- elseif (args[1] == "help") then
- rust.SendChatToUser(netuser, "uberArena version " .. self.Version)
- rust.SendChatToUser(netuser, "/ua status to see the arenas' current status")
- rust.SendChatToUser(netuser, "/jt 1 or 2 to join a team while the queue is active")
- rust.SendChatToUser(netuser, "/leaveq to leave the queue")
- rust.SendChatToUser(netuser, "Be sure to clear your inventory before you join the queue!")
- return
- end
- value = self.MatchTime - self.ArenaTock
- end
- function PLUGIN:AdminUArenaCommands (netuser, cmd, args)
- if (netuser:CanAdmin()) or (self.oxminInstalled and oxmin_Plugin:HasFlag(netuser, self.FLAG_UAControls, false)) then
- if (args[1] == "debug") then
- self:UArenaDebug(netuser)
- return
- elseif (args[1] == "onbydefault") then
- if (args[2]) == "true" then
- rust.SendChatToUser(netuser, "Changed setting onbydefault to true. Was " .. self.Config.OnByDefault .. "!")
- self.Config.OnByDefault = true
- config.Save("uberarena")
- return
- elseif (args[2] == "false") then
- rust.SendChatToUser(netuser, "Changed setting onbydefault to false. Was " .. self.Config.OnByDefault .. "!")
- self.Config.OnByDefault = true
- config.Save("uberarena")
- return
- else
- rust.SendChatToUser(netuser, "onbydefault must be true or false")
- return
- end
- elseif (args[1] == "arena") then
- if (args[2] == "on") then
- if (not(self.ArenaOn)) then
- self.CanQueue = true
- self.ArenaOn = true
- --self.ArenaTimer = timer.Repeat(1, 0, function() self:ArenaTick() end )
- self.ArenaTock = 0
- self:UArenaConfigPull()
- rust.SendChatToUser (netuser, "The uberArena is on!")
- return
- else
- rust.SendChatToUser (netuser,"The uberArena is already on!")
- return
- end
- elseif (args[2] == "off") then
- if (self.ArenaOn) and (self.CanQueue) then
- self.ArenaOn = nil
- rust.SendChatToUser (netuser, "The uberArena is off!")
- return
- elseif (self.ArenaOn) then
- self.ArenaOn = nil
- rust.SendChatToUser (netuser, "It will be disabled after the match ends!")
- return
- end
- else
- rust.SendChatToUser(netuser, "You must turn it on or off! Not " .. args[2])
- return
- end
- elseif (args[1] == "reset") then
- if (self.ArenaOn) and (self.CanQueue) then
- self:ForceEnd("admin", netuser)
- self.CanQueue = true
- self.ArenaOn = true
- self.ArenaTock = 0
- self:UArenaConfigPull()
- rust.SendChatToUser (netuser, "The uberArena is off!")
- return
- end
- elseif (args[1] == "forceoff") then
- if (self.ArenaOn) and (not(self.CanQueue)) then
- self:UArenaDebug(netuser)
- self:ForceEnd("admin", netuser)
- rust.SendChatToUser(netuser, "Arena forced off!")
- return
- else
- rust.SendChatToUser(netuser, "Arena doesn't need to be forced off!")
- return
- end
- elseif (args[1] == "friendlyfire") then
- if (args[2] == "on") or (args[2] == "off") then
- rust.SendChatToUser(netuser, "friendlyfire changed to " .. args[2] .. ". Was " .. self.Config.FriendlyFire .. ". Will apply after next match!")
- self.Config.FriendlyFire = args[2]
- config.Save("uberarena")
- return
- else
- rust.SendChatToUser(netuser, "friendly fire must be set to on or off")
- return
- end
- elseif (args[1] == "queuetime") then
- if (args[2]) then
- rust.SendChatToUser(netuser, "queuetime changed to " .. tonumber(args[2]) .. ". Was " .. self.Config.QueueTime .. ". Will apply after next match!")
- self.Config.QueueTime = tonumber(args[2])
- config.Save("uberarena")
- return
- else
- rust.SendChatToUser(netuser, "Value required (in seconds)!")
- return
- end
- elseif (args[1] == "minplayer") then
- if ((tonumber(args[2]) > 1) and (tonumber(args[2]) < self.Config.MaxPlayer)) then
- rust.SendChatToUser(netuser, "minplayer changed to " .. tonumber(args[2]) .. ". Was " .. self.Config.MinPlayer .. ". Will apply after next match!")
- self.Config.MinPlayer = tonumber(args[2])
- config.Save("uberarena")
- return
- elseif (tonumber(args[2]) > self.Config.MaxPlayer) then
- rust.SendChatToUser(netuser, "Must be lower than maxplayer(" .. self.Config.MaxPlayer .. ")!")
- return
- else
- rust.SendChatToUser(netuser, "Must be a number")
- return
- end
- elseif (args[1] == "maxplayer") then
- if (args[2]) and (tonumber(args[2]) > self.Config.MinPlayer) then
- rust.SendChatToUser(netuser, "maxplayer changed to " .. tonumber(args[2]) .. ". Was " .. self.Config.MaxPlayer .. ". Will apply after next match!")
- self.ConfigMinPlayer = tonumber(args[2])
- self.SaveConfigFile()
- return
- elseif (args[2]) and (tonumber(args[2]) < self.Config.MinPlayer) then
- rust.SendChatToUser(netuser, "Must be higher than minplayer(" .. self.Config.MinPlayer .. ")!")
- return
- else
- rust.SendChatToUser(netuser, "Must be a number")
- return
- end
- elseif (args[1] == "spawn") then
- if (args[2]) and (tonumber(args[2]) < 3) then
- rust.SendChatToUser(netuser, "Team " .. tonumber(args[2]) .. " spawn set!")
- self:UArenaSetSpawn(netuser, tonumber(args[2]))
- return
- else
- rust.SendChatToUser(netuser, "Can set team 1 or 2")
- return
- end
- elseif (args[1] == "reward") then
- if (rust.GetDatablockByName(args[2])) then
- if (args[3] == "remove") and (self.Reward[args[2]]) then
- rust.SendChatToUser(netuser, args[2] .. " removed from rewards list!")
- self.Reward[args[2]] = nil
- return
- else
- rust.SendChatToUser (netuser, "Reward " .. args[2] .. " in quantity " .. tonumber(args[3]) .. " was added to the reward list!")
- self.Config.Reward[args[2]] = tonumber(args[3])
- config.Save("uberarena")
- return
- end
- else
- rust.SendChatToUser(netuser, "Improper syntax.")
- return
- end
- elseif (args[1] == "minplayerreward") then
- if (args[2]) and (tonumber(args[2]) > 0) then
- rust.SendChatToUser(netuser, "minplayerreward changed to " .. tonumber(args[2]) .. ". Was " .. self.Config.MinPlayerReward .. ". Will apply after next match!")
- self.Config.MinPlayerReward = tonumber(args[2])
- config.Save("uberarena")
- return
- else
- rust.SendChatToUser(netuser, "minplayerreward must be greater than 1")
- return
- end
- elseif (args[1] == "matchlimit") then
- if (args[2]) and (tonumber(args[2]) == 0) then
- rust.SendChatToUser(netuser, "matchlimit disabled! Will apply after next match!")
- self.Config.MatchTime = 0
- config.Save("uberarena")
- return
- elseif (args[2]) and (tonumber(args[2]) > 0) then
- rust.SendChatToUser(netuser, "matchlimit set to " .. tonumber(args[2]) .. ". Will apply after next match!")
- self.Config.MatchTime = tonumber(args[2])
- config.Save("uberarena")
- return
- else
- rust.SendChatToUser(netuser, "Match time limit (in seconds). Setting it to 0 will remove timelimit!")
- return
- end
- elseif (args[1] == "arenaalert") then
- if (args[2]) and (tonumber(args[2])) then
- rust.SendChatToUser(netuser, "arenaalert set to " .. tonumber(args[2]) .. ". Was " .. self.Config.AlertTime .. ". Will apply after next match!")
- self.Config.AlertTime = tonumber(args[2])
- config.Save("uberarena")
- return
- end
- elseif (args[1] == "randomteams") then
- if (self.RandomTeams == true) then
- self.Config.RandomTeams = false
- elseif (self.RandomTeams == false) then
- self.Config.RandomTeams = true
- end
- rust.SendChatToUser(netuser, "randomteams toggled to " .. tostring(self.Config.RandomTeams) .. ". Will apply after next match!")
- config.Save("uberarena")
- return
- else
- rust.SendChatToUser(netuser, "Invalid command")
- return
- end
- else
- rust.SendChatToUser (netuser, "You must be logged in as an admin to do this!")
- end
- end
- function PLUGIN:UAStatusCommands(netuser, cmd, args)
- if (netuser:CanAdmin()) or (self.oxminInstalled and oxmin_Plugin:HasFlag(netuser, self.FLAG_UAControls, false)) then
- local oldsetting = "derp"
- local newsetting = "derp"
- local arenastatus = "for next match"
- local proceed = false
- if (self.ArenaOn) and (not(self.CanQueue)) then
- arenastatus = "for current match"
- end
- if (args[1] == "randomteams") then
- oldsetting = self.RandomTeams
- newsetting = self.Config.RandomTeams
- elseif (args[1] == "minplayer") then
- newsetting = self.Config.MinPlayer
- oldsetting = self.MinPlayer
- elseif (args[1] == "maxplayer") then
- newsetting = self.Config.MaxPlayer
- oldsetting = self.MaxPlayer
- elseif (args[1] == "queuetime") then
- newsetting = self.Config.QueueTime
- oldsetting = self.QueueTime
- elseif (args[1] == "arenaalert") then
- newsetting = self.Config.AlertTime
- oldsetting = self.AlertTime
- elseif (args[1] == "minplayerreward") then
- newsetting = self.Config.MinPlayerReward
- oldsetting = self.MinPlayerReward
- elseif (args[1] == "matchlimit") then
- newsetting = self.Config.MatchTime
- oldsetting = self.MatchTime - self.QueueTime
- elseif (args[1] == "friendlyfire") then
- newsetting = self.Config.FriendlyFire
- oldsetting = self.FriendlyFire
- end
- if (tostring(oldsetting)) and (tostring(newsetting)) then
- if (tostring(oldsetting) == tostring(newsetting)) then
- rust.SendChatToUser(netuser, "Status " .. tostring(arenastatus) .. " is " .. args[1] .. ": " .. tostring(oldsetting) .. "!")
- return
- else
- rust.SendChatToUser(netuser, "Status " .. tostring(arenastatus) .. " is " .. args[1] .. ": " .. tostring(oldsetting) .. ". Will be " .. tostring(newsetting) .. " the match after that!")
- end
- else
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement