Garry's Mod
I'm making a School RP server and I need a Class/Lesson timer
Submitted by Feykon, 07-02-2018, 10:38 PM, Thread ID: 74012
Thread Closed
RE: I'm making a School RP server and I need a Class/Lesson timer
13-02-2018, 06:05 PM
#7 07-02-2018, 10:38 PMFeykon Wrote: Im currently making the sv and the I tried with the one on the workshop but it sucks, it just show you the lesson but it has no timer (like 150 seconds left) and I see all this sv and wonder if you guys know about one that works
Code:
if CLIENT then
local blur = Material 'pp/blurscreen'
local function drawBlur( pan, amt )
local x, y = pan:LocalToScreen( 0, 0 )
surface.SetDrawColor( 255, 255, 255 )
surface.SetMaterial( blur )
for i = 1, 3 do
blur:SetFloat( '$blur', ( i / 3 ) * ( amt or 6 ) )
blur:Recompute()
render.UpdateScreenEffectTexture()
surface.DrawTexturedRect( x * -1, y * -1, ScrW(), ScrH() )
end
end
surface.CreateFont( "TaMereLaChauve", { font = "Caviar Dreams", extended = false, size = 18, weight = 500, blursize = 0, scanlines = 0, antialias = true, underline = false, italic = false, strikeout = false, symbol = false, rotary = false, shadow = false, additive = false, outline = false, } )
local activity = {name = "", time = 0, left = 0}
local loaded = false
net.Receive("Activity_Update", function()
activity = util.JSONToTable(net.ReadString())
loaded = true
end)
net.Receive("Jail_Alarm", function()
LocalPlayer():EmitSound("ambient/alarms/alarm1.wav")
timer.Simple( 5, function() LocalPlayer():ConCommand("stopsound") end )
end)
local function paintHUD()
local w, h = 350, 70
local x, y = 5, 5
local bg = vgui.Create( 'DFrame' )
bg:SetSize( w, h )
bg:SetPos( x, y )
bg:ShowCloseButton( false )
bg:SetTitle( '' )
function bg:Paint( w, h )
drawBlur( self, 5 )
draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 100 ) )
draw.SimpleText( activity.name, 'TaMereLaChauve', w / 2-1, h / 2, color_white, 1, 1 )
surface.SetDrawColor( Color( 0, 0, 0, 100 ) )
surface.DrawLine( 0, 0, w - 1, 0 )
surface.DrawLine( w - 1, 0, w - 1, h - 1 )
surface.DrawLine( 0, h - 1, w - 1, h - 1 )
surface.DrawLine( 0, 0, 0, h )
end
local Gryff = vgui.Create( "DImage", bg )
Gryff:SetPos( x+10 ,23 )
Gryff:SetSize( 26,26 )
Gryff:SetImage( "hp/gryff.png" )
local Serdaigle = vgui.Create( "DImage", bg )
Serdaigle:SetPos( x+40 , 23 )
Serdaigle:SetSize( 25,25 )
Serdaigle:SetImage( "hp/rave.png" )
local Serpentard = vgui.Create( "DImage", bg )
Serpentard:SetPos( x+280 , 23 )
Serpentard:SetSize( 25,25 )
Serpentard:SetImage( "hp/slyt.png" )
local Poufsouffle = vgui.Create( "DImage", bg )
Poufsouffle:SetPos( x+310 , 23 )
Poufsouffle:SetSize( 25,25 )
Poufsouffle:SetImage( "hp/huff.png" )
end
hook.Add("InitPostEntity", "PoudlardRP", paintHUD)
end
if SERVER then
local activities = {
{name = "Lesson #1", time = 20},
{name = "Lesson #1", time = 20},
{name = "Lesson #1", time = 20},
{name = "Break", time = 5},
{name = "Lesson #1", time = 20},
{name = "Lesson #1", time = 20},
{name = "Lesson #1", time = 20},
{name = "Break", time = 5},
{name = "Lesson #1", time = 20},
{name = "Lesson #1", time = 20},
{name = "Lesson #1", time = 20},
{name = "Break", time = 5},
}
local current = 1
local time = 0
util.AddNetworkString("Activity_Update")
util.AddNetworkString("Jail_Alarm")
timer.Create("Activity_Updater", 1, 0, function()
time = time + 1
activities[current].left = activities[current].time * 60 - time
if (time > activities[current].time * 60) then
time = 0
if current > 6 then
current = 1
else
current = current + 1
end
if current == 7 then current = 1 print("set current to " .. current) end
activities[current].left = activities[current].time * 60 - time
net.Start("Jail_Alarm")
net.WriteString(util.TableToJSON(activities[current]))
net.Broadcast()
net.Start("Activity_Update")
net.WriteString(util.TableToJSON(activities[current]))
net.Broadcast()
else
net.Start("Activity_Update")
net.WriteString(util.TableToJSON(activities[current]))
net.Broadcast()
end
end)
end
Users browsing this thread: 2 Guest(s)