Skip to content

Instantly share code, notes, and snippets.

@MattJeanes
Last active August 29, 2015 14:04
Show Gist options
  • Save MattJeanes/1215bec121c29fc9362d to your computer and use it in GitHub Desktop.
Save MattJeanes/1215bec121c29fc9362d to your computer and use it in GitHub Desktop.
Purge script for Garry's Mod, based on film 'The Purge'.
-- Purge. Written by Dr. Matt, initial version/idea by Paft.
AddCSLuaFile()
if SERVER then
util.AddNetworkString("purge")
local purge=false
local cooldown=false
local cooldowntime=15
function togglepurge()
if cooldown then
return false
end
purge = not purge
net.Start("purge")
net.WriteBit(purge)
net.WriteBit(false)
net.Broadcast()
cooldown=true
timer.Simple(cooldowntime,function()
net.Start("purge")
net.WriteBit(purge)
net.WriteBit(true)
net.Broadcast()
cooldown=false
end)
return true
end
hook.Add("PlayerSay", "purge", function(ply,text)
if ply:IsAdmin() or ply:IsSuperAdmin() then
local t=string.Explode(" ", text)
if t and t[1] then
local cmd=t[1]:lower()
if cmd=="!purge" then
togglepurge()
return ""
end
end
end
end)
concommand.Add("purge", function(ply,cmd,args)
if not IsValid(ply) or (ply and ply:IsAdmin() or ply:IsSuperAdmin()) then
togglepurge()
end
end)
hook.Add("PlayerInitialSpawn", "purge", function(ply)
if purge then
net.Start("purge")
net.WriteBit(purge)
net.WriteBit(true)
net.Broadcast()
end
end)
elseif CLIENT then
surface.CreateFont( "purgebig", {
font = "CloseCaption_Bold",
size = 52,
weight = 700,
antialias = true,
})
local snd
net.Receive("purge",function(len)
local on=tobool(net.ReadBit())
local tempbig=tobool(net.ReadBit())
if tempbig then
hook.Remove("HUDPaint", "purgebig")
if on then
hook.Add("HUDPaint", "purge", function()
draw.SimpleText("Purge is active", "CloseCaption_Bold", ScrW()*0.9, ScrH()/14, Color(255,56,56,150), TEXT_ALIGN_CENTER)
end)
end
return
end
if snd then
snd:Stop()
end
if on then
hook.Add("HUDPaint", "purgebig", function()
draw.SimpleText("Purge is starting | Prepare yourself", "purgebig", ScrW()/2, ScrH()/14, Color(255,56,56,150), TEXT_ALIGN_CENTER)
end)
snd=CreateSound(LocalPlayer(), "paft/end.wav")
else
hook.Remove("HUDPaint", "purge")
hook.Add("HUDPaint", "purgebig", function()
draw.SimpleText("Purge has ended | Normality will pursue", "purgebig", ScrW()/2, ScrH()/14, Color(255,56,56,150), TEXT_ALIGN_CENTER)
end)
snd=CreateSound(LocalPlayer(), "paft/end.wav")
end
snd:Play()
end)
end
@edmoendo
Copy link

in what folder do i have to place this timer...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment