전략게시판

전략게시판 [스튜디오]
yes
2020.06.02 15:23 조회 : 2163
Lv. 285토게피 쀼얍이와친구들 작성자 게시물 더보기

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
댓글을 남기시려면 로그인 해주세요
댓글 : 3
  • or yes Lv. 607모바일에서 등록빨간헤비 2020.06.09
  • Lv. 530attack5132 2020.06.02
  • 아직 실질적인 테스트를 하지는 못한 상태임... Lv. 285토게피 2020.06.02