SHARE
TWEET

radioalert.lua

Mrhacker95 May 19th, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. radioalert_table_T = {}
  4. radioalert_table_S = {}
  5. if CLIENT then
  6.     hook.Add( "HUDPaint", "Hud_KOS_Alert", function()
  7.         HowManyKOS = table.Count(radioalert_table_T)
  8.         HowManySUS = table.Count(radioalert_table_S)
  9.         /*------
  10.         --------SUSPECT
  11.         */------
  12.         x = 0
  13.         y = 250
  14.         if HowManySUS != 0 then
  15.             SY = 250
  16.             SYText = SY+20
  17.             SYBox = 0
  18.             draw.RoundedBoxEx( 8, x, SY, 150, 20, Color(150,150,0,100), false, true, false, false )
  19.             draw.DrawText("Suspect ", "HudHintTextLarge", x+5, SY+3, Color(255, 255, 0, 255),TEXT_ALIGN_LEFT)
  20.             for i = 1 , HowManySUS do
  21.                 draw.DrawText(radioalert_table_S[i], "Default", x+5, SYText-1, Color(255,255,255, 255),TEXT_ALIGN_LEFT)
  22.                 SYText = SYText+10
  23.                 SYBox = SYBox+10
  24.             end
  25.             draw.RoundedBoxEx( 0, x, SY+20, 150, SYBox, Color(100,100,0,100), false, false, false, false )
  26.             draw.RoundedBoxEx( 4, x, SY+20+SYBox, 150, 8, Color(150,150,0,100), false, false, false, true )
  27.         end
  28.         /*------
  29.         --------Traitor
  30.         */------   
  31.         if HowManyKOS != 0 then
  32.             if HowManySUS == 0 then
  33.                 TY = y
  34.                 TYText = TY+20
  35.                 TYBox = 0
  36.             else
  37.                 TY = SY+SYBox+35
  38.                 TYText = TY+20
  39.                 TYBox = 0
  40.             end
  41.             draw.RoundedBoxEx( 8, x, TY, 150, 20, Color(150,0,0,100), false, true, false, false )
  42.             draw.DrawText("Traitor - KOS", "HudHintTextLarge", x+5, TY+3, Color(255, 0, 0, 255),TEXT_ALIGN_LEFT)
  43.             -- draw.DrawText(table.Count(radioalert_table_T), "Default", x+100, TY+20, Color(255, 255, 255, 255),TEXT_ALIGN_LEFT)
  44.             for i = 1 , HowManyKOS do
  45.                 draw.DrawText(radioalert_table_T[i], "Default", x+5, TYText-1, Color(255,255,255, 255),TEXT_ALIGN_LEFT)
  46.                 TYText = TYText+10
  47.                 TYBox = TYBox+10
  48.             end
  49.             draw.RoundedBoxEx( 0, x, TY+20, 150, TYBox, Color(100,0,0,100), false, false, false, false )
  50.             draw.RoundedBoxEx( 4, x, TY+20+TYBox, 150, 8, Color(150,0,0,100), false, false, false, true )
  51.         end
  52.         /*------
  53.         --------Player Warnings
  54.         */------   
  55.         if table.HasValue(radioalert_table_T, LocalPlayer():Nick()) then
  56.             draw.DrawText("Someone has called you out as a Traitor.", "DermaLarge", 270, ScrH()-35, Color(150, 0, 0, 255),TEXT_ALIGN_LEFT)
  57.         elseif table.HasValue(radioalert_table_S, LocalPlayer():Nick()) then
  58.             draw.DrawText("Someone is suspecting you.", "DermaLarge", 270, ScrH()-35, Color(150, 150, 0, 255),TEXT_ALIGN_LEFT)
  59.         end
  60.     end)
  61.     /*------
  62.     --------Server Net Grabber
  63.     */------
  64.     net.Receive( "Radio_Player_KOS", function( len ) -- Radio Tratior
  65.         Target = net.ReadString()
  66.         Target1 = player.GetByID(Target):Nick()
  67.         if !table.HasValue( radioalert_table_T, Target1 ) and player.GetByID(Target):GetRole() != 2 then
  68.             table.insert(radioalert_table_T,Target1)
  69.             if table.HasValue( radioalert_table_S, Target1 ) then
  70.                 table.remove(radioalert_table_S,table.KeyFromValue(radioalert_table_S, Target1))
  71.             end
  72.         end
  73.     end )
  74.     net.Receive( "Radio_Player_SUS", function( len ) -- Radio Suspect
  75.         Target = net.ReadString()
  76.         Target1 = player.GetByID(Target):Nick()
  77.         print(Target)
  78.         if !table.HasValue( radioalert_table_S, Target1 ) and player.GetByID(Target):GetRole() != 2 then
  79.             table.insert(radioalert_table_S,Target1)
  80.             if table.HasValue( radioalert_table_T, Target1 ) then
  81.                 table.remove(radioalert_table_T,table.KeyFromValue(radioalert_table_T, Target1))
  82.             end
  83.         end
  84.     end )
  85.     net.Receive( "Radio_Player_REM", function( len ) -- Radio Innocent
  86.         Target = net.ReadString()
  87.         Target1 = player.GetByID(Target):Nick()
  88.         if table.HasValue( radioalert_table_S, Target1 ) then
  89.                 table.remove(radioalert_table_S,table.KeyFromValue(radioalert_table_S, Target1))
  90.             end
  91.         if table.HasValue( radioalert_table_T, Target1 ) then
  92.             table.remove(radioalert_table_T,table.KeyFromValue(radioalert_table_T, Target1))
  93.         end
  94.     end )
  95.     net.Receive( "Radio_Player_REM_B", function( len ) -- Dead Bodies
  96.         Target = net.ReadString()
  97.         if table.HasValue( radioalert_table_S, Target1 ) then
  98.             table.remove(radioalert_table_S,table.KeyFromValue(radioalert_table_S, Target1))
  99.         end
  100.         if table.HasValue( radioalert_table_T, Target ) then
  101.             table.remove(radioalert_table_T,table.KeyFromValue(radioalert_table_S, Target))
  102.         end
  103.     end )
  104. end
  105. if SERVER then
  106.     /*------
  107.     --------Server Net Cteater
  108.     */------   
  109.     util.AddNetworkString( "Radio_Player_KOS" )
  110.     util.AddNetworkString( "Radio_Player_SUS" )
  111.     util.AddNetworkString( "Radio_Player_REM" )
  112.     util.AddNetworkString( "Radio_Player_REM_B" )
  113.     /*------
  114.     --------Radio Hooks and Server Net Senders
  115.     */------
  116.     hook.Add("TTTPlayerRadioCommand", "Radio_KOS_Alert", function(ply, cmd_name, cmd_target)
  117.             if (cmd_name == "quick_traitor" and cmd_target != "quick_nobody" and cmd_target != "quick_corpse") then
  118.                 Radio_Target = cmd_target:EntIndex()
  119.                     net.Start("Radio_Player_KOS")
  120.                     net.WriteString(Radio_Target)
  121.                     net.Send(player.GetAll())
  122.             end
  123.             if (cmd_name == "quick_suspect" and cmd_target != "quick_nobody" and cmd_target != "quick_corpse") then
  124.                 Radio_Target = cmd_target:EntIndex()
  125.                     net.Start("Radio_Player_SUS")
  126.                     net.WriteString(Radio_Target)
  127.                     net.Send(player.GetAll())
  128.             end
  129.             if (cmd_name == "quick_inno" and cmd_target != "quick_nobody" and cmd_target != "quick_corpse") then
  130.                 Radio_Target = cmd_target:EntIndex()
  131.                     net.Start("Radio_Player_REM")
  132.                     net.WriteString(Radio_Target)
  133.                     net.Send(player.GetAll())
  134.             end
  135.     end )
  136. end
  137.     /*------
  138.     --------Hooks to clear table at brguning of each stage and body clear hook
  139.     */------
  140. hook.Add("TTTPrepareRound", "ClearRadioTable1", function()
  141.     table.Empty(radioalert_table_T)
  142.     table.Empty(radioalert_table_S)
  143. end)
  144. hook.Add("TTTBeginRound", "ClearRadioTable2", function()
  145.     table.Empty(radioalert_table_T)
  146.     table.Empty(radioalert_table_S)
  147. end)
  148. hook.Add("TTTEndRound", "ClearRadioTable3", function()
  149.     table.Empty(radioalert_table_T)
  150.     table.Empty(radioalert_table_S)
  151. end)
  152. hook.Add("TTTBodyFound", "RemoveRadioTable", function(ply, deadply, rag)
  153.     Radio_Target = tostring(CORPSE.GetPlayerNick(rag))
  154.         net.Start("Radio_Player_REM_B")
  155.         net.WriteString(Radio_Target)
  156.         net.Send(player.GetAll())
  157. end)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top