Last active
August 29, 2015 14:04
-
-
Save MattJeanes/1215bec121c29fc9362d to your computer and use it in GitHub Desktop.
Purge script for Garry's Mod, based on film 'The Purge'.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
in what folder do i have to place this timer...