tdm_game.lua

--팀데스매치 예제(game)

local TDM = Game.Rule
TDM.name = "팀데스매치"
TDM.desc = "스크립트로 만드는 팀데 모드"

-- 맵 파괴 가능
TDM.breakable = true

-- 목표 점수
local MaxKill = Game.SyncValue.Create("MaxKill")
MaxKill.value = 30

-- 팀 점수
local Score = {}
Score[Game.TEAM.CT] = Game.SyncValue.Create("ScoreCT")
Score[Game.TEAM.CT].value = 0
Score[Game.TEAM.TR] = Game.SyncValue.Create("ScoreTR")
Score[Game.TEAM.TR].value = 0

function TDM:OnPlayerSpawn(player)
    player:ShowBuymenu()
end

function TDM:OnPlayerKilled(victim, killer)
    -- 자살이나 낙사 등
    if killer == nil then
        return
    end

    -- 죽인 플레이어 팀에게 1점
    local killer_team = killer.team
    local point = Score[killer_team]
    point.value = point.value + 1

    -- 목표 넘었으면 승리!
    if (point.value >= MaxKill.value) then
        self:Win(killer_team)
    end
end
generated by LDoc 1.4.6 Last updated 2019-11-08 21:27:50