@name Alarm System
@persist Player:entity Playing Alert Color V1:vector V2:vector
interval(500)
runOnChat(1)
if(clk()) {
    findInBox(V1,V2)
    findClipToClass("player")
    BoxPlayers = findToArray()
    Alert = 0
    for(I=1, BoxPlayers:count()) {
        Wpn = BoxPlayers[I,entity]:weapon():type()
        if(Wpn=="keypad_cracker" | Wpn=="lockpick" | Wpn=="super_lockpick" | Wpn=="pro_keypad_cracker" | Wpn=="weapon_" | Wpn=="pro_lockpick" | Wpn=="super_cracker") {
            Alert = 1
            if(!Playing) {
                Player = BoxPlayers[I,entity]
                Playing = 1
                timer("Alert",1)
                timer("PrintHUD",1)
            }
        }
    }
    if(Alert==0) {
        Playing = 0
        soundStop(1)
    }
} else {
    if(first()) {
        function vector getWall(V:vector) {
            rangerHitEntities(0)
            return rangerOffset(owner():pos()+vec(0,0,70),owner():pos()+vec(0,0,70)+V):position()
        }
    }
    if(clk("Alert") & Playing) {
        owner():soundPlay(1, 8, "/hl1/fvox/near_death.wav")
        timer("Alert",5000)
    }
    if(clk("PrintHUD") & Playing) {
        print(_HUD_PRINTCENTER,"You are being raided!")
        timer("PrintHUD",1000)
    }
    if(chatClk(owner())) {
        if(lastSaid()=="!room") {
            A = getWall(vec(0,0,10000)):z()
            B = getWall(vec(0,0,-10000)):z()
            C = getWall(vec(-10000,0,0)):x()
            D = getWall(vec(10000,0,0)):x()
            E = getWall(vec(0,-10000,0)):y()
            F = getWall(vec(0,10000,0)):y()
            V1 = vec(C,E,A)
            V2 = vec(D,F,B)
        }
        if(lastSaid()=="!v1") {
            V1 = owner():aimPos()
        }
        if(lastSaid()=="!v2") {
            V2 = owner():aimPos()
        }
    }
}
