@name BoxAboutWeaponCheck
@inputs S:wirelink
@outputs Length Entrance Exit Cooldown
@persist A B Target Scanning Mode Done Trapped:entity SIDs:table FailLength AcceptLength
 
 
holoCreate(1)
holoModel(1,"models/hunter/plates/plate05x2.mdl")
holoPos(1,entity():toWorld(vec(25,0,45)))
holoAng(1,entity():toWorld(ang(0,90,90)))
holoMaterial(1,"models/debug/debugwhite")
 
holoCreate(2)
holoModel(2,"models/hunter/plates/plate05x2.mdl")
holoPos(2,entity():toWorld(vec(-25,0,45)))
holoAng(2,entity():toWorld(ang(0,90,90)))
holoMaterial(2,"models/debug/debugwhite")
 
holoCreate(3)
holoModel(3,"models/hunter/plates/plate05x1.mdl")
holoPos(3,entity():toWorld(vec(0,0,91)))
holoAng(3,entity():toWorld(ang(0,90,0)))
holoMaterial(3,"models/debug/debugwhite")
 
holoCreate(4)
holoModel(4,"models/props_lab/hevplate.mdl")
holoPos(4,entity():toWorld(vec(24,0,50)))
holoAng(4,entity():toWorld(ang(0,180,0)))
holoScale(4,vec(1,0.8,1))
holoMaterial(4,"phoenix_storms/pack2/darkgrey")
 
holoCreate(5)
holoModel(5,"models/props_lab/reciever01a.mdl")
holoPos(5,entity():toWorld(vec(13,0.9,87)))
holoAng(5,entity():toWorld(ang(0,90,0)))
holoScale(5,vec(1.7,1,1))
holoMaterial(5,"phoenix_storms/pack2/darkgrey")
 
holoCreate(6)
holoModel(6,"models/props_lab/reciever01d.mdl")
holoPos(6,entity():toWorld(vec(0,0,87)))
holoAng(6,entity():toWorld(ang(0,90,0)))
holoMaterial(6,"phoenix_storms/pack2/darkgrey")
holoScale(6,vec(1.5,1,1))
 
holoCreate(7)
holoModel(7,"models/props_lab/reciever01b.mdl")
holoPos(7,entity():toWorld(vec(-15,5,87)))
holoAng(7,entity():toWorld(ang(0,90,0)))
holoMaterial(7,"phoenix_storms/pack2/darkgrey")
holoScale(7,vec(1,1.1,1))
 
holoCreate(8)
holoModel(8,"models/props_c17/light_cagelight01_off.mdl")
holoPos(8,entity():toWorld(vec(-25,5,80)))
holoAng(8,entity():toWorld(ang(0,270,90)))
 
lightCreate(1)
lightPos(1,entity():toWorld(vec(-25,0,75)))
lightDistance(1,0.1)
 
if (FailLength) {
    lightColor(1,vec(255,0,0))
}  else { lightColor(1,vec(0,0,0))
}
 
 
#WEAPON DETECTING#
 
if (first()) {
    A = 5
    B = 0
    Length = A
    runOnTick(1)
    rangerFlags("IEZ")
    rangerPersist(1)
    Entrance = 1
    Exit = 0
    FailLength = soundDuration("buttons/weapon_cant_buy.wav")
    AcceptLength = soundDuration("buttons/button9.wav")
}
 
if (clk("Close")) {
    Entrance = 1
    Exit = 0
    exit()
}
if (clk("Cooldown")) {
    Cooldown = 0
}
if (Done) {
    # Do something
    Done = 0
    Accepted = 1
    S:writeString(Trapped:name() + ":",0, 0)
    S:writeString(" ", 0, 1, 0, teamColor(Trapped:team()))
    S:writeString(Trapped:team():teamName(), 1, 1)
    findIncludePlayerProps(Trapped)
    N = findByClass("*")
    if (N > 0) {
        Ar = findToArray()
        findDisallowPlayerProps(Trapped)
        W = array()
        J = 0
        for (I = 0, N) {
            E = Ar[I, entity]
            #if (E:owner() == E) {
            T = E:type()
            if (E:isWeapon()
                & T != "gmod_tool"
                & T != "gmod_camera"
                & T != "pocket"
                & T != "keys"
                & T != "weapon_physcannon"
                & T != "weapon_physgun"
                & T != "weapon_mad_fists"
                & T != "med_kit"
                & T != "bugbait"
                & T != "keypad_cracker"
                & T != "lockpick"
                & T != "door_ram"
                & T != "arrest_stick"
                & T != "unarrest_stick"
                & T != "stunstick"
                & T != "weapon_fists"
                & T != "weaponchecker"
                & T != "itemstore_pickup"
            ) {
                W[J,string] = T
                J++
            }
        }
        if (J == 0) {
            S:writeString("No Weapons", 0, 3, 90)
        } else {
            Accepted = 0
            for (I = 0, J) {
                S:writeString(W[I,string], 0, 3+I, 900)
            }
        }
    }
    if (Accepted) {
        Exit = 1
        timer("Close", 0)
        Timer = 0
        soundPlay(1, AcceptLength, "buttons/button9.wav")
    } else {
        Timer = 0
        Entrance = 1
        soundPlay(1, FailLength, "buttons/weapon_cant_buy.wav")
        print("NONONO")
    }
    Cooldown = 1
    timer("Cooldown", Timer)
    exit()
}
 
if (Cooldown) { exit() }
if (!Scanning) {
    RD = ranger(200)
    if (RD:hit()) {
        Trapped = RD:entity()
        if (Trapped != noentity() & Trapped:isPlayer()) {
            Entrance = 0
            Scanning = 1
            Mode = 1
        }
        S["Reset", number] = 1
        S["Reset", number] = 0
    }
    exit()
}
 
if (Length == Target) {
    if (Target == A) {
        if (Mode) {
            Target = B
        } else {
            Scanning = 0
            Done = 1
            exit()
        }
    } else {
        Mode = 0
        Target = A
    }
}
if (Length > Target) {
    Length--
} else {
    Length++
}
 

