@name Div's Gunshop By Bacon Sammich
@inputs S:wirelink [User R1 R2 R3 R4]:entity
@outputs Shipment1 Shipment2 Shipment3 Shipment4 Door  
@persist [BGChange]:array Shipment1 Shipment2 Shipment3 Shipment4 
@persist Seconds Current Door Shop Selection1 Selection2 Ra1 Ra2 Ra3 Ra4
@persist Selection3 Selection4 Confirm Dist1 Dist2 Dist3 Dist4 Select:string
@persist SlotCheck Swap Return Gun1Price Gun2Price Gun3Price Gun4Price
@persist [Text1 Text2 Text3 Text4 Text5 Text6 Text7 AmountL]:string 
interval(400)
if(S&~S){reset()}
#[
BBBBBBBBBBBBBBBBB                                                                            
B::::::::::::::::B                                                                           
B::::::BBBBBB:::::B                                                                          
BB:::::B     B:::::B                                                                         
  B::::B     B:::::B  aaaaaaaaaaaaa       cccccccccccccccc   ooooooooooo   nnnn  nnnnnnnn    
  B::::B     B:::::B  a::::::::::::a    cc:::::::::::::::c oo:::::::::::oo n:::nn::::::::nn  
  B::::BBBBBB:::::B   aaaaaaaaa:::::a  c:::::::::::::::::co:::::::::::::::on::::::::::::::nn 
  B:::::::::::::BB             a::::a c:::::::cccccc:::::co:::::ooooo:::::onn:::::::::::::::n
  B::::BBBBBB:::::B     aaaaaaa:::::a c::::::c     ccccccco::::o     o::::o  n:::::nnnn:::::n
  B::::B     B:::::B  aa::::::::::::a c:::::c             o::::o     o::::o  n::::n    n::::n
  B::::B     B:::::B a::::aaaa::::::a c:::::c             o::::o     o::::o  n::::n    n::::n
  B::::B     B:::::Ba::::a    a:::::a c::::::c     ccccccco::::o     o::::o  n::::n    n::::n
BB:::::BBBBBB::::::Ba::::a    a:::::a c:::::::cccccc:::::co:::::ooooo:::::o  n::::n    n::::n
B:::::::::::::::::B a:::::aaaa::::::a  c:::::::::::::::::co:::::::::::::::o  n::::n    n::::n
B::::::::::::::::B   a::::::::::aa:::a  cc:::::::::::::::c oo:::::::::::oo   n::::n    n::::n
BBBBBBBBBBBBBBBBB     aaaaaaaaaa  aaaa    cccccccccccccccc   ooooooooooo     nnnnnn    nnnnnn
]#
BGChange = array("vgui/appchooser/background_ep2","vgui/appchooser/background_episodic","vgui/appchooser/background_hl2")
Seconds = 4000 #think of it like this 25 + 000 = 25 seconds (1000 for 1)


if(first()){
    Current=1
    Shop = 0
    S:egpClear()
        function number wirelink:pIR(Idx:number,Ply:entity,TopLeft:number)
    {
        TL = This:egpPos(Idx) - This:egpSize(Idx) / 2 * (TopLeft ? 0 : 1)
        BR = This:egpPos(Idx) + This:egpSize(Idx) / (TopLeft ? 1 : 2)
        Cur = This:egpCursor(Ply)
        return inrange(Cur, TL, BR)
    }}

#---- Do not Touch Boxes

S:egpBox(1,vec2(256,256),vec2(512,512))
S:egpMaterial(1,BGChange[Current,string])


#---- Do not Touch If's
timer("Changer",Seconds)
if(clk("Changer")){Current+=1}
if(Current>=4){Current=1}
#----

#---- Deleteables ----# (In sense of e2s)
S:egpCircle(2,vec2(256,256),vec2(100,100))
S:egpColor(2,vec4(0,0,255,100))
S:egpText(3,"Tap Anywhere to begin.",vec2(170,240))
S:egpBox(4,vec2(256,256),vec2(512,512))
S:egpColor(4,vec4(0,0,0,0))
#----

