@name Ranged Auto-Emptier
@persist Made Elapsed [Entity Owner]:entity

if(first()) {
    Owner=owner()
    Entity=entity()
    
    entity():setAlpha(0)
    
    function string prettyInt(N:number) {
        #print(N)
        local Str=ceil(N):toString():reverse():explode("")
        local Count=Str:count()
        local Add=1
        for (I=0, Str:count(), 3) {
            if (I!=0 & I!=Count & Str[I+1,string]) {Str:insertString(I+Add,",") Add++}
        }
        return Str:concat():reverse()
    }
    
    function string getTime(Num:number) {
        Min=floor(Num/60)
        Sec=Num-(Min*60)
        if (Sec>=10) {
            return ""+Min+":"+Sec
        } else {
            return ""+Min+":0"+Sec
        }
    }
}

interval(10000)
Elapsed+=10

local Printers=0

findInSphere(entity():pos(),100)
findByClass("ngii_a_printer")

foreach(I,V:entity=findToArray()) {
    if(V:pos():distance(Entity:pos())<400) {
        concmd("ngii "+V:id())
        Made+=450
        Printers++
    }
}

setName("Printer System\nCash made: $"+prettyInt(Made)+"\nTime elapsed: "+getTime(Elapsed)+"\nPrinters: "+Printers)
