@name ChronoStore_By_Jim_Dangle
@inputs EGP:wirelink Owner:wirelink UP DOWN SELECT MONEY R1 R2 R3 R4 R5 R6
@outputs U1 U2 U3 U4 U5 U6 UM
@persist Index P1 P2 P3 P4 P5 P6 I1:string I2:string I3:string I4:string I5:string I6:string
runOnChat(1)


EGP:egpClear()
if(first()){Owner:egpClear() EGP:egpClear()}

List = array(I1,I2,I3,I4,I5,I6)
Price = array(P1,P2,P3,P4,P5,P6)
#Chat shit

CMD = owner():lastSaid():explode(" ")
if(chatClk(owner())){
if(CMD:string(1) == "!p1"){
    hideChat(1)
    P1 = owner():lastSaid():sub(4):toNumber()
    }
if(CMD:string(1) == "!p2"){
     hideChat(1)
    P2 = owner():lastSaid():sub(4):toNumber()
    }
if(CMD:string(1) == "!p3"){
     hideChat(1)
    P3 = owner():lastSaid():sub(4):toNumber()
    }
if(CMD:string(1) == "!p4"){
     hideChat(1)
    P4 = owner():lastSaid():sub(4):toNumber()
    }
if(CMD:string(1) == "!p5"){
     hideChat(1)
    P5 = owner():lastSaid():sub(4):toNumber()
    }    
if(CMD:string(1) == "!p6"){
     hideChat(1)
    P6 = owner():lastSaid():sub(4):toNumber()
    }    
if(CMD:string(1)== "!i1"){
     hideChat(1)
    I1 = owner():lastSaid():sub(4)
    }
if(CMD:string(1)== "!i2"){
     hideChat(1)
    I2 = owner():lastSaid():sub(4)
    }
if(CMD:string(1)== "!i3"){
     hideChat(1)
    I3 = owner():lastSaid():sub(4)
    }
if(CMD:string(1)== "!i4"){
     hideChat(1)
    I4 = owner():lastSaid():sub(4)
    }
if(CMD:string(1)== "!i5"){
     hideChat(1)
    I5 = owner():lastSaid():sub(4)
    }
if(CMD:string(1)== "!i6"){
     hideChat(1)
    I6 = owner():lastSaid():sub(4)
    }
if(CMD:string(1)=="!stock"){
    if(R1>=1){EGP:egpColor(25,vec(0,255,0)) print(_HUD_PRINTCENTER,List[1, string] + " is in stock!")}else{_HUD_PRINTCENTER,print(List[1, string] + " is out of stock!") EGP:egpColor(25,vec(255,0,0))}
    if(R2>=1){EGP:egpColor(26,vec(0,255,0)) print(_HUD_PRINTCENTER,List[1, string] + " is in stock!")}else{_HUD_PRINTCENTER,print(List[2, string] + " is out of stock!") EGP:egpColor(26,vec(255,0,0))}
    if(R3>=1){EGP:egpColor(27,vec(0,255,0)) print(_HUD_PRINTCENTER,List[1, string] + " is in stock!")}else{_HUD_PRINTCENTER,print(List[3, string] + " is out of stock!") EGP:egpColor(27,vec(255,0,0))}
    if(R4>=1){EGP:egpColor(28,vec(0,255,0)) print(_HUD_PRINTCENTER,List[1, string] + " is in stock!")}else{_HUD_PRINTCENTER,print(List[4, string] + " is out of stock!") EGP:egpColor(29,vec(255,0,0))}
    if(R5>=1){EGP:egpColor(28,vec(0,255,0)) print(_HUD_PRINTCENTER,List[1, string] + " is in stock!")}else{_HUD_PRINTCENTER,print(List[5, string] + " is out of stock!") EGP:egpColor(29,vec(255,0,0))}
    if(R6>=1){EGP:egpColor(30,vec(0,255,0)) print(_HUD_PRINTCENTER,List[1, string] + " is in stock!")}else{_HUD_PRINTCENTER,print(List[6, string] + " is out of stock!") EGP:egpColor(30,vec(255,0,0))}
    }
}

EGP:egpText(7,"Chrono Auto Shop",vec2(10,10))
EGP:egpSize(7,40)




for(I=0, 6){
    EGP:egpCircle(I,vec2(50,30+(60*I)),vec2(10,10))
    }

for(I=0, 6){
        EGP:egpText(8+I,List[I, string],vec2(70, 23+(60*I)))
    }



for(I=0, 6){
    
        EGP:egpText(15+I,"$"+Price[I, number],vec2(150,23+(60*I)))
        EGP:egpRemove(15)
    }
    
for(I=0, 6){
        EGP:egpText(24+I,"In Stock",vec2(250, 23+(60*I)))
        EGP:egpRemove(24)
    }

if(UP==1){Index--
    soundPlay(1,1,"buttons/button3.wav")
    }
if(DOWN==1){Index++
    soundPlay(3,3,"buttons/button3.wav")
    }
if(Index>6){Index=1}
if(Index<1){Index=6}

if(SELECT==1 & MONEY==Price[1, number]){soundPlay(0,0,"buttons/button24.wav") U1 = 1 UM=1 }else{UM=0 U1 = 0}
if(SELECT==1 & MONEY==Price[2, number]){soundPlay(0,0,"buttons/button24.wav") U2 = 1 UM=1 }else{UM=0 U1 = 0}
if(SELECT==1 & MONEY==Price[3, number]){soundPlay(0,0,"buttons/button24.wav") U3 = 1 UM=1 }else{UM=0 U1 = 0}
if(SELECT==1 & MONEY==Price[4, number]){soundPlay(0,0,"buttons/button24.wav") U4 = 1 UM=1 }else{UM=0 U1 = 0}
if(SELECT==1 & MONEY==Price[5, number]){soundPlay(0,0,"buttons/button24.wav") U5 = 1 UM=1 }else{UM=0 U1 = 0}
if(SELECT==1 & MONEY==Price[6, number]){soundPlay(0,0,"buttons/button24.wav") U6 = 1 UM=1 }else{UM=0 U1 = 0}


if(SELECT==1 & MONEY<Price[Index, number]){
    soundPlay(2,2,"buttons/button10.wav")
    
    }
EGP:egpText(23,"Money: $"+MONEY,vec2(12,44))
if(Index==1){EGP:egpColor(1,vec(0,255,0))}else{EGP:egpColor(1,vec(0,150,150))}
if(Index==2){EGP:egpColor(2,vec(0,255,0))}else{EGP:egpColor(2,vec(0,150,150))}
if(Index==3){EGP:egpColor(3,vec(0,255,0))}else{EGP:egpColor(3,vec(0,150,150))}
if(Index==4){EGP:egpColor(4,vec(0,255,0))}else{EGP:egpColor(4,vec(0,150,150))}
if(Index==5){EGP:egpColor(5,vec(0,255,0))}else{EGP:egpColor(5,vec(0,150,150))}
if(Index==6){EGP:egpColor(6,vec(0,255,0))}else{EGP:egpColor(6,vec(0,150,150))}
if(R1>=1){EGP:egpColor(25,vec(0,255,0))}else{ EGP:egpColor(25,vec(255,0,0))}
if(R2>=1){EGP:egpColor(26,vec(0,255,0))}else{ EGP:egpColor(26,vec(255,0,0))}
if(R3>=1){EGP:egpColor(27,vec(0,255,0))}else{ EGP:egpColor(27,vec(255,0,0))}
if(R4>=1){EGP:egpColor(28,vec(0,255,0))}else{ EGP:egpColor(28,vec(255,0,0))}
if(R5>=1){EGP:egpColor(28,vec(0,255,0))}else{ EGP:egpColor(29,vec(255,0,0))}
if(R6>=1){EGP:egpColor(30,vec(0,255,0))}else{ EGP:egpColor(30,vec(255,0,0))}





#Store Owner Menu


Owner:egpText(1,"Chrono Store Owner Menu",vec2(150,10))
Owner:egpSize(1, 20)
Owner:egpColor(1,vec(120,120,0))
Owner:egpLine(2,vec2(0,40),vec2(600,40))
Owner:egpText(3, "Type !i1-6 to set the name of an item, example: !i1 M4A1", vec2(10,90))
Owner:egpText(4, "Type !p1-6 to set the price of an item, example: !p2 600", vec2(10,120))
Owner:egpText(5, "Type !stock to check your stock",vec2(10,150))
Owner:egpText(6, "U1-6 stand for the wire users", vec2(10,180))
Owner:egpText(7, "R1-6 stand for the wire rangers", vec2(10,210))
Owner:egpText(200, "Created by RuthlessSpork aka Jim Dangle",vec2(10,400))