if(~User & User & !Shop){if( S:pIR(4, User, 0) ) {Shop = !Shop}}
if(~User & User & Shop){if( S:pIR(5, User, 0) ) {Selection1 = 1 Selection2 = 0 Selection3 = 0 Selection4 = 0}}
if(~User & User & Shop){if( S:pIR(6, User, 0) ) {Selection1 = 0 Selection2 = 1 Selection3 = 0 Selection4 = 0}}
if(~User & User & Shop){if( S:pIR(7, User, 0) ) {Selection1 = 0 Selection2 = 0 Selection3 = 1 Selection4 = 0}}
if(~User & User & Shop){if( S:pIR(8, User, 0) ) {Selection1 = 0 Selection2 = 0 Selection3 = 0 Selection4 = 1}}
if(~User & User & Shop){if( S:pIR(15, User, 0)){Confirm=1}}

if(Shop){
    Dist1 = 70
    Dist2 = 70
    Dist3 = 70
    Dist4 = 70

    S:egpRemove(3)
    S:egpRemove(4)
    
    S:egpBox(2, vec2(256,256),vec2(455,455))
    S:egpColor(2, vec4(20,20,20,220))
    
    #---- The 4 Selection Buttons ----#
    S:egpBox(5, vec2(120,80),vec2(125,40))#Box 1
    S:egpBox(6, vec2(120,130),vec2(125,40))#Box 2
    S:egpBox(7, vec2(120,180),vec2(125,40))#Box 3
    S:egpBox(8, vec2(120,230),vec2(125,40))#Box 4
    S:egpText(9,R1:shipmentName(),vec2(Dist1,70))#Box 1 Text
    S:egpText(10,R2:shipmentName(),vec2(Dist2,120))#Box 2 Text
    S:egpText(11,R3:shipmentName(),vec2(Dist3,170))#Box 3 Text
    S:egpText(12,R4:shipmentName(),vec2(Dist4,220))#Box 4 Text
    S:egpSize(9,15)
    S:egpSize(10,15)
    S:egpSize(11,15)
    S:egpSize(12,15)
    #---- ----#
    
    S:egpBox(13, vec2(325,155),vec2(250,188))
    S:egpColor(13, vec4(0,0,255,100))
    S:egpBox(14, vec2(255,350),vec2(390,180))
    S:egpColor(14, vec4(0,0,255,100))
    
    S:egpBox(15, vec2(256,410),vec2(300,30))#Purchase Button
    S:egpText(16,"Purchase a :",vec2(170,400))
    S:egpText(17, Select ,vec2(266,403))
    S:egpSize(17,15)
    
    S:egpText(18,Text1,vec2(70,265))
    S:egpText(19,Text2,vec2(70,280))
    S:egpText(20,Text3,vec2(70,295))
    S:egpText(21,Text4,vec2(70,310))
    S:egpText(22,Text5,vec2(70,325))
    S:egpText(23,Text6,vec2(70,340))
    S:egpText(24,Text7,vec2(70,355))
    S:egpText(25,"Amount left :",vec2(215,75))
    S:egpText(27,"Price :",vec2(215,100))
    S:egpSize(18,15)
    S:egpSize(19,15)
    S:egpSize(20,15)
    S:egpSize(21,15)
    S:egpSize(22,15)
    S:egpSize(23,15)
    S:egpSize(24,15)

    
}
if(Selection1 & !Selection2 & !Selection3 & !Selection4){
        Ra1=1 Ra2=0 Ra3=0 Ra4=0
        Gun1Price=R1:shipmentPrice()/7
        S:egpText(26,R1:shipmentAmount():toString(),vec2(320,75))
        S:egpText(28,round(Gun1Price):toString(),vec2(280,100))
        Select = R1:shipmentName()
        S:egpColor(5, vec4(0,255,0,100))
        S:egpColor(6, vec4(0,0,255,100))
        S:egpColor(7, vec4(0,0,255,100))
        S:egpColor(8, vec4(0,0,255,100))
}
if(!Selection1 & Selection2 & !Selection3 & !Selection4){
        Ra1=0 Ra2=1 Ra3=0 Ra4=0
        Gun2Price=R2:shipmentPrice()/7
        S:egpText(26,R2:shipmentAmount():toString(),vec2(320,75))
        S:egpText(28,round(Gun2Price):toString(),vec2(280,100))
        Select = R2:shipmentName()
        S:egpColor(5, vec4(0,0,255,100))
        S:egpColor(6, vec4(0,255,0,100))
        S:egpColor(7, vec4(0,0,255,100))
        S:egpColor(8, vec4(0,0,255,100))
}
if(!Selection1 & !Selection2 & Selection3 & !Selection4){
        Ra1=0 Ra2=0 Ra3=1 Ra4=0
        Gun3Price=R3:shipmentPrice()/7
        S:egpText(26,R3:shipmentAmount():toString(),vec2(320,75))
        S:egpText(28,round(Gun3Price):toString(),vec2(280,100))
        Select = R3:shipmentName()
        S:egpColor(5, vec4(0,0,255,100))
        S:egpColor(6, vec4(0,0,255,100))
        S:egpColor(7, vec4(0,255,0,100))
        S:egpColor(8, vec4(0,0,255,100))
}
if(!Selection1 & !Selection2 & !Selection3 & Selection4){
        Ra1=0 Ra2=0 Ra3=0 Ra4=1
        Gun4Price=R4:shipmentPrice()/7
        S:egpText(26,R4:shipmentAmount():toString(),vec2(320,75))
        S:egpText(28,round(Gun4Price):toString(),vec2(280,100))
        Select = R4:shipmentName()
        S:egpColor(5, vec4(0,0,255,100))
        S:egpColor(6, vec4(0,0,255,100))
        S:egpColor(7, vec4(0,0,255,100))
        S:egpColor(8, vec4(0,255,0,100))
}
if(Shop & !Selection1 & !Selection2 & !Selection3 & !Selection4){
        Ra1=0 Ra2=0 Ra3=0 Ra4=0
        S:egpColor(5, vec4(0,0,255,100))
        S:egpColor(6, vec4(0,0,255,100))
        S:egpColor(7, vec4(0,0,255,100))
        S:egpColor(8, vec4(0,0,255,100))
    }
if(Shop & !Confirm & !Ra1 & !Ra2 & !Ra3 & !Ra4){S:egpColor(15, vec4(255,0,0,100)) Confirm=0}
if(Shop & Confirm & !Ra1 & !Ra2 & !Ra3 & !Ra4){S:egpColor(15, vec4(255,0,0,100)) Confirm=0}
if(Shop & !Confirm & Ra1 | Shop & !Confirm & Ra2 | Shop & !Confirm & Ra3 | Shop & !Confirm & Ra4){S:egpColor(15, vec4(255,0,0,100))}
if(Shop & Confirm){S:egpColor(15, vec4(0,255,0,100)) SlotCheck=1}


if(R1:shipmentName()=="PUMP SHOTGUN" & Ra1 | R2:shipmentName()=="PUMP SHOTGUN" & Ra2 | R3:shipmentName()=="PUMP SHOTGUN" & Ra3 | R4:shipmentName()=="PUMP SHOTGUN" & Ra4)
{
    Text1 = "The Savage Arms/Stevens 350 Security Pump-Action"
    Text2 = "Shotgun is loaded with tactical features,"
    Text3 = "making it a must-have for home defense. Its 18.5\""
    Text4 = "carbon steel barrel ensures lasting durability,"
    Text5 = "while the synthetic stock offers a secure, comfortable hold."
    Text6 = "Tube magazine with a 8 round capacity right hand"
    Text7 = "desgin and a left eject."
}
if(R1:shipmentName()=="CROWBAR" & Ra1 | R2:shipmentName()=="CROWBAR" & Ra2 | R3:shipmentName()=="CROWBAR" & Ra3 | R4:shipmentName()=="CROWBAR" & Ra4)
{
    Text1 = "Commonly used as a lever to pry 2 thing appart"
    Text2 = "but also a nice useful thing to bash a head in"
    Text3 = "with the bent steel or iron it only takes 2 hits"
    Text4 = "on the head to sucessfully kill someone."
    Text5 = ""
    Text6 = ""
    Text7 = ""
}
if(R1:shipmentName()==".357 MAGNUM" & Ra1 | R2:shipmentName()==".357 MAGNUM" & Ra2 | R3:shipmentName()==".357 MAGNUM" & Ra3 | R4:shipmentName()==".357 MAGNUM" & Ra4)
{
    Text1 = "The .357 Magnum is a revolver cartidge with a 9.07mm "
    Text2 = "bullet diameter, created by Elmer Keith, Phillip B. Sharpe,"
    Text3 = "and Colonel D. B. Wesson of Smith & Wesson firearms "
    Text4 = "manufacturer."
    Text5 = ""
    Text6 = ""
    Text7 = ""
}
if(R1:shipmentName()=="PULSE-RIFLE" & Ra1 | R2:shipmentName()=="PULSE-RIFLE" & Ra2 | R3:shipmentName()=="PULSE-RIFLE" & Ra3 | R4:shipmentName()=="PULSE-RIFLE" & Ra4)
{
    Text1 = "Standard issued high-powered rifle to combines."
    Text2 = ""
    Text3 = ""
    Text4 = ""
    Text5 = ""
    Text6 = ""
    Text7 = ""
}
if(R1:shipmentName()=="AK47" & Ra1 | R2:shipmentName()=="AK47" & Ra2 | R3:shipmentName()=="AK47" & Ra3 | R4:shipmentName()=="AK47" & Ra4)
{
    Text1 = "The AK-47 is a selective-fire, gas-operated "
    Text2 = "7.62x39mm assault rifle first developed in the"
    Text3 = "Soviet Union by Mikhail Kalashnikov. It is "
    Text4 = "officially know in the Soviet documentation as "
    Text5 = "Avtomat Kalashnikova. It is also know as Kalash."
    Text6 = ""
    Text7 = ""
}
if(R1:shipmentName()=="MP5" & Ra1 | R2:shipmentName()=="MP5" & Ra2 | R3:shipmentName()=="MP5" & Ra3 | R4:shipmentName()=="MP5" & Ra4)
{
    Text1 = "One of the most popular submachine guns ever"
    Text2 = "produced, The MP5(\"Maschinenpistole 5\") became"
    Text3 = "a common sight throughout the latter Cold War years."
    Text4 = "The gun was adopted by many special forces groups as "
    Text5 = "well as security elements for its sound design and utmost"
    Text6 = "reliable in close-quarters actions."
    Text7 = ""
}
if(R1:shipmentName()=="AWP" & Ra1 | R2:shipmentName()=="AWP" & Ra2 | R3:shipmentName()=="AWP" & Ra3 | R4:shipmentName()=="AWP" & Ra4)
{
    Text1 = "The AWP a.k.a \"Arctic Police sniper rifle\" was"
    Text2 = "British-made for use of the common Mauser action"
    Text3 = "with an effective range of 800+ meters."
    Text4 = ""
    Text5 = ""
    Text6 = ""
    Text7 = ""
}
if(R1:shipmentName()=="STUNSTICK" & Ra1 | R2:shipmentName()=="STUNSTICK" & Ra2 | R3:shipmentName()=="STUNSTICK" & Ra3 | R4:shipmentName()=="STUNSTICK" & Ra4)
{
    Text1 = "Stunstick, is an electrified baton used by "
    Text2 = "Civil Protection officers to enforce the law "
    Text3 = "on unruly citizens, or simply to beat them."
    Text4 = ""
    Text5 = ""
    Text6 = ""
    Text7 = ""
}
if(R1:shipmentName()=="KARATE TRAINING" & Ra1 | R2:shipmentName()=="KARATE TRAINING" & Ra2 | R3:shipmentName()=="KARATE TRAINING" & Ra3 | R4:shipmentName()=="KARATE TRAINING" & Ra4)
{
    Text1 = "Its just fists."
    Text2 = ""
    Text3 = ""
    Text4 = ""
    Text5 = ""
    Text6 = ""
    Text7 = ""
}
if(R1:shipmentName()=="SMG" & Ra1 | R2:shipmentName()=="SMG" & Ra2 | R3:shipmentName()=="SMG" & Ra3 | R4:shipmentName()=="SMG" & Ra4)
{
    Text1 = "The MP7, along with the OSIPR, forms the bulk"
    Text2 = "of the Combine's small arms and is often carried"
    Text3 = "by Overwatch Soldiers and Metrocops. It is also"
    Text4 = "widely used by members of the Resistance as a"
    Text5 = "standard issue firearm."
    Text6 = ""
    Text7 = ""
}
if(R1:shipmentName()=="SHOTGUN" & Ra1 | R2:shipmentName()=="SHOTGUN" & Ra2 | R3:shipmentName()=="SHOTGUN" & Ra3 | R4:shipmentName()=="SHOTGUN" & Ra4)
{
    Text1 = "The Combine SPAS-12 is a powerful pump-action shotgun"
    Text2 = "that fires buckshot in a cone-shaped pattern."
    Text3 = ""
    Text4 = ""
    Text5 = ""
    Text6 = ""
    Text7 = ""
}
if(R1:shipmentName()=="DESERT EAGLE" & Ra1 | R2:shipmentName()=="DESERT EAGLE" & Ra2 | R3:shipmentName()=="DESERT EAGLE" & Ra3 | R4:shipmentName()=="DESERT EAGLE" & Ra4)
{
    Text1 = "The Desert Eagle (or Deagle) is a large-framed"
    Text2 = "gas-operated semi-automatic pistol designed by"
    Text3 = "IMI in Israel together with Magnum Research,"
    Text4 = "Inc. (MRI) in the United States."
    Text5 = ""
    Text6 = ""
    Text7 = ""
}
if(R1:shipmentName()=="M4A1" & Ra1 | R2:shipmentName()=="M4A1" & Ra2 | R3:shipmentName()=="M4A1" & Ra3 | R4:shipmentName()=="M4A1" & Ra4)
{
    Text1 = "The M4 carbine is a family of firearms that was  which"
    Text2 = "was derived from earlier carbine versions of the M16 rifle,"
    Text3 = "in turn derived from the original AR-15 rifle that Eugene Stoner"
    Text4 = "designed and ArmaLite manufactured."
    Text5 = ""
    Text6 = ""
    Text7 = ""
}
if(R1:shipmentName()=="MAC10" & Ra1 | R2:shipmentName()=="MAC10" & Ra2 | R3:shipmentName()=="MAC10" & Ra3 | R4:shipmentName()=="MAC10" & Ra4)
{
    Text1 = "The MAC-10 (Military Armament Corporation Model 10, officially "
    Text2 = "the M-10) is a compact, blowback operated machine pistol developed"
    Text3 = "by Gordon B. Ingram in 1964."
    Text4 = ""
    Text5 = ""
    Text6 = ""
    Text7 = ""
}
if(R1:shipmentName()=="SCOUT" & Ra1 | R2:shipmentName()=="SCOUT" & Ra2 | R3:shipmentName()=="SCOUT" & Ra3 | R4:shipmentName()=="SCOUT" & Ra4)
{
    Text1 = "Due to its short overall length of just 98 cm (38,6\") and"
    Text2 = "the low weight with approximately 3 kg (6.6 pounds), the"
    Text3 = "MANNLICHER SCOUT is the perfect rifle to be utilized"
    Text4 = "universally."
    Text5 = ""
    Text6 = ""
    Text7 = ""
}
if(R1:shipmentName()=="KEYPAD CRACKER" & Ra1 | R2:shipmentName()=="KEYPAD CRACKER" & Ra2 | R3:shipmentName()=="KEYPAD CRACKER" & Ra3 | R4:shipmentName()=="KEYPAD CRACKER" & Ra4)
{
    Text1 = "Crack peoples keypads and enter their homes."
    Text2 = ""
    Text3 = ""
    Text4 = ""
    Text5 = ""
    Text6 = ""
    Text7 = ""
}
if(R1:shipmentName()=="Invalid Shipment" & Ra1 | R2:shipmentName()=="Invalid Shipment" & Ra2 | R3:shipmentName()=="Invalid Shipment" & Ra3 | R4:shipmentName()=="Invalid Shipment" & Ra4)
{
    Text1="" Text2="" Text3="" Text4=""
    Text5="" Text6="" Text7=""
}

if(SlotCheck&Ra1){
    moneyRequest(User, Gun1Price, 15, "Purchase a gun?")
    if(moneyClk("Purchase a gun?")){print("Test") Shipment1=!Shipment1 moneyClkPlayer():name()+" Purchased a gun." timer("Swap",250) Return=!Return Confirm=0}
    if(moneyNoClk("Purchase a gun?")){print(moneyNoClkPlayer():name()+" Did not Purchase a gun.") timer("Swap",250)}
    if(moneyTimeout("Purchase a gun?")){print(moneyTimeoutPlayer():name()+" timed out.") timer("Swap",250)}
}
if(SlotCheck&Ra2){
    moneyRequest(User, Gun2Price, 15, "Purchase a gun?")
    if(moneyClk("Purchase a gun?")){print("Test") Shipment2=!Shipment2 moneyClkPlayer():name()+" Purchased a gun." timer("Swap",250) Return=!Return Confirm=0}
    if(moneyNoClk("Purchase a gun?")){print(moneyNoClkPlayer():name()+" Did not Purchase a gun.") timer("Swap",250)}
    if(moneyTimeout("Purchase a gun?")){print(moneyTimeoutPlayer():name()+" timed out.") timer("Swap",250)}
}
if(SlotCheck&Ra3){
    moneyRequest(User, Gun3Price, 15, "Purchase a gun?")
    if(moneyClk("Purchase a gun?")){print("Test") Shipment3=!Shipment3 moneyClkPlayer():name()+" Purchased a gun." timer("Swap",250) Return=!Return Confirm=0}
    if(moneyNoClk("Purchase a gun?")){print(moneyNoClkPlayer():name()+" Did not Purchase a gun.") timer("Swap",250)}
    if(moneyTimeout("Purchase a gun?")){print(moneyTimeoutPlayer():name()+" timed out.") timer("Swap",250)}
}
if(SlotCheck&Ra4){
    moneyRequest(User, Gun4Price, 15, "Purchase a gun?")
    if(moneyClk("Purchase a gun?")){print("Test") Shipment4=!Shipment4 moneyClkPlayer():name()+" Purchased a gun." timer("Swap",250) Return=!Return}
    if(moneyNoClk("Purchase a gun?")){print(moneyNoClkPlayer():name()+" Did not Purchase a gun.") timer("Swap",250)}
    if(moneyTimeout("Purchase a gun?")){print(moneyTimeoutPlayer():name()+" timed out.") timer("Swap",250)}
}

if(clk("Swap")){
    SlotCheck=0
    Confirm=0
    if(Shipment1){Shipment1=!Shipment1}
    if(Shipment2){Shipment2=!Shipment2}
    if(Shipment3){Shipment3=!Shipment3}
    if(Shipment4){Shipment4=!Shipment4}
    if(Selection1){Selection1=!Selection1}
    if(Selection2){Selection2=!Selection2}
    if(Selection3){Selection3=!Selection3}
    if(Selection4){Selection4=!Selection4}
    }

