@name Weapon checker
@inputs RD:ranger Screen:wirelink Screen2:wirelink Reset
@outputs Play
@persist Target:entity Weapons:array Play Allowed:table
if (first()) {
    Allowed["weapon_physcannon",number] = 1
    Allowed["weapon_physgun",number]    = 1
    Allowed["gmod_tool",number] = 1
    Allowed["gmod_camera",number] = 1
    Allowed["laserpointer",number] = 1
    Allowed["remotecontroller",number] = 1

    Allowed["keys",number] = 1
    Allowed["pocket",number] = 1
    Allowed["arrest_stick",number] = 1
    Allowed["unarrest_stick",number] = 1
    Allowed["stunstick",number] = 1

}

interval(20)
if (RD:hit() & clk()) {
    Play = 0
    if (RD:entity():type() == "player" | Reset) {
        Screen[2041] = 1
        Screen2[2041] = 1
        Target = RD:entity()
        findIncludePlayerProps(Target)
#        findIncludeClass("sent_ball")
        findIncludeClass("weapon_*")
        findExcludeClass("prop_physics")
        findExcludeClass("player") 
        findInSphere(Target:pos(),25)
        Weapons = findToArray()
        Name = Target:name():sub(1,20)
        Screen:writeString(Name,0,0,49)
        
        for (X = 1,Weapons:count()) {
            if (!Allowed[Weapons[X,entity]:type(),number]) {Play = 1, Color = 900} else {Color = 90}
            Name = Weapons[X,entity]:type():sub(1,20)
            if (X+3 < 17) {Screen:writeString(Name,0,3+X,Color)} else {
                Screen2:writeString(Name,0,X-14,Color)
            }
        }
    }
}

if (changed(Play)) {
    if (Play) {soundPlay(0,0,"synth/square.wav"), timer("stop",500)} else {soundStop(0)}
}
if (clk("stop")) {Play = 0}

if (Reset & ~Reset) {Play = 0, Target = noentity(), Weapons = array()}
