-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
require 'config' | ||
|
||
local humanTeamId = 2 | ||
local botTeamId = 1 | ||
|
||
Events:Subscribe('Level:Loaded', function(levelName, gameMode, round, roundsPerMap) | ||
DisableTeamSwitching() | ||
|
||
print("Team selection mode = " .. teamMode) | ||
|
||
if teamMode == 1 then | ||
SetHumanTeam(math.random(1, 2)) | ||
elseif teamMode == 2 then | ||
SwapTeams() | ||
elseif teamMode == 3 then | ||
SetHumanTeam(1) | ||
elseif teamMode == 4 then | ||
SetHumanTeam(2) | ||
end | ||
|
||
PrintHumanTeam() | ||
print("Squad size = " .. squadSize) | ||
|
||
BalanceAllPlayers() | ||
end) | ||
|
||
|
||
Events:Subscribe('Player:TeamChange', function(player, team, squad) | ||
BalancePlayer(player) | ||
end) | ||
|
||
function BalancePlayer(player) | ||
if player == nil then | ||
return | ||
end | ||
|
||
if player.onlineId == 0 or player.guid == 0 then | ||
return | ||
else | ||
if player.teamId ~= humanTeamId then | ||
player.teamId = humanTeamId | ||
else | ||
return | ||
end | ||
end | ||
|
||
if player.squadId == 0 or player.squadId == 33 then | ||
FindSquad(player) | ||
end | ||
|
||
print("Moved " .. player.name .. " to team '" .. player.teamId .. "' squad '" .. player.squadId .. "'") | ||
end | ||
|
||
function BalanceAllPlayers() | ||
for i,player in ipairs(PlayerManager:GetPlayers()) do | ||
BalancePlayer(player) | ||
end | ||
end | ||
|
||
function FindSquad(player) | ||
for i=1,32 do | ||
if TeamSquadManager:GetSquadPlayerCount(player.teamId, i) < squadSize then | ||
player.squadId = i | ||
break | ||
end | ||
end | ||
end | ||
|
||
function SetHumanTeam(team) | ||
if team == 1 then | ||
humanTeamId = 1 | ||
botTeamId = 2 | ||
else | ||
humanTeamId = 2 | ||
botTeamId = 1 | ||
end | ||
end | ||
|
||
function SwapTeams() | ||
local tempHumanId = humanTeamId | ||
local tempBotId = botTeamId | ||
|
||
humanTeamId = tempBotId | ||
botTeamId = tempHumanId | ||
end | ||
|
||
function PrintHumanTeam() | ||
if humanTeamId == 1 then | ||
print("Human team = US") | ||
else | ||
print("Human team = RU") | ||
end | ||
end | ||
|
||
function DisableTeamSwitching() | ||
local s_SyncedBFSettings = ResourceManager:GetSettings("SyncedBFSettings") | ||
if s_SyncedBFSettings ~= nil then | ||
s_SyncedBFSettings = SyncedBFSettings(s_SyncedBFSettings) | ||
s_SyncedBFSettings.teamSwitchingAllowed = false | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
-- The teamMode allows you to choose how the human team is selected every round | ||
-- 1 = random team | ||
-- 2 = swapped teams (This will swap the teams between rounds, if humans were US in the last round, they'll get RU in the next) | ||
-- 3 = Always US | ||
-- 4 = Always RU | ||
teamMode = 1 | ||
|
||
-- Set squadSize equal to the squad size you've configured in your server's startup.txt | ||
-- Vanilla default = 4 | ||
squadSize = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"Name": "No PVP", | ||
"Description": "Puts those pesky humans in one place", | ||
"Authors": ["P!NK_Lesley aka PowerChopper"], | ||
"Tags": ["no-pvp"], | ||
"Version": "1.0.0", | ||
"HasVeniceEXT": true, | ||
"HasWebUI": false, | ||
"Dependencies": { | ||
"veniceext": "^1.0.0" | ||
} | ||
} |