Skip to content

Commit

Permalink
Merged FPP
Browse files Browse the repository at this point in the history
  • Loading branch information
FPtje committed Jul 27, 2023
1 parent 3d786d4 commit e85007c
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 20 deletions.
15 changes: 8 additions & 7 deletions gamemode/modules/fpp/pp/client/hud.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,14 @@ local HUDNote_c = 0
local HUDNote_i = 1
local HUDNotes = {}

--Notify ripped off the Sandbox notify, changed to my likings
function FPP.AddNotify( str, type )
-- Notify ripped off the Sandbox notify, changed to my likings
function FPP.AddNotify(str, type, total_time)
local tab = {}
tab.text = str
tab.recv = SysTime()
tab.velx = 0
tab.vely = -5
tab.time_visible = total_time ~= 0 and total_time or 6
surface_SetFont( "TabLarge" )
local w = surface_GetTextSize( str )

Expand All @@ -72,7 +73,7 @@ function FPP.AddNotify( str, type )
ply:EmitSound("npc/turret_floor/click1.wav", 10, 100)
end

usermessage.Hook("FPP_Notify", function(u) FPP.AddNotify(u:ReadString(), u:ReadBool()) end)
usermessage.Hook("FPP_Notify", function(u) FPP.AddNotify(u:ReadString(), u:ReadBool(), u:ReadFloat()) end)

local function DrawNotice(k, v, i)

Expand Down Expand Up @@ -104,15 +105,15 @@ local function DrawNotice(k, v, i)

local ideal_y = ScrH() - (HUDNote_c - i) * h
local ideal_x = ScrW() / 2 + w * 0.5 + (ScrW() / 20)
local timeleft = 6 - (SysTime() - v.recv)
local timeleft = v.time_visible - (SysTime() - v.recv)

-- Cartoon style about to go thing
if (timeleft < 0.8) then
if (timeleft < 0.5) then
ideal_x = ScrW() / 2 + w * 0.5 + 200
end

-- Gone!
if (timeleft < 0.5) then
if (timeleft < 0.2) then
ideal_y = ScrH() + 50
end

Expand Down Expand Up @@ -176,7 +177,7 @@ local function HUDPaint()
end

for k, v in pairs(HUDNotes) do
if v ~= 0 and v.recv + 6 < SysTime() then
if v ~= 0 and v.recv + v.time_visible < SysTime() then
HUDNotes[ k ] = 0
HUDNote_c = HUDNote_c - 1
if (HUDNote_c == 0) then HUDNotes = {} end
Expand Down
40 changes: 29 additions & 11 deletions gamemode/modules/fpp/pp/server/antispam.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,27 +55,45 @@ function FPP.AntiSpam.CreateEntity(ply, ent, IsDuplicate)
-- I power by ten because the volume of a prop can vary between 65 and like a few billion
if tobool(FPP.Settings.FPP_ANTISPAM1.bigpropantispam) and phys:GetVolume() and phys:GetVolume() > math.pow(10, FPP.Settings.FPP_ANTISPAM1.bigpropsize) and not string.find(class, "constraint") and not string.find(class, "hinge")
and not string.find(class, "magnet") and not string.find(class, "collision") and not blacklist[class] then
ply.FPPAntispamBigProp = ply.FPPAntispamBigProp or 0
ply.FPPAntiSpamLastBigProp = ply.FPPAntiSpamLastBigProp or 0
if not IsDuplicate then
ply.FPPAntispamBigProp = (ply.FPPAntispamBigProp or 0) + 1
timer.Simple(10 * FPP.Settings.FPP_ANTISPAM1.bigpropwait, function()
if not ply:IsValid() then return end
ply.FPPAntispamBigProp = ply.FPPAntispamBigProp or 0
ply.FPPAntispamBigProp = math.Max(ply.FPPAntispamBigProp - 1, 0)
end)
ply.FPPAntispamBigProp = ply.FPPAntispamBigProp + 1
end

if ply.FPPAntiSpamLastBigProp and ply.FPPAntiSpamLastBigProp > (CurTime() - (FPP.Settings.FPP_ANTISPAM1.bigpropwait * ply.FPPAntispamBigProp)) then
FPP.Notify(ply, "Please wait " .. FPP.Settings.FPP_ANTISPAM1.bigpropwait * ply.FPPAntispamBigProp .. " Seconds before spawning a big prop again", false)
ply.FPPAntiSpamLastBigProp = CurTime()
local curTime = CurTime()
local spawningBlockedUntil =
ply.FPPAntiSpamLastBigProp + ply.FPPAntispamBigProp * FPP.Settings.FPP_ANTISPAM1.bigpropwait

if curTime < spawningBlockedUntil then
-- The current attempt would have been blocked until
-- spawningBlockedUntil. The next attempt will add up to that time.
-- The wait time is thus the time the user should wait before the
-- next attempt.
local waitTime = spawningBlockedUntil + FPP.Settings.FPP_ANTISPAM1.bigpropwait - curTime
FPP.Notify(
ply,
"Please wait " .. math.Round(waitTime, 2) .. " Seconds before spawning a big prop again",
false,
waitTime
)
ent:Remove()
return
end

if not IsDuplicate then
ply.FPPAntiSpamLastBigProp = CurTime()
ply.FPPAntiSpamLastBigProp = curTime
-- Spawning succeeded, reset big prop count to 0
ply.FPPAntispamBigProp = 0
end
local waitTime = FPP.Settings.FPP_ANTISPAM1.bigpropwait
FPP.AntiSpam.GhostFreeze(ent, phys)
FPP.Notify(ply, "Your prop is ghosted because it is too big. Interract with it to unghost it.", true)
FPP.Notify(
ply,
"Your prop is ghosted because it is too big. Interract with it to unghost it.",
true,
waitTime
)
return
end

Expand Down
6 changes: 4 additions & 2 deletions gamemode/modules/fpp/pp/server/settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,24 @@ FPP.RestrictedToolsPlayers = FPP.RestrictedToolsPlayers or {}
FPP.Groups = FPP.Groups or {}
FPP.GroupMembers = FPP.GroupMembers or {}

function FPP.Notify(ply, text, bool)
function FPP.Notify(ply, text, bool, total_time)
if ply:EntIndex() == 0 then
ServerLog(text)
return
end
umsg.Start("FPP_Notify", ply)
umsg.String(text)
umsg.Bool(bool)
umsg.Float(total_time or 6)
umsg.End()
ply:PrintMessage(HUD_PRINTCONSOLE, text)
end

function FPP.NotifyAll(text, bool)
function FPP.NotifyAll(text, bool, total_time)
umsg.Start("FPP_Notify")
umsg.String(text)
umsg.Bool(bool)
umsg.Float(total_time or 6)
umsg.End()
for _, ply in ipairs(player.GetAll()) do
ply:PrintMessage(HUD_PRINTCONSOLE, text)
Expand Down

0 comments on commit e85007c

Please sign in to comment.