Advertisement
Guest User

Untitled

a guest
Feb 21st, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 10.97 KB | None | 0 0
  1. -- All functions must sit within a unique class
  2. -- This prevents any conflicts with other lua scripts
  3. CSGO_Example = {}
  4.  
  5. local Colore = clr.Corale.Colore
  6. local Razer =  Colore.Razer
  7. local Thread = clr.System.Threading.Thread
  8.  
  9.  
  10. -- Theme Options
  11.  
  12. local Theme = {
  13.     Colors = {
  14.         None = Colore.Core.Color(20, 20, 20),
  15.         Dead = Colore.Core.Color(255, 0, 0),
  16.         Freeze = Colore.Core.Color(255, 255, 255),
  17.         Lite = Colore.Core.Color(50, 50, 50),
  18.         Menu = Colore.Core.Color(255, 255, 255),
  19.         Counter =   Colore.Core.Color(0, 0, 255),
  20.         Terrorists = Colore.Core.Color(255, 69, 0),
  21.         Health = {
  22.             Low = Colore.Core.Color(60, 0, 0),
  23.             Full = Colore.Core.Color(255, 0, 0)
  24.         },
  25.         Weapon = {
  26.             Inactive = Colore.Core.Color(60, 0, 0),
  27.             Active = Colore.Core.Color(0, 255, 0)
  28.         },
  29.         Armor = {
  30.             Low = Colore.Core.Color(60, 0, 0),
  31.             Full = Colore.Core.Color(255, 255, 255)
  32.         },
  33.        
  34.         Ammo = {
  35.             Low = Colore.Core.Color(60, 0, 0),
  36.             Full = Colore.Core.Color(255, 255, 0)
  37.         }
  38.     }
  39. }
  40.  
  41. local Colors = {
  42.     Background = Colore.Core.Color(255, 69, 0),
  43.     One = Colore.Core.Color.Red,
  44.     Two = Colore.Core.Color.Red,
  45.     Three = Colore.Core.Color(255,140,0),
  46. }
  47.  
  48. -- CS:GO Specific fields
  49.  
  50. local _team = "NA"
  51. local _isAnimating = false
  52. local _phase = "NA"
  53. local _activity = "NA"
  54. local _helmet = false
  55. local _planted = false
  56. local _flashed = false
  57. local _burning = false
  58.  
  59.  
  60.  
  61. function CSGO_Example.SetAll(color)
  62.     Colore.Core.Chroma.Instance.SetAll(color)
  63. end
  64.  
  65.  
  66. function CSGO_Example.SetNumpad(color)
  67.  
  68.     for x=0,5 do
  69.         for y=15,21 do
  70.             Keyboard[x,y] =  color
  71.         end
  72.     end
  73.    
  74. end
  75.  
  76. -- FreezeTime Animation
  77. CSGO_Example.FreezeTime = coroutine.create(function ()
  78. local mousepadNumber = 0
  79.     while true do
  80.         _isAnimating = true
  81.         if _phase ~= "freezetime" then
  82.             CSGO_Example.SetTeam(_team)
  83.             _isAnimating = false
  84.             coroutine.yield()      
  85.         end
  86.         --Keyboard.SetAll(Colore.Core.Color.Pink)
  87.         if mousepadNumber > 7 then
  88.             Keyboard.SetKey(Razer.Keyboard.Key.Escape, Theme.Colors.Freeze)
  89.             CSGO_Example.SetNumpad(Theme.Colors.Freeze)
  90.         else
  91.         Keyboard.SetKey(Razer.Keyboard.Key.Escape, Colore.Core.Color.Black)
  92.         CSGO_Example.SetNumpad(Theme.Colors.None)
  93.         end
  94.         Mousepad.SetAll(Theme.Colors.None)
  95.         Mousepad[mousepadNumber] = Theme.Colors.Freeze
  96.         Thread.Sleep(50)       
  97.        
  98.         mousepadNumber = mousepadNumber + 1
  99.         if mousepadNumber >= 15 then
  100.             mousepadNumber = 0
  101.         end
  102.     end
  103. end)
  104.  
  105. -- Flashed Animation
  106. CSGO_Example.Flashed = coroutine.create(function ()
  107. local mousepadNumber = 0
  108.     while true do
  109.    
  110.         _isAnimating = true
  111.         if _flashed == false then
  112.             CSGO_Example.SetTeam(_team)
  113.             _isAnimating = false
  114.             coroutine.yield()      
  115.         end
  116.        
  117.         if _helmet == false then
  118.             _flashed = false
  119.             CSGO_Example.SetTeam(_team)
  120.             _isAnimating = false
  121.             coroutine.yield()      
  122.         end
  123.        
  124.         --Keyboard.SetAll(Colore.Core.Color.Pink)
  125.        
  126.         CSGO_Example.SetAll(Theme.Colors.Freeze)
  127.         Thread.Sleep(100)
  128.     end
  129. end)
  130.  
  131. CSGO_Example.Burning = coroutine.create(function ()
  132.     while true do
  133.         _isAnimating = true
  134.         if _burning ~= true then
  135.             CSGO_Example.SetTeam(_team)
  136.             _isAnimating = false
  137.             coroutine.yield()
  138.         end
  139.        
  140.         if _helmet == false then
  141.             CSGO_Example.SetTeam(_team)
  142.             _isAnimating = false
  143.             coroutine.yield()      
  144.         end
  145.        
  146.         -- set keyboard colour
  147.        
  148.         CSGO_Example.SetAll(Theme.Colors.Terrorists)
  149.        
  150.         for x=0,5 do
  151.             Keyboard[math.random(0,6), math.random(0,22)] =  Colors.One
  152.         end
  153.        
  154.         -- set mousepad colour
  155.         Mousepad[math.random(0,15)] = Colors.One
  156.  
  157.        
  158.         -- set mouse colour    
  159.         Mouse[math.random(0,9), math.random(0,7)] = Colors.One
  160.  
  161.        
  162.         -- set keypad colour
  163.        
  164.         Keypad[math.random(0,4),math.random(0,5)] = Colors.One
  165.        
  166.         -- We don't want to spam the SDK, so throttle to 50ms
  167.         Thread.Sleep(60)
  168.     end
  169. end)
  170.  
  171. CSGO_Example.Planted = coroutine.create(function ()
  172.     while true do
  173.         _isAnimating = true
  174.         if _planted ~= "planted" then
  175.             CSGO_Example.SetTeam(_team)
  176.             _isAnimating = false
  177.             coroutine.yield()      
  178.         end
  179.        
  180.         if _helmet == false then
  181.             CSGO_Example.SetTeam(_team)
  182.             _isAnimating = false
  183.             coroutine.yield()      
  184.         end
  185.        
  186.         --Keyboard.SetAll(Colore.Core.Color.Pink)
  187.         Keyboard.SetKey(Razer.Keyboard.Key.D5, Theme.Colors.Dead)
  188.         CSGO_Example.SetNumpad(Theme.Colors.Dead)
  189.  
  190.         Mousepad.SetAll(Theme.Colors.Dead)
  191.        
  192.        
  193.         Thread.Sleep(500)
  194.         --Keyboard.SetAll(Colore.Core.Color.Blue)
  195.         Keyboard.SetKey(Razer.Keyboard.Key.D5, Theme.Colors.None)
  196.         Mousepad.SetAll(Theme.Colors.None)
  197.         CSGO_Example.SetNumpad(Theme.Colors.None)
  198.         Thread.Sleep(500)
  199.     end
  200. end)
  201.  
  202. function CSGO_Example.RoundHandler(round)
  203.     if _activity == "playing" then
  204.         if round["phase"] ~= _phase then
  205.             --DebugLua("phase changed: " .. round["phase"])
  206.             _phase = round["phase"]
  207.         end
  208.        
  209.         if round["bomb"] ~= _planted then
  210.             --DebugLua("phase changed: " .. round["phase"])
  211.             _planted = round["bomb"]
  212.         end
  213.        
  214.        
  215.         if _planted == "planted" then -- Check if Phase is FreezeTime
  216.             --DebugLua("phase is now freezetime")
  217.            
  218.             coroutine.resume(CSGO_Example.Planted)
  219.         end
  220.        
  221.         if _phase == "freezetime" then -- Check if Phase is FreezeTime
  222.             --DebugLua("phase is now freezetime")
  223.                     coroutine.resume(CSGO_Example.FreezeTime)
  224.         end
  225.     end
  226.    
  227. end
  228. function CSGO_Example.PlayerHandler(player)
  229.    
  230.     if player["activity"] ~= _activity then
  231.         _activity = player["activity"]
  232.                
  233.         if _activity == "menu" then
  234.                 _team = "NA"
  235.                 _burning = false
  236.         _flashed = false
  237.         _planted = false
  238.         _phase = "NA"
  239.             CSGO_Example.SetAll(Theme.Colors.Terrorists)
  240.             Keyboard.SetKey(Razer.Keyboard.Key.C, Theme.Colors.Menu)
  241.             Keyboard.SetKey(Razer.Keyboard.Key.S, Theme.Colors.Menu)
  242.             Keyboard.SetKey(Razer.Keyboard.Key.G, Theme.Colors.Menu)
  243.             Keyboard.SetKey(Razer.Keyboard.Key.O, Theme.Colors.Menu)
  244.             do return end
  245.        
  246.         end
  247.        
  248.     end
  249.    
  250.     if _activity == "menu" then
  251.         _team = "NA"
  252.         _burning = false
  253.         _flashed = false
  254.         _planted = false
  255.         _phase = "NA"
  256.         do return end
  257.     end
  258.    
  259.     if player["state"]["flashed"] > 0 then
  260.         _flashed = true
  261.         --DebugLua(player["state"]["flashed"])
  262.         coroutine.resume(CSGO_Example.Flashed)
  263.         do return end
  264.     else
  265.         _flashed = false
  266.     end
  267.    
  268.     if player["state"]["burning"] > 0 then
  269.         _burning = true
  270.         --DebugLua(player["state"]["burning"])
  271.         coroutine.resume(CSGO_Example.Burning)
  272.         do return end
  273.     else
  274.         _burning = false
  275.     end
  276.  
  277.     if player["state"] ~= nil then
  278.         if player["state"]["helmet"] ~= _helmet then
  279.             _helmet = player["state"]["helmet"]
  280.             if _helmet == false then
  281.                 CSGO_Example.SetAll(Colore.Core.Color.Red)
  282.                 _team = "NA"
  283.             do return end
  284.         end
  285.     end
  286.        
  287.         if _team ~= player["team"] then
  288.             _team = player["team"]
  289.             CSGO_Example.SetTeam(_team)
  290.         end
  291.        
  292.         if (_activity ~="menu" and _helmet) then
  293.             local health = math.ceil((4 / 100) * ConvertInt(player["state"]["health"]))
  294.             for i=1, 4 do
  295.                 if health >= i then
  296.                     Keyboard[0,6+i]= Theme.Colors.Health.Full
  297.                 else
  298.                     Keyboard[0,6+i]= Theme.Colors.None
  299.                 end
  300.             end
  301.            
  302.             local armor = math.ceil((4 / 100) * ConvertInt(player["state"]["armor"]))
  303.             for i=1, 4 do
  304.                 if armor >= i then
  305.                     Keyboard[0,10+i]= Theme.Colors.Armor.Full
  306.                 else
  307.                     Keyboard[0,10+i]= Theme.Colors.None
  308.                 end
  309.             end
  310.            
  311.             -- WEAPONS
  312.            
  313.             local Set = {
  314.                 One = Theme.Colors.None,
  315.                 Two = Theme.Colors.None,
  316.                 Three = Theme.Colors.None,
  317.                 Four = Theme.Colors.None,
  318.                 Five = Theme.Colors.None
  319.             }
  320.            
  321.             for i=0,10 do --pseudocode
  322.                 local color = Theme.Colors.None
  323.                 --Keyboard[1,1+i]= Theme.Colors.None
  324.                 local weapon = player["weapons"]["weapon_" .. i]
  325.                 if weapon ~= nil then
  326.                     local type= weapon["type"]
  327.                    
  328.                     if type == "Pistol" then
  329.                         color = Theme.Colors.Weapon.Inactive
  330.                         if weapon["state"]== "active" then
  331.                             color = Theme.Colors.Weapon.Active
  332.                         end
  333.                         Set.Two = color
  334.                     elseif type == "Knife" then
  335.                         color = Theme.Colors.Weapon.Inactive
  336.                         if weapon["state"] == "active" then
  337.                             color = Theme.Colors.Weapon.Active
  338.                         end
  339.                         Set.Three = color
  340.  
  341.                     elseif type == "Grenade" then
  342.                         color = Theme.Colors.Weapon.Inactive
  343.                         if weapon["state"] == "active" then
  344.                             color = Theme.Colors.Weapon.Active
  345.                         end
  346.                         Set.Four = color
  347.                     elseif type == "C4" then
  348.                         color = Theme.Colors.Weapon.Inactive
  349.                         if weapon["state"] == "active" then
  350.                             color = Theme.Colors.Weapon.Active
  351.                         end
  352.                         Set.Five = color
  353.                     else
  354.                         color = Theme.Colors.Weapon.Inactive
  355.                         if weapon["state"] == "active" then
  356.                             color = Theme.Colors.Weapon.Active
  357.                         end
  358.                         Set.One = color
  359.                     end
  360.                    
  361.                    
  362.                     -- Current Ammo
  363.                     local ammo = weapon["ammo_clip"]
  364.                     if (weapon["state"] == "active" and ammo ~= nil) then
  365.                         local keyboardTotal = math.ceil((4 / ConvertInt(weapon["ammo_clip_max"])) * ConvertInt(ammo))
  366.                         local mouseTotal = math.ceil((7 / ConvertInt(weapon["ammo_clip_max"])) * ConvertInt(ammo))
  367.                         local mouseCustom = NewCustom("mouse")
  368.                         c = Theme.Colors.Ammo.Full
  369.                            
  370.                         if (mouseTotal < 3) then
  371.                             c = Theme.Colors.Ammo.Low
  372.                            
  373.                         end
  374.                            
  375.                         for i=1, 7 do
  376.                                
  377.                             if(i >= mouseTotal) then
  378.                                 c = Theme.Colors.None
  379.                             end
  380.                            
  381.                             Mouse[i,0] = c
  382.                             Mouse[i,6] = c
  383.                            
  384.                         end
  385.                        
  386.                         c = Theme.Colors.Ammo.Full
  387.                            
  388.                         if (keyboardTotal < 2) then
  389.                             c = Theme.Colors.Ammo.Low
  390.                             Keyboard.SetKey(Razer.Keyboard.Key.R, Theme.Colors.Menu)
  391.                         else
  392.                             c = Theme.Colors.Ammo.Full
  393.                             Keyboard.SetKey(Razer.Keyboard.Key.R, Theme.Colors.None)
  394.                         end
  395.                        
  396.                         for i=0, 3 do
  397.                                
  398.                             if(i >= keyboardTotal) then
  399.                                 c = Theme.Colors.None
  400.                             end
  401.                             Keyboard[0, 3 + i] = c
  402.                         end
  403.                        
  404.                        
  405.                     end
  406.                 end
  407.             end
  408.             Keyboard.SetKey(Razer.Keyboard.Key.D1, Set.One)
  409.             Keyboard.SetKey(Razer.Keyboard.Key.D2, Set.Two)
  410.             Keyboard.SetKey(Razer.Keyboard.Key.D3, Set.Three)
  411.             Keyboard.SetKey(Razer.Keyboard.Key.D4, Set.Four)
  412.             Keyboard.SetKey(Razer.Keyboard.Key.D5, Set.Five)
  413.         end
  414.     end
  415. end
  416.  
  417. function CSGO_Example.SetTeam(team)
  418.         --DebugLua("team: " .. _team)
  419.        
  420.     if _activity ~= "menu" then
  421.         if team == "CT" then
  422.             CSGO_Example.SetAll(Theme.Colors.Counter)
  423.         else
  424.             CSGO_Example.SetAll(Theme.Colors.Terrorists)
  425.         end
  426.         -- WASD
  427.         Keyboard.SetKey(Razer.Keyboard.Key.W, Theme.Colors.Menu)
  428.         Keyboard.SetKey(Razer.Keyboard.Key.A, Theme.Colors.Menu)
  429.         Keyboard.SetKey(Razer.Keyboard.Key.S, Theme.Colors.Menu)
  430.         Keyboard.SetKey(Razer.Keyboard.Key.D, Theme.Colors.Menu)
  431.    
  432.     else
  433.         _team = "NA"
  434.     end
  435. end
  436.  
  437. -- our main function to handle the data
  438. function CSGO_Example.handleData(json) 
  439.     -- Get the current phase (if any)
  440.     player = json["player"]
  441.     CSGO_Example.PlayerHandler(player)
  442.     round = json["round"]
  443.     if round ~= nil then
  444.         CSGO_Example.RoundHandler(round)
  445.     end
  446.     --phase = json["round"]["phase"]
  447.     --CSGO_Example.PhaseHandler(phase)
  448.  
  449. end
  450.  
  451. -- Finally, we must register this script in order to receive data
  452. RegisterForEvents("Counter-Strike: Global Offensive", CSGO_Example.handle
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement