Advertisement
sethxi

Untitled

Apr 15th, 2015
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.74 KB | None | 0 0
  1. -- clientside code
  2.  
  3. if CLIENT then
  4.  
  5.   local phase, phase_time
  6.  
  7.   net.Receive("PrisonRP_Phase", function( len, ply )
  8.     phase = net.ReadString()
  9.     end)
  10.  
  11.   net.Receive("PrisonRP_Phase_Time", function( len, ply )
  12.     phase_time = net.ReadString()
  13.     end)
  14.  
  15.   local function paintHUD()
  16.  
  17.     local ply = LocalPlayer()
  18.     local wep = LocalPlayer():GetActiveWeapon():Clip1()
  19.     local HP  = LocalPlayer():Health()
  20.     local ARM = LocalPlayer():Armor()
  21.  
  22.     local w, h = ScrW(), ScrH()
  23.  
  24.     draw.RoundedBox( 4, w/2 - 105, 45, 210, 62, Color(0, 0, 0, 150) )
  25.  
  26.     surface.SetTextColor(255, 255, 255, 255)
  27.     surface.SetTextPos(w / 2 - 95, 50)
  28.     surface.SetFont("CloseCaption_Bold")
  29.  
  30.     surface.DrawText("Phase: ") // Display what phase the Prison Roleplay is in.
  31.  
  32.     surface.SetTextColor(88, 219, 65)
  33.  
  34.     surface.DrawText(phase or "LOADING")
  35.  
  36.     surface.SetTextPos(w / 2 - 85, 75)
  37.     surface.SetTextColor(255, 255, 255, 255)
  38.  
  39.     surface.DrawText("Time Left: ") // Display how much time is left in the current phase.
  40.  
  41.     surface.SetTextColor(88, 219, 65)
  42.  
  43.     surface.DrawText(phase_time or "0")
  44.  
  45.     surface.SetTextColor(255, 255, 255)
  46.  
  47.     surface.DrawText("s")
  48.   end
  49.  
  50.   hook.Add("HUDPaint", "PrisonRP_Timer", paintHUD)
  51.  
  52. end
  53.  
  54. -- serverside code
  55.  
  56. if SERVER then
  57.  
  58.   --declare prison times & current time
  59.  
  60.   local prisonTimes = {
  61.     "Work Time",
  62.     "Free Time",
  63.     "Roll Call",
  64.     "Cell Time"
  65.   }
  66.  
  67.   local currentTime, seconds = 1, 300
  68.  
  69.   -- make easy functions to use
  70.  
  71.   function getCurrentPhase()
  72.     return prisonTimes[currentTime]
  73.   end
  74.  
  75.   function nextTime()
  76.     if(currentTime == #prisonTimes) then
  77.       currentTime = 1
  78.       return
  79.     end
  80.     currentTime = currentTime + 1
  81.   end
  82.  
  83.   function broadcastPhase(ply)
  84.     net.Start("PrisonRP_Phase")
  85.       net.WriteString(getCurrentPhase())
  86.     if ply then
  87.       net.Send(ply)
  88.     else
  89.       net.Broadcast()
  90.     end
  91.   end
  92.  
  93.   function broadcastSeconds()
  94.     net.Start("PrisonRP_Phase_Time")
  95.       net.WriteString(seconds)
  96.     net.Broadcast()
  97.   end
  98.  
  99.   -- add network strings
  100.  
  101.   util.AddNetworkString("PrisonRP_Phase_Time")
  102.   util.AddNetworkString("PrisonRP_Phase")
  103.  
  104.   -- make phase timer
  105.  
  106.   timer.Create("PrisonRP_Phases", 300, 0, function()
  107.     nextTime()
  108.     seconds = 300
  109.   end)
  110.  
  111.   -- make broadcast timer
  112.   timer.Create("PrisonRP_Phases_Broadcast", 1, 0, function()
  113.     seconds = seconds - 1
  114.     broadcastPhase(ply)
  115.     broadcastSeconds()
  116.   end)
  117.  
  118.   broadcastPhase()
  119.   broadcastSeconds()
  120.  
  121.   MsgC(Color(255, 50, 50), "PrisonRP Timer ", Color(255, 255, 255), "- ", Color(50, 255, 50), "Custom Made by ", Color(0, 133, 255), "Liquid Obsidian ", Color(50, 255, 50), "with ", Color(255, 50, 50), "emotions.get(\"LOVE\") \n")
  122.  
  123. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement