Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- clientside code
- if CLIENT then
- local phase, phase_time
- net.Receive("PrisonRP_Phase", function( len, ply )
- phase = net.ReadString()
- end)
- net.Receive("PrisonRP_Phase_Time", function( len, ply )
- phase_time = net.ReadString()
- end)
- local function paintHUD()
- local ply = LocalPlayer()
- local wep = LocalPlayer():GetActiveWeapon():Clip1()
- local HP = LocalPlayer():Health()
- local ARM = LocalPlayer():Armor()
- local w, h = ScrW(), ScrH()
- draw.RoundedBox( 4, w/2 - 105, 45, 210, 62, Color(0, 0, 0, 150) )
- surface.SetTextColor(255, 255, 255, 255)
- surface.SetTextPos(w / 2 - 95, 50)
- surface.SetFont("CloseCaption_Bold")
- surface.DrawText("Phase: ") // Display what phase the Prison Roleplay is in.
- surface.SetTextColor(88, 219, 65)
- surface.DrawText(phase or "LOADING")
- surface.SetTextPos(w / 2 - 85, 75)
- surface.SetTextColor(255, 255, 255, 255)
- surface.DrawText("Time Left: ") // Display how much time is left in the current phase.
- surface.SetTextColor(88, 219, 65)
- surface.DrawText(phase_time or "0")
- surface.SetTextColor(255, 255, 255)
- surface.DrawText("s")
- end
- hook.Add("HUDPaint", "PrisonRP_Timer", paintHUD)
- end
- -- serverside code
- if SERVER then
- --declare prison times & current time
- local prisonTimes = {
- "Work Time",
- "Free Time",
- "Roll Call",
- "Cell Time"
- }
- local currentTime, seconds = 1, 300
- -- make easy functions to use
- function getCurrentPhase()
- return prisonTimes[currentTime]
- end
- function nextTime()
- if(currentTime == #prisonTimes) then
- currentTime = 1
- return
- end
- currentTime = currentTime + 1
- end
- function broadcastPhase(ply)
- net.Start("PrisonRP_Phase")
- net.WriteString(getCurrentPhase())
- if ply then
- net.Send(ply)
- else
- net.Broadcast()
- end
- end
- function broadcastSeconds()
- net.Start("PrisonRP_Phase_Time")
- net.WriteString(seconds)
- net.Broadcast()
- end
- -- add network strings
- util.AddNetworkString("PrisonRP_Phase_Time")
- util.AddNetworkString("PrisonRP_Phase")
- -- make phase timer
- timer.Create("PrisonRP_Phases", 300, 0, function()
- nextTime()
- seconds = 300
- end)
- -- make broadcast timer
- timer.Create("PrisonRP_Phases_Broadcast", 1, 0, function()
- seconds = seconds - 1
- broadcastPhase(ply)
- broadcastSeconds()
- end)
- broadcastPhase()
- broadcastSeconds()
- 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")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement