mirror of
https://github.com/lifestorm/wnsrc.git
synced 2025-12-17 05:43:46 +03:00
Upload
This commit is contained in:
95
gamemodes/helix/plugins/willardantiafk/cl_hooks.lua
Normal file
95
gamemodes/helix/plugins/willardantiafk/cl_hooks.lua
Normal file
@@ -0,0 +1,95 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
local PLUGIN = PLUGIN
|
||||
|
||||
PLUGIN.stopDraw = 0
|
||||
|
||||
local COLOR_BLACK_WHITE = {
|
||||
["$pp_colour_addr"] = 0,
|
||||
["$pp_colour_addg"] = 0,
|
||||
["$pp_colour_addb"] = 0,
|
||||
["$pp_colour_brightness"] = -0.1,
|
||||
["$pp_colour_contrast"] = 0.9,
|
||||
["$pp_colour_colour"] = 0,
|
||||
["$pp_colour_mulr"] = 0,
|
||||
["$pp_colour_mulg"] = 0,
|
||||
["$pp_colour_mulb"] = 0
|
||||
}
|
||||
|
||||
function PLUGIN:HUDPaint()
|
||||
if (IsValid(LocalPlayer()) and LocalPlayer():IsAFK() and LocalPlayer():GetAimVector() and self.stopDraw < CurTime()) then
|
||||
draw.SimpleText(
|
||||
"VOUS ÊTES AFK",
|
||||
"HUDFontExtraLargeNoClamp",
|
||||
ScrW() * 0.5,
|
||||
ScrH() - SScaleMin(230 / 3),
|
||||
Color(255, 255, 255, 255),
|
||||
TEXT_ALIGN_CENTER
|
||||
)
|
||||
draw.SimpleText(
|
||||
"La faim, la soif et les rations sont en pause",
|
||||
"WNBleedingTextNoClamp",
|
||||
ScrW() * 0.5,
|
||||
ScrH() - SScaleMin(165 / 3),
|
||||
Color(255, 255, 255, 255),
|
||||
TEXT_ALIGN_CENTER
|
||||
)
|
||||
draw.SimpleText(
|
||||
"Vous pouvez être exclu",
|
||||
"WNBleedingTextNoClamp",
|
||||
ScrW() * 0.5,
|
||||
ScrH() - SScaleMin(135 / 3),
|
||||
Color(255, 78, 69, 255),
|
||||
TEXT_ALIGN_CENTER
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
local afkColor = Color(255, 78, 69, 255)
|
||||
function PLUGIN:PopulateCharacterInfo(client, character, tooltip)
|
||||
if (client:IsAFK()) then
|
||||
local afk = tooltip:AddRowAfter("name", "afk")
|
||||
afk:SetBackgroundColor(afkColor)
|
||||
afk:SetText(L("playerIsAFK"))
|
||||
afk:SizeToContents()
|
||||
end
|
||||
end
|
||||
|
||||
function PLUGIN:GetPlayerESPText(client, toDraw, distance, alphaFar, alphaMid, alphaClose)
|
||||
if (client:IsAFK()) then
|
||||
toDraw[#toDraw + 1] = {alpha = alphaFar, priority = 2, text = "AFK - "..math.floor(client:GetNetVar("afkTime", 0) / 60).."m"}
|
||||
end
|
||||
end
|
||||
|
||||
function PLUGIN:Think()
|
||||
if (LocalPlayer():IsAFK()) then
|
||||
if ((!self.aimVector or !self.posVector) and self.stopDraw < CurTime()) then
|
||||
self.aimVector = LocalPlayer():GetAimVector()
|
||||
self.posVector = LocalPlayer():GetPos()
|
||||
elseif (self.aimVector != LocalPlayer():GetAimVector() or
|
||||
self.posVector != LocalPlayer():GetPos()) then
|
||||
self.stopDraw = CurTime() + 5
|
||||
self.aimVector = nil
|
||||
self.posVector = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function PLUGIN:RenderScreenspaceEffects()
|
||||
if (LocalPlayer():IsAFK() and self.stopDraw < CurTime()) then
|
||||
DrawColorModify(COLOR_BLACK_WHITE)
|
||||
end
|
||||
end
|
||||
|
||||
net.Receive("ixPrintAfkPlayers", function()
|
||||
local text = net.ReadString()
|
||||
chat.AddText(Color(255,255,255), text)
|
||||
end)
|
||||
@@ -0,0 +1,16 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
LANGUAGE = {
|
||||
antiafk = "Anti-AFK",
|
||||
kickedAFK = "Vous avez été expulsé pour être AFK",
|
||||
kickedAdminAFK = "%s a été exclu du serveur automatiquement '%s' (AFK).",
|
||||
charAFK = "A.F.K"
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
LANGUAGE = {
|
||||
antiafk = "Anti-AFK",
|
||||
kickedAFK = "Vous avez été expulsé pour être AFK",
|
||||
kickedAdminAFK = "%s a été exclu du serveur automatiquement '%s' (AFK).",
|
||||
charAFK = "A.F.K"
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
LANGUAGE = {
|
||||
kickedAdminAFK = "%s ha auto-expulsado '%s' (AFK).",
|
||||
antiafk = "Anti-AFK",
|
||||
kickedAFK = "%s ha sido expulsado por el servidor (AFK)",
|
||||
charAFK = "Ausente"
|
||||
}
|
||||
84
gamemodes/helix/plugins/willardantiafk/sh_plugin.lua
Normal file
84
gamemodes/helix/plugins/willardantiafk/sh_plugin.lua
Normal file
@@ -0,0 +1,84 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
local PLUGIN = PLUGIN
|
||||
|
||||
PLUGIN.name = "Anti-AFK"
|
||||
PLUGIN.author = "Gr4Ss, M!NT"
|
||||
PLUGIN.description = "Empêche les joueurs AFK de gagner des salaires et d'être kick lorsque le serveur est plein."
|
||||
PLUGIN.license = [[
|
||||
(c) 2020 by Willard Networks - WN:IX A unique HL2RP schema built by the WN team
|
||||
Copyright Atko 2020 All Rights Reserved
|
||||
]]
|
||||
ix.afk = ix.afk or {}
|
||||
|
||||
ix.config.Add("afkTime", 300, "Le nombre de secondes qu'il faut pour qu'une personne soit signalée comme AFK.", nil, {
|
||||
data = {min = 120, max = 3600},
|
||||
category = "Anti-afk"
|
||||
})
|
||||
|
||||
ix.lang.AddTable("english", {
|
||||
playerIsAFK = "Ce joueur est AFK",
|
||||
noAfk = "Personne n'est actuellement AFK.",
|
||||
currentAFK = "Joueurs AFK actuels :\n",
|
||||
afkFormat = "%s pour %.1fm\n",
|
||||
})
|
||||
|
||||
ix.lang.AddTable("french", {
|
||||
playerIsAFK = "Ce joueur est AFK",
|
||||
noAfk = "Personne n'est actuellement AFK.",
|
||||
currentAFK = "Joueurs AFK actuels :\n",
|
||||
afkFormat = "%s pour %.1fm\n",
|
||||
})
|
||||
|
||||
ix.lang.AddTable("spanish", {
|
||||
playerIsAFK = "Este jugador está AFK",
|
||||
currentAFK = "Jugadores AFK actuales:\n",
|
||||
afkFormat = "%s para %.1fm\n",
|
||||
noAfk = "Nadie está AFK ahora mismo."
|
||||
})
|
||||
|
||||
ix.command.Add("PrintAFKPlayers", {
|
||||
description = "Désigne les joueurs actuellement AFK dans votre chat.",
|
||||
adminOnly = true,
|
||||
OnRun = function(self, client)
|
||||
local text = L("noAfk", client)
|
||||
local afkPlayers = {}
|
||||
for _, target in ipairs(player.GetAll()) do
|
||||
if (target:IsAFK()) then
|
||||
afkPlayers[#afkPlayers + 1] = target
|
||||
end
|
||||
end
|
||||
|
||||
if (#afkPlayers > 0) then
|
||||
text = L("currentAFK", client)
|
||||
for _, target in pairs(afkPlayers) do
|
||||
text = text..string.format("%s pour %.1fm\n", target:GetName(), math.floor(target:GetNetVar("afkTime", 0) / 60))
|
||||
end
|
||||
end
|
||||
|
||||
net.Start("ixPrintAfkPlayers")
|
||||
net.WriteString(text)
|
||||
net.Send(client)
|
||||
end
|
||||
})
|
||||
|
||||
do
|
||||
local PLAYER = FindMetaTable("Player")
|
||||
|
||||
function PLAYER:IsAFK()
|
||||
return self:GetNetVar("afkTime", 0) >= ix.config.Get("afkTime")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
ix.util.Include("cl_hooks.lua")
|
||||
ix.util.Include("sv_plugin.lua")
|
||||
ix.util.Include("sv_hooks.lua")
|
||||
37
gamemodes/helix/plugins/willardantiafk/sv_hooks.lua
Normal file
37
gamemodes/helix/plugins/willardantiafk/sv_hooks.lua
Normal file
@@ -0,0 +1,37 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
|
||||
local PLUGIN = PLUGIN
|
||||
|
||||
function PLUGIN:PlayerLoadedCharacter(client, character)
|
||||
local uniqueID = "ixAntiAFK"..client:SteamID64()
|
||||
timer.Create(uniqueID, 30, 0, function()
|
||||
if (IsValid(client)) then
|
||||
local result = client:CheckAFKTick(client.ixAfkInterval)
|
||||
if (result) then
|
||||
client.ixAfkInterval = result
|
||||
timer.Adjust(uniqueID, result)
|
||||
end
|
||||
else
|
||||
timer.Remove(uniqueID)
|
||||
end
|
||||
end)
|
||||
|
||||
client:ResetAFKTimer()
|
||||
end
|
||||
|
||||
function PLUGIN:PlayerInteractItem(client)
|
||||
client:ResetAFKTimer()
|
||||
end
|
||||
|
||||
function PLUGIN:PlayerSay(client)
|
||||
client:ResetAFKTimer()
|
||||
end
|
||||
84
gamemodes/helix/plugins/willardantiafk/sv_plugin.lua
Normal file
84
gamemodes/helix/plugins/willardantiafk/sv_plugin.lua
Normal file
@@ -0,0 +1,84 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
|
||||
local PLUGIN = PLUGIN
|
||||
local INTERVAL = 30
|
||||
|
||||
util.AddNetworkString("ixPrintAfkPlayers")
|
||||
|
||||
ix.log.AddType("afkStart", function(client)
|
||||
return Format("%s est maintenant AFK.", client:Name())
|
||||
end)
|
||||
ix.log.AddType("afkEnd", function(client, ...)
|
||||
local arg = {...}
|
||||
return Format("%s n'est plus AFK. Temps total passé AFK : %s", client:Name(), arg[1])
|
||||
end)
|
||||
|
||||
do
|
||||
local PLAYER = FindMetaTable("Player")
|
||||
|
||||
function PLAYER:CheckAFKTick(interval)
|
||||
local aimVector = self:GetAimVector()
|
||||
local posVector = self:GetPos()
|
||||
|
||||
if (self.ixLastAimVector == aimVector
|
||||
and self.ixLastPosition == posVector
|
||||
and !self.autowalk)
|
||||
then
|
||||
|
||||
return self:AddAFKTime(interval or INTERVAL)
|
||||
else
|
||||
self.ixLastAimVector = aimVector
|
||||
self.ixLastPosition = posVector
|
||||
if (self:GetNetVar("afkTime", 0) > 0) then
|
||||
return self:ResetAFKTimer()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function PLAYER:AddAFKTime(time)
|
||||
local oldValue, oldTime = self:IsAFK(), self:GetNetVar("afkTime", 0)
|
||||
self:SetNetVar("afkTime", oldTime + time)
|
||||
|
||||
if (self:IsAFK() and !oldValue) then
|
||||
ix.log.Add(self, "afkStart")
|
||||
return 5
|
||||
elseif (oldTime + time >= ix.config.Get("afkTime") - 60 and oldTime < ix.config.Get("afkTime") - 60) then
|
||||
self:Notify("Vous serez considéré comme AFK dans 60 secondes si vous ne bougez pas.")
|
||||
return 1
|
||||
end
|
||||
end
|
||||
|
||||
function PLAYER:ResetAFKTimer()
|
||||
if (self:IsAFK()) then
|
||||
ix.log.Add(self, "afkEnd", self:GetNetVar("afkTime", 0))
|
||||
elseif (self:GetNetVar("afkTime", 0) > (ix.config.Get("afkTime") - 60)) then
|
||||
self:Notify("Timer d'AFK réinitialiser.")
|
||||
end
|
||||
|
||||
self:SetNetVar("afkTime", 0)
|
||||
|
||||
return INTERVAL
|
||||
end
|
||||
end
|
||||
|
||||
function PLUGIN:KickAFK(target, byAdmin)
|
||||
if (target and target:IsAFK()) then
|
||||
target:Kick("Vous avez été expulsé pour être AFK")
|
||||
if (byAdmin) then
|
||||
ix.util.NotifyLocalized("kickedAdminAFK", nil, byAdmin:Name(), target:Name())
|
||||
else
|
||||
ix.util.NotifyLocalized("kickedAFK", nil, target:Name())
|
||||
end
|
||||
elseif (byAdmin) then
|
||||
byAdmin:NotifyLocalized("targetNotAFK", target:Name())
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user