-- [ Settings ] ----------------------------StartDelay = 45 -- Delay in seconds before a new game startsMinimumPlayers = 5 -- Minimum players needed to start/continue a gameResources = 50 -- Amount of resources given to support classes at the start of the gamePointReward = 400 -- Base point reward awarded to the winning teamCashReward = 250 -- Base cash reward awarded to the winning teamExpReward = 200 -- Base experience reward awarded to the winning team-- [ Globals ] -----------------------------Arena = nilTotalPlayers = 0bGameStarted = falseStartTime = nilStartEvent = 0HillTeam = nilCommandCenter = nil-- [ Events ] ------------------------------function Arena_OnCreate(arena) Arena = arena endfunction Player_OnJoin(Player) TotalPlayers = TotalPlayers + 1 if ( bGameStarted == false ) and ( TotalPlayers >= MinimumPlayers ) then Arena:message("Game starting in " .. StartDelay .. " seconds.. Press F12 to join the game!") StartEvent = event_create(StartGame, StartDelay*1000) endendfunction Player_OnLeave(Player) TotalPlayers = TotalPlayers - 1 if ( bGameStarted == true ) and ( TotalPlayers < MinimumPlayers ) then -- Not enough players to continue the game, abort it bGameStarted = false StartTime = nil HillTeam = nil -- Destroy the game delay event event_destroy(StartEvent) -- Notify everyone Arena:message("Not enough players to continue...game aborted.") -- Reset everyones temporary statistics for i = 1, TotalPlayers do ResetStats(Arena:get(i)) end else -- Reset the players temporary statistics ResetStats(Player) endendfunction Player_OnDeath(Killer, Player) if ( bGameStarted == false ) then return end -- Increment the killers total kills Killer:setstat(2, Killer:getstat(2) + 1) -- Increment the players total deaths Player:setstat(3, Player:getstat(3) + 1)endfunction Vehicle_OnDeath(Vehicle, Killer) if ( bGameStarted == false ) then return end if ( Vehicle:vehicletypeid() == 200 ) then local KillerTeam = Killer:getTeam() if ( KillerTeam.m_name == HillTeam.m_name ) then CommandCenter = vehicle_create(200, 0, 0, 0) -- need to create you for a specific team =( else -- The hill has a new owner! Arena:message(KillerTeam.m_name .. " has taken control of the hill!") CommandCenter = vehicle_create(200, 0, 0, 0) -- Move everyone but the team owning the hill back to spawn for a 'grace' period -- Start the 30 minute countdown to victory end endendfunction Vehicle_OnCreate(Vehicle) endfunction Vehicle_OnProduce(Player, Item)end-- [ Functions ] ---------------------------function StartGame() -- Start the game timer StartTime = os.time() for i = 1, TotalPlayers do local Player = Arena:get(i) if ( Player:spectator() == false ) then -- Engineer if ( Player:getVehicle():vehicletypeid() == 11 ) then Player:item_modify("Titanium Oxide", Resources) -- Medic elseif ( Player:getVehicle():vehicletypeid() == 15 ) then Player:item_modify("Tsolvy Crystals", Resources) end end end -- Move teams/players back to their spawn points ResetSpawns() -- It has begun! bGameStarted = true Arena:message("Game started.")endfunction EndGame(WinningTeam) -- Calculate how long the game has been running local RunningTime = os.difftime(os.time(), StartTime) -- Calculate the rewards (fix me!) local RewardPoints = PointsReward * TotalPlayers + (RunningTime * 4) local RewardCash = CashReward * TotalPlayers + (RunningTime * 2) local RewardExp = ExpReward * TotalPlayers + (RunningTime * 2) -- Arena:message("!After " .. FormatedTime .. " the battle has come to an end.") Arena:message("Victory: " .. WinningTeam.m_name .. " -- Points = " .. RewardPoints .. " Cash = " .. RewardCash .. " Experience = " .. RewardExp) for i = 1, TotalPlayers do local Player = Arena:get(i) local PlayerTeam = Player:getTeam() if ( Player:spectator() == false ) then if ( PlayerTeam.m_name == WinningTeam.m_name ) then -- Increment the players total wins Player:setstat(0, Player:getstat(0) + 1) else -- Increment the players total losses Player:setstat(1, Player:getstat(1) + 1) end end -- Reset the players temporary statistics ResetStats(Player) end -- No one controls the hill now HillTeam = nil CommandCenter:destroy() -- Notify everyone that there's another game coming up Arena:message("Next game in " .. StartDelay .. " seconds. Press F12 to join the game!") StartEvent = event_create(StartGame, StartDelay*1000)endfunction ResetSpawns()endfunction ResetStats(Player) Player:setstat(2, 0) -- Kills this game Player:setstat(3, 0) -- Deaths this gameend