Players = {}
tempplayers = {} -- 실질적인 팀 분배에 사용될 플레이어 배열
for i=1,24 do
Players[i] = nil
tempplayers[i] = nil
end
function Game.Rule:OnPlayerJoiningSpawn (player) -- 들어올 때 플레이어 배열에 집어넣음
Players[player.index] = player
end
function Game.Rule:OnPlayerConnect (player) -- 함수 실행 후 들어오면 무조건 대테로 보냄.
player.team = Game.TEAM.CT
end
-- 주의 : 난입시 사망처리와는 다른 개념임!
function Game.Rule:OnPlayerDisconnect (player) -- 나가면 플레이어 배열에서 삭제
Players[player.index] = nil
end
function Game.Rule:OnRoundStart ()
TRgoesto()
end
function shuffletempplayer() -- players 배열의 인덱스를 뒤섞어준다.
local temp
local r
for i=1,tempindex-1 do
r = Game.RandomInt(1,tempindex-1)
temp = tempplayers[r]
tempplayers[r] = tempplayers[i]
tempplayers[i] = temp
end
end
function TRgoesto() -- 실질적 팀 할당 함수
tempindex = 1 -- tempplayers 에서 사용될 배열 인덱스
for i,p in pairs(Players) do -- 존재하는 플레이어를 실질 배열에 저장
if p ~= nil then
tempplayers[tempindex]=p
tempindex = tempindex + 1
end
end
shuffletempplayer() -- 실질 배열을 뒤섞는다.
if tempindex > 4 then -- 뒤섞인 실질 배열에서 2명을 뽑아 테러로 보낸다.
for i=1,(tempindex-1) do -- 먼저 전부 대테로
tempplayers[i].team = Game.TEAM.CT
end
tempplayers[1].team = Game.TEAM.TR --선택받은 두명은 테러로
tempplayers[2].team = Game.TEAM.TR
end
end
추천 :
0