Sony_08

Sony's Smart Shipment Container

Mar 8th, 2020
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.85 KB | None | 0 0
  1. @name Sony's Smart Shipment Box
  2. @inputs [EGP]:wirelink [User]:entity Ranger
  3. @outputs ShipmentUser
  4. @persist CanSell
  5. @trigger
  6.  
  7. # SmartContainer V0.2
  8. # Made by Sony - https://steamcommunity.com/id/Sony_08/
  9. # Hit me up if you have any questions or feedback!
  10.  
  11.  
  12. # --== SmartContainer Config: ==-- #
  13.  
  14.  
  15. GunName = "Deagle"    # What gun are we selling? (String)
  16. GunPrice = 200        # For what price?          (Number)
  17.  
  18.  
  19. # By default this uses some sounds from TF2 because they sound better IMO.
  20. # For those that don't want to use TF2 content, just change these vars to use HL2 sounds instead.
  21.  
  22. Sound_Purchase = "mvm/mvm_bought_upgrade.wav"   # What sound plays when someone buys something? (string)
  23. Sound_Failed = "mvm/mvm_money_vanish.wav"       # What sound plays when there is a problem.     (string)
  24.  
  25. # Your local or preferred currency symbol.
  26. CurrencySymbol = "£"
  27.  
  28. # --== End of config, don't edit below here unless you know what you're doing. ==-- #
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37. if(first() || dupefinished())
  38. {
  39.     ShipmentUser = 0
  40.    
  41.     function void prefixPrint(Text:string)
  42.     {
  43.         printColor(vec(100, 100, 255), format("\n[%s]", "SmartContainer"), vec(180), " : ", Text)
  44.     }
  45.    
  46.     function void wirelink:mainScreen()
  47.     {
  48.         This:egpClear()
  49.        
  50.         This:egpBox(1, vec2(256), vec2(512))
  51.         This:egpColor(1, vec(25))
  52.        
  53.         This:egpCircle(2, vec2(256), vec2(196))
  54.         This:egpColor(2, vec(35))
  55.        
  56.         # What gun are we selling?
  57.         This:egpText(3, GunName, vec2(256, 190))
  58.         This:egpAlign(3, 1, 1)
  59.         This:egpSize(3, 100)
  60.        
  61.         # For what price?
  62.         This:egpText(4, CurrencySymbol+GunPrice, vec2(256, 276))
  63.         This:egpAlign(4, 1, 1)
  64.         This:egpSize(4, 80)
  65.        
  66.         # Smaller text underneath tells people what to do.
  67.         This:egpText(5, "Press E to buy", vec2(256, 340))
  68.         This:egpAlign(5, 1, 1)
  69.         This:egpSize(5, 50)
  70.     }
  71.    
  72.     # What shows on the screen when somone purchases our contents:
  73.     function void wirelink:purchasedScreen()
  74.     {
  75.         EGP:entity():soundPlay(1, 1, Sound_Purchase)
  76.         EGP:egpSetText(3, "Thanks!")
  77.         EGP:egpSetText(4, ":)")
  78.         EGP:egpSetText(5, "Enjoy")
  79.         EGP:egpColor(3, vec(0, 255, 0))
  80.         ShipmentUser = 1
  81.         timer("Reset", 3000)
  82.     }
  83.    
  84.     # What shows on the screen when somone tries to buy, but can't:
  85.    function void wirelink:failedScreen()
  86.    {
  87.        EGP:entity():soundPlay(1, 1, Sound_Failed)
  88.        EGP:egpSetText(3, "Failed.")
  89.        EGP:egpSetText(4, ":(")
  90.        EGP:egpSetText(5, "Not enough?")
  91.        EGP:egpColor(3, vec(255, 0, 0))
  92.        timer("Reset", 3000)
  93.    }
  94.    
  95.    EGP:mainScreen()
  96.  
  97.    if (Ranger == 0) {
  98.        prefixPrint("\nYour container with stock '"+GunName+"' is empty and needs refilling!\nContainer will reboot in 2 minutes.")
  99.        EGP:egpSetText(3, "Empty")
  100.        EGP:egpSetText(4, ":(")
  101.        EGP:egpSetText(5, "Try again later")
  102.        EGP:egpColor(3, vec(255, 0, 0))
  103.        CanSell = 0
  104.        
  105.        timer("Reset", 120000)
  106.    }
  107.    else
  108.    {
  109.        CanSell = 1
  110.    }
  111. }
  112.  
  113. # Was the execution caused by a change in the input "User"
  114. elseif(~User & User)
  115. {
  116.    if(CanSell == 1) {
  117.        CurPly = User
  118.        EGP:mainScreen()
  119.        moneyRequest(CurPly,GunPrice,"Purchase 1x "+GunName+" from SmartContainer:")
  120.    }
  121.    else
  122.    {
  123.        prefixPrint("Someone tried to buy your stuff but we're out of stock!")
  124.        EGP:entity():soundPlay(1, 1, Sound_Failed)
  125.    }
  126. }
  127.  
  128. # Purchase success!
  129. if(moneyClk()){
  130.    prefixPrint("Someone bought 1x '"+GunName+"' from your SmartContainer!")
  131.    EGP:purchasedScreen()
  132. }
  133.  
  134. # Purchase failed, they clicked no or it timed out.
  135. if(moneyNoClk() | moneyTimeout()){
  136.    EGP:failedScreen()
  137. }
  138.  
  139. if(clk("Reset"))
  140. {
  141.    reset()
  142. }
Advertisement
Add Comment
Please, Sign In to add comment