function SuR:StartExfil()
    hook.Call("SuR.ExfilStarted", nil, SuR.Current_Wave)
    local ptab = SuR.Config.Exfil_Points
    if !SuR.Game_Started or !SuR.Wave_Started or #ptab == 0 or SuR.Config.Exfil_Wave > SuR.Current_Wave or SuR.ExfilWave or SuR.Config.Objective_Mode then return end

    SuR.ExfilWave = true

    local point = table.Random(ptab)

    net.Start("SuR.ExfilIcon")
    net.WriteBool(false)
    net.Broadcast()

    SuR:MessageOnClient(13)
    SuR:ShowTips("evac")
    timer.Simple(1, function()
        SuR:PlaySoundOnClient("surrounded/other/pilot1/helidepart_0"..math.random(1,3)..".mp3")
    end)

    timer.Create("ExfilLine1", 60, 1, function()
        SuR:PlaySoundOnClient("surrounded/other/pilot1/heli60_0"..math.random(1,3)..".mp3")
    end)

    timer.Create("ExfilLine2", 90, 1, function()
        SuR:PlaySoundOnClient("surrounded/other/pilot1/heli30_0"..math.random(1,3)..".mp3")
    end)

    timer.Create("ExfilStart", 120, 1, function()
        for _, ply in pairs(player.GetAll()) do
            ply:SetJumpPower(240)
        end
        local he = ents.Create("sur_exfil_helo")
        he.Points = point
        he.WaitTime = 45
        he:Spawn()
        hook.Call("SuR.ExfilHeliSpawned", nil, he)
        SuR:SetMarker(point["Main"], player.GetAll(), "Evacuation")
    end)
end

function SuR:StartObjectiveExfil()
    if !SuR.Game_Started or SuR.ExfilWave then return end

    hook.Call("SuR.ExfilStarted", nil, SuR.Current_Wave)

    net.Start("SuR.ExfilIcon")
    net.WriteBool(false)
    net.Broadcast()

    SuR:ShowTips("evac")
    for _, ply in pairs(player.GetAll()) do
        ply:SetJumpPower(240)
    end

    local ptab = SuR.Config.Exfil_Points
    local point = table.Random(ptab)
    local he = ents.Create("sur_exfil_helo")
    he.Points = point
    he.WaitTime = 60
    he:Spawn()
    hook.Call("SuR.ExfilHeliSpawned", nil, he)
    SuR:SetMarker(point["Main"], player.GetAll(), "Evacuation Point")
    timer.Simple(1, function()
        SuR:PlaySoundOnClient("surrounded/other/pilot1/helidepart_0"..math.random(1,3)..".mp3")
    end)
end

function SuR:StartGasExfil()
    hook.Call("SuR.ExfilStarted", nil, SuR.Current_Wave)
    local ptab = SuR.Config.Exfil_Points
    if !SuR.Game_Started or !SuR.Wave_Started or #ptab == 0 or SuR.ExfilWave then return end

    SuR.ExfilWave = true

    local point = table.Random(ptab)

    SuR:ShowTips("evac")
    timer.Simple(1, function()
        SuR:PlaySoundOnClient("surrounded/other/pilot1/gas"..math.random(1,4)..".mp3")

        local pos = nil
        if #SuR.Config.Gas_SpawnPositions > 0 then
            pos = table.Random(SuR.Config.Gas_SpawnPositions)
        else
            pos = SuR:GetRandomPos(false, 100, 10000)
            if !isvector(pos) then
                pos = SuR:GetRandomPos(true, 100, 10000)
            end
        end
        if isvector(pos) then
            local gas = ents.Create("sur_gas_zone")
            gas:SetPos(pos)
            gas.Dist = math.max(pos:Distance(point[3].pos)-200, 100)
            gas:Spawn()
            SuR.Gas_Entity = gas
        end
    end)
    
    timer.Create("ExfilLine1", 50, 1, function()
        SuR:PlaySoundOnClient("surrounded/other/pilot1/heli30_0"..math.random(1,3)..".mp3")
    end)
    
    timer.Create("ExfilLine2", 60, 1, function()
        net.Start("SuR.ExfilIcon")
        net.WriteBool(true)
        net.Broadcast()

        SuR.DisableMusic = true
        BroadcastLua([[SuR:PlayMusicOther(table.Random(SuR.Config.MusicWave["Countdown"]))]])
        SuR:SetMarker(point["Main"], player.GetAll(), "Last Exfil")
    end)

    timer.Create("ExfilStart", 75, 1, function()
        for _, ply in pairs(player.GetAll()) do
            ply:SetJumpPower(240)
        end
        local he = ents.Create("sur_exfil_helo")
        he.Points = point
        he.WaitTime = 30
        he.LastExfil = true
        he:Spawn()
        hook.Call("SuR.ExfilHeliSpawned", nil, he)
    end)
end

function SuR:StopExfil()
    SuR:Countdown(0)
    SuR.ExfilWave = false 
    timer.Remove("ExfilLine1")
    timer.Remove("ExfilLine2")
    timer.Remove("ExfilStart")
end