@name GunStoreScreenChip
@inputs CS:wirelink Ar Br Cr Dr Er Fr Gr Hr Ir Jr Up Down Money Buy
@outputs A B C D E F G H I J Reset Spawnamount
@persist Chat:array Ap Bp Cp Dp Ep Fp Gp Hp Ip Jp Al Bl Cl Dl El Fl Gl Hl Il Jl Selected Saved:array
@trigger 
interval(1000)
runOnChat(1)
Reset = 0
if(first()){
    Ap = 200
    Bp = 500
    Cp = 450
    Dp = 700
    Ep = 600
    Fp = 400
    Gp = 500
    Hp = 250
    Ip = 300
    Jp = 350
   
}
#setprice and reset chatfunction
if(chatClk(owner())){
    Chat = owner():lastSaid():explode(" ")
    if(Chat[1,string]=="!setprice"){
        hideChat(1)
        if(Chat[2,string]=="Deagle"){
            Ap = Chat[3,string]:toNumber()
        }
        elseif(Chat[2,string]=="AK47"){
            Bp = Chat[3,string]:toNumber()
        }
        elseif(Chat[2,string]=="M4A1"){
            Cp = Chat[3,string]:toNumber()
        }
        elseif(Chat[2,string]=="M249"){
            Dp = Chat[3,string]:toNumber()
        }
        elseif(Chat[2,string]=="AWP"){
            Ep = Chat[3,string]:toNumber()
        }
        elseif(Chat[2,string]=="Shotgun"){
            Fp = Chat[3,string]:toNumber()
        }
        elseif(Chat[2,string]=="Galil"){
            Gp = Chat[3,string]:toNumber()
        }
        elseif(Chat[2,string]=="Knife"){
            Hp = Chat[3,string]:toNumber()
        }
        elseif(Chat[2,string]=="Lockpick"){
            Ip = Chat[3,string]:toNumber()
        }
        elseif(Chat[2,string]=="Armor"){
            Jp = Chat[3,string]:toNumber()
        }
        else{printColor(vec(255,255,255),"Unrecognised weapon name, The avaible names are :",vec(255,0,0),"Deagle, AK47, M4A1, M249, AWP, Shotgun, Galil, Knife, Lockpick, Armor",vec(255,255,255)," These are case sensitive")
        }
    }
    if(Chat[1,string]=="!reset"){
        hideChat(1)
        Reset = 1
    }
}
#prices and weapon names      
CS:writeString(owner():name()+"'s Gun Shop",0,1,500,222,1)
CS:writeString("Deposited Amount:  "+(Money-Saved[1,normal]),0,2,50,20)
CS:writeString("Deagle ------ "+Ap+"$",0,4,9,2,Al)
CS:writeString("AK47 -------- "+Bp+"$",0,5,9,2,Bl)
CS:writeString("M4A1 -------- "+Cp+"$",0,6,9,2,Cl)
CS:writeString("M249 -------- "+Dp+"$",0,7,9,2,Dl)
CS:writeString("AWP --------- "+Ep+"$",0,8,9,2,El)
CS:writeString("Shotgun ----- "+Fp+"$",0,9,9,2,Fl)
CS:writeString("Galil ------- "+Gp+"$",0,10,9,2,Gl)
CS:writeString("Knife ------- "+Hp+"$",0,11,9,2,Hl)
CS:writeString("Lockpick ---- "+Ip+"$",0,12,9,2,Il)
CS:writeString("Armor ------- "+Jp+"$",0,13,9,2,Jl)


# In stock and out of stock message

if(Ar==0){
    CS:writeString("OUT OF STOCK",18,4,900,0,1)
}
else{CS:writeString("  IN STOCK  ",18,4,90,0,1)}

if(Br==0){
    CS:writeString("OUT OF STOCK",18,5,900,0,1)
}
else{CS:writeString("  IN STOCK  ",18,5,90,0,1)}

if(Cr==0){
    CS:writeString("OUT OF STOCK",18,6,900,0,1)
}
else{CS:writeString("  IN STOCK  ",18,6,90,0,1)}

if(Dr==0){
    CS:writeString("OUT OF STOCK",18,7,900,0,1)
}
else{CS:writeString("  IN STOCK  ",18,7,90,0,1)}

if(Er==0){
    CS:writeString("OUT OF STOCK",18,8,900,0,1)
}
else{CS:writeString("  IN STOCK  ",18,8,90,0,1)}

if(Fr==0){
    CS:writeString("OUT OF STOCK",18,9,900,0,1)
}
else{CS:writeString("  IN STOCK  ",18,9,90,0,1)}

if(Gr==0){
    CS:writeString("OUT OF STOCK",18,10,900,0,1)
}
else{CS:writeString("  IN STOCK  ",18,10,90,0,1)}

if(Hr==0){
    CS:writeString("OUT OF STOCK",18,11,900,0,1)
}
else{CS:writeString("  IN STOCK  ",18,11,90,0,1)}

if(Ir==0){
    CS:writeString("OUT OF STOCK",18,12,900,0,1)
}
else{CS:writeString("  IN STOCK  ",18,12,90,0,1)}

if(Jr==0){
    CS:writeString("OUT OF STOCK",18,13,900,0,1)
}
else{CS:writeString("  IN STOCK  ",18,13,90,0,1)}


#Selected
if(Down == 1 & Selected != 9){
    Selected++
}
elseif(Up == 1 & Selected != 0){
    Selected--
}
if(Selected==0){
    Al = 1
    Bl = 0
}
elseif(Selected==1){
    Al = 0
    Bl = 1
    Cl = 0
}
elseif(Selected==2){
    Bl = 0
    Cl = 1
    Dl = 0
}
elseif(Selected==3){
    Cl = 0
    Dl = 1
    El = 0
}
elseif(Selected==4){
    Dl = 0
    El = 1
    Fl = 0
}
elseif(Selected==5){
    El = 0
    Fl = 1
    Gl = 0
}
elseif(Selected==6){
    Fl = 0
    Gl = 1
    Hl = 0
}
elseif(Selected==7){
    Gl = 0
    Hl = 1
    Il = 0
}
elseif(Selected==8){
    Hl = 0
    Il = 1
    Jl = 0
}
elseif(Selected==9){
    Il = 0
    Jl = 1
}

if(Buy==1&Money>=Ap&Selected==0){A=1,Saved[1,normal]=Saved[1,normal]+Ap}else{A=0}
if(Buy==1&Money>=Bp&Selected==1){B=1,Saved[1,normal]=Saved[1,normal]+Bp}else{B=0}
if(Buy==1&Money>=Cp&Selected==2){C=1,Saved[1,normal]=Saved[1,normal]+Cp}else{C=0}
if(Buy==1&Money>=Dp&Selected==3){D=1,Saved[1,normal]=Saved[1,normal]+Dp}else{D=0}
if(Buy==1&Money>=Ep&Selected==4){E=1,Saved[1,normal]=Saved[1,normal]+Ep}else{E=0}
if(Buy==1&Money>=Fp&Selected==5){F=1,Saved[1,normal]=Saved[1,normal]+Fp}else{F=0}
if(Buy==1&Money>=Gp&Selected==6){G=1,Saved[1,normal]=Saved[1,normal]+Gp}else{G=0}
if(Buy==1&Money>=Hp&Selected==7){H=1,Saved[1,normal]=Saved[1,normal]+Hp}else{H=0}
if(Buy==1&Money>=Ip&Selected==8){I=1,Saved[1,normal]=Saved[1,normal]+Ip}else{I=0}
if(Buy==1&Money>=Jp&Selected==9){J=1,Saved[1,normal]=Saved[1,normal]+Jp}else{J=0}
if(Saved[1,normal]>=Money){Saved[1,normal]=0}
if (A==1 | B==1 | C==1 | D==1 | E==1 | F==1 | G==1 | H==1 | I==1 | J==1)
{Spawnamount = Saved[1,normal]=Saved[1,normal]-Saved[1,normal]} else {Spawnamount=0}

