@name Climbshit
@inputs 
@outputs N Go X Y
@persist E:array Z I Won PlayerMony:table A
@trigger 

interval(10)

PropCount = 50
Radius = 100
ZFactor = 30

timer("FIRST",250)
if(clk("FIRST"))
{
    if(N < PropCount)
    {
        N++
        #Pos = vec(random(-Radius,Radius),random(-Radius,Radius),N * ZFactor)
        Pos = vec(sin(curtime() * Radius) * Radius,cos(curtime() * Radius) * Radius,N * ZFactor)
        E[N,entity] = propSpawn("models/hunter/blocks/cube1x1x1.mdl",entity():pos() + Pos,1)
        E[N,entity]:setColor(vec4(128,128,128,128))
        if(N == PropCount){E[N,entity]:setColor(vec4(255,128,0,128))}
    }
}
if(Z < E:count()){Z++}else{Z=0}
if(entity():toLocal(E[Z,entity]:pos()):x() > 200){X = -10}else{X = randint(-10,10)}
if(entity():toLocal(E[Z,entity]:pos()):x() < -200){X = 10}else{X = randint(-10,10)}

if(entity():toLocal(E[Z,entity]:pos()):y() > 200){Y = -10}else{Y = randint(-10,10)}
if(entity():toLocal(E[Z,entity]:pos()):y() < -200){Y = 10}else{Y = randint(-10,10)}

#E[Z,entity]:setPos(E[Z,entity]:pos() + vec(X,Y,0))

findByClass("player")
if(I < maxPlayers())
{
    I++
    if(E[PropCount,entity]:pos():distance(findResult(I):pos()) < 50 & Won == 0)
    {
        PlayerMony[findResult(I):name(),number] = PlayerMony[findResult(I):name(),number] + 1
        concmd("say " + findResult(I):name() + " won! " + PlayerMony[findResult(I):name(),number] + "$ Now.")
        Won = 1
        A = 0
    }
}
else
{
    I = 0
}

if(Won == 1)
{
    if(A < PropCount)
    {
        A++
        #Pos = vec(random(-Radius,Radius),random(-Radius,Radius),N * ZFactor)
        Pos = vec(sin(curtime() * Radius) * Radius,cos(curtime() * Radius) * Radius,A * ZFactor)
        E[A,entity]:setPos(entity():pos() + Pos)
        if(A == PropCount){Won = 0}
    }
}
