This commit is contained in:
lifestorm
2024-08-04 22:55:00 +03:00
parent 0e770b2b49
commit 94063e4369
7342 changed files with 1718932 additions and 14 deletions

View File

@@ -0,0 +1,204 @@
--[[
| 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 IsValid = IsValid
local LocalPlayer = LocalPlayer
local DynamicLight = DynamicLight
local math = math
local CurTime = CurTime
local ix = ix
local hook = hook
local CAMI = CAMI
local ScrW = ScrW
local ScrH = ScrH
local pairs = pairs
local ents = ents
local string = string
local ipairs = ipairs
local surface = surface
local ColorAlpha = ColorAlpha
local table = table
local Color = Color
local PLUGIN = PLUGIN
PLUGIN.dimDistance = 1024
net.Receive("ixObserverFlashlight", function(len, ply)
LocalPlayer():EmitSound("buttons/lightswitch2.wav")
end)
function PLUGIN:ShouldPopulateEntityInfo(entity)
if (IsValid(entity) and
(entity:IsPlayer() or IsValid(entity:GetNetVar("player"))) and
(entity:GetMoveType() == MOVETYPE_NOCLIP and !entity:InVehicle())) then
return false
end
end
function PLUGIN:DrawPhysgunBeam(client, physgun, enabled, target, bone, hitPos)
if (client != LocalPlayer() and client:GetMoveType() == MOVETYPE_NOCLIP) then
return false
end
end
function PLUGIN:PrePlayerDraw(client)
if (client:GetMoveType() == MOVETYPE_NOCLIP and !client:InVehicle()) then
return true
end
end
function PLUGIN:Think()
if (!LocalPlayer():GetLocalVar("observerLight") or ix.option.Get("observerFullBright", false)) then return end
local dlight = DynamicLight(LocalPlayer():EntIndex())
if (dlight) then
local trace = LocalPlayer():GetEyeTraceNoCursor()
dlight.pos = LocalPlayer():GetShootPos() + LocalPlayer():EyeAngles():Forward() * -100
dlight.r = 255
dlight.g = 255
dlight.b = 255
dlight.brightness = math.Remap(math.Clamp(trace.HitPos:DistToSqr(LocalPlayer():EyePos()), 100, 10000), 100, 10000, 0.01, 1)
dlight.Decay = 20000
dlight.Size = 2000
dlight.DieTime = CurTime() + 0.1
end
end
function PLUGIN:ThirdPersonToggled(oldValue, value)
if (value and LocalPlayer():GetMoveType() == MOVETYPE_NOCLIP and !LocalPlayer():InVehicle()) then
ix.option.Set("thirdpersonEnabled", false)
end
end
function PLUGIN:HUDPaint()
local client = LocalPlayer()
local drawESP = hook.Run("ShouldDrawAdminESP")
if (drawESP == nil) then
drawESP = ix.option.Get("observerESP", true) and client:GetMoveType() == MOVETYPE_NOCLIP and
!client:InVehicle() and CAMI.PlayerHasAccess(client, "Helix - Observer", nil)
end
if (drawESP) then
local scrW, scrH = ScrW(), ScrH()
local marginX, marginY = scrH * .1, scrH * .1
self:DrawPlayerESP(client, scrW, scrH)
if (ix.observer:ShouldRenderAnyTypes() and CAMI.PlayerHasAccess(LocalPlayer(), "Helix - Observer Extra ESP", nil)) then
for _, ent in pairs(ents.GetAll()) do
if (!IsValid(ent)) then continue end
local class = string.lower(ent:GetClass())
if (ix.observer.types[class] and ix.option.Get(ix.observer.types[class][1])) then
local screenPosition = ent:GetPos():ToScreen()
local x, y = math.Clamp(screenPosition.x, marginX, scrW - marginX), math.Clamp(screenPosition.y, marginY, scrH - marginY)
if ((x != screenPosition.x or screenPosition.y != y) and !ix.observer.types[class][3]) then
continue
end
local distance = client:GetPos():Distance(ent:GetPos())
local factor = 1 - math.Clamp(distance / self.dimDistance, 0, 1)
ix.observer.types[class][2](client, ent, x, y, factor, distance)
end
end
end
local points = {}
hook.Run("DrawPointESP", points)
for _, v in ipairs(points) do
local screenPosition = v[1]:ToScreen()
local x, y = math.Clamp(screenPosition.x, marginX, scrW - marginX), math.Clamp(screenPosition.y, marginY, scrH - marginY)
local distance = client:GetPos():Distance(v[1])
local alpha = math.Remap(math.Clamp(distance, v[4] or 1500, v[5] or 2000), v[4] or 1500, v[4] or 2000, 255, v[6] or 0)
local size = math.Remap(math.Clamp(distance, 0, v[5] or 2000), v[4] or 1500, v[4] or 2000, 10, 2)
local drawColor = v[3] or color_white
surface.SetDrawColor(drawColor.r, drawColor.g, drawColor.b, alpha)
surface.SetFont("ixGenericFont")
surface.DrawRect(x - size / 2, y - size / 2, size, size)
ix.util.DrawText(v[2], x, y - (size + 5), ColorAlpha(drawColor, alpha), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, nil, alpha)
end
end
end
function PLUGIN:DrawPointESP(points)
if (ix.option.Get("mapscenesESP")) then
local scenes = hook.Run("GetMapscenes")
if (scenes and !table.IsEmpty(scenes)) then
for k, v in pairs(scenes) do
points[#points + 1] = {v[1], "Mapscene #"..k..", "..v[3], Color(50, 191, 179)}
end
end
end
end
local blacklist = {
["ix_hands"] = true,
["ix_keys"] = true,
["gmod_tool"] = true,
["weapon_physgun"] = true,
}
function PLUGIN:GetPlayerESPText(client, toDraw, distance, alphaFar, alphaMid, alphaClose)
toDraw[#toDraw + 1] = {alpha = alphaMid, priority = 11, text = client:SteamName()}
local weapon = client:GetActiveWeapon()
if (IsValid(weapon) and !blacklist[weapon:GetClass()]) then
toDraw[#toDraw + 1] = {alpha = alphaMid, priority = 15, text = "Arme : "..weapon:GetClass()}
end
end
function PLUGIN:PreRender()
if (LocalPlayer():GetLocalVar("observerLight") and ix.option.Get("observerFullBright", false)) then
render.SetLightingMode(1)
end
end
function PLUGIN:PreDrawHUD()
if (LocalPlayer():GetLocalVar("observerLight") and ix.option.Get("observerFullBright", false)) then
render.SetLightingMode(0)
end
end
-- Overriding the SF2 PostDraw2DSkyBox hook otherwise fullbright doesn't work.
hook.Add("PostDraw2DSkyBox", "StormFox2.SkyBoxRender", function()
if (LocalPlayer():GetLocalVar("observerLight") and ix.option.Get("observerFullBright", false)) then return end
if (!StormFox2 or !StormFox2.Loaded or !StormFox2.Setting.SFEnabled()) then return end
if (!StormFox2.util or !StormFox2.Sun or !StormFox2.Moon or !StormFox2.Moon.GetAngle) then return end
local c_pos = StormFox2.util.RenderPos()
local sky = StormFox2.Setting.GetCache("enable_skybox", true)
local use_2d = StormFox2.Setting.GetCache("use_2dskybox",false)
cam.Start3D(Vector(0, 0, 0), EyeAngles(), nil, nil, nil, nil, nil, 1, 32000) -- 2d maps fix
render.OverrideDepthEnable(false,false)
render.SuppressEngineLighting(true)
render.SetLightingMode(2)
if (!use_2d or !sky) then
hook.Run("StormFox2.2DSkybox.StarRender", c_pos)
-- hook.Run("StormFox2.2DSkybox.BlockStarRender",c_pos)
hook.Run("StormFox2.2DSkybox.SunRender", c_pos) -- No need to block, shrink the sun.
hook.Run("StormFox2.2DSkybox.Moon", c_pos)
end
hook.Run("StormFox2.2DSkybox.CloudBox", c_pos)
hook.Run("StormFox2.2DSkybox.CloudLayer", c_pos)
hook.Run("StormFox2.2DSkybox.FogLayer", c_pos)
render.SuppressEngineLighting(false)
render.SetLightingMode(0)
render.OverrideDepthEnable( false, false )
cam.End3D()
render.SetColorMaterial()
end)

View File

@@ -0,0 +1,222 @@
--[[
| 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 Color = Color
local CreateMaterial = CreateMaterial
local net = net
local os = os
local cam = cam
local hook = hook
local player = player
local team = team
local Vector = Vector
local surface = surface
local table = table
local render = render
local util = util
local ix = ix
local math = math
local ipairs = ipairs
local PLUGIN = PLUGIN
PLUGIN.traceFilter = {nil, nil}
local extraColor = Color(200, 200, 200, 255)
local mat1 = CreateMaterial("GA0249aSFJ3","VertexLitGeneric",{
["$basetexture"] = "models/debug/debugwhite",
["$model"] = 1,
["$translucent"] = 1,
["$alpha"] = 1,
["$nocull"] = 1,
["$ignorez"] = 1
})
net.Receive("ixObserverDisableTP", function(len)
if (ix.option.Get("thirdpersonEnabled")) then
net.Start("ixObserverDisableTP")
net.SendToServer()
end
ix.option.Set("thirdpersonEnabled", net.ReadBool())
end)
do
local npcColor = Color(255, 0, 128)
local espColor = Color(255,255,255,255)
local espColors = {
["Weapons"] = Color(255,78,69),
["Ammunition"] = Color(255,78,69),
["Medical"] = Color(138,200,97),
["Crafting"] = Color(255,204,0)
}
local minAlpha = {
["Writing"] = 0,
["Workbenches"] = 0,
}
local function itemESP(client, entity, x, y, factor, distance)
local itemTable = entity:GetItemTable()
if (!itemTable) then return end
local color = espColors[itemTable.category] or espColor
local alpha = math.Remap(math.Clamp(distance, 1500, 2000), 1500, 2000, 255, minAlpha[itemTable.category] or 45)
if (alpha == 0) then return end
color.a = alpha
ix.util.DrawText(itemTable.name .. " (#" .. entity:GetNetVar("itemID", "nil ID") .. ")", x, y + math.max(10, 32 * factor), color, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, nil, alpha)
local owner = entity:GetNetVar("ownerName")
if (owner) then
local time = (entity:GetNetVar("spawnTime") and " - "..math.ceil((os.time() - entity:GetNetVar("spawnTime")) / 60).."m") or ""
alpha = math.Remap(math.Clamp(distance, 400, 700), 400, 700, 255, 0)
espColor.a = alpha
ix.util.DrawText(owner..time, x, y + math.max(10, 32 * factor) + 20, espColor, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, nil, alpha)
end
end
ix.observer:RegisterESPType("ix_item", itemESP, "item")
local function npcESP(client, entity, x, y, factor)
ix.util.DrawText(entity:GetClass(), x, y - math.max(10, 32 * factor), npcColor, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, nil, math.max(255 * factor, 80))
end
ix.observer:RegisterESPType("ix_npc", npcESP, "npc", "Voir NPC", nil, true)
if (CLIENT) then
local function containerESP(client, entity, x, y, factor, distance)
local color = espColor
local alpha = math.Remap(math.Clamp(distance, 500, 1000), 500, 1000, 255, 30)
color.a = alpha
ix.util.DrawText("Container - "..entity:GetDisplayName().." #"..entity:EntIndex(), x, y - math.max(10, 32 * factor), color, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, nil, alpha)
end
ix.observer:RegisterESPType("ix_container", containerESP, "container")
end
local function staticESP(client, entity, x, y, factor, distance)
if (distance > 2500) then return end
local alpha = math.Remap(math.Clamp(distance, 500, 2500), 500, 2500, 255, 45)
espColor.a = alpha
if (IsValid(entity) and entity:GetNetVar("Persistent", false)) then
ix.util.DrawText(entity:GetModel(), x, y - math.max(10, 32 * factor), espColor, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, nil, alpha)
end
end
ix.observer:RegisterESPType("prop_physics", staticESP, "static", "Voir props statiques")
end
local function sortFunc(a, b)
if (a.alpha != b.alpha) then
return a.alpha > b.alpha
elseif (a.priority != b.priority) then
return a.priority < b.priority
else
return a.text < b.text
end
end
function PLUGIN:DrawPlayerESP(client, scrW, scrH)
local pos = client:EyePos()
local marginX, marginY = scrW * .1, scrH * .1
self.traceFilter[1] = client
local names = {}
cam.Start3D()
local targets = hook.Run("GetAdminESPTargets") or player.GetAll()
for _, v in ipairs(targets) do
if (v == client or !v:GetCharacter() or client:GetAimVector():Dot((v:GetPos() - pos):GetNormal()) < 0.65) then
continue
end
local bObserver = v:GetMoveType() == MOVETYPE_NOCLIP and !v:InVehicle()
local teamColor = bObserver and Color(255, 85, 20, 255) or team.GetColor(v:Team())
local vEyePos = v:EyePos()
local distance = pos:Distance(vEyePos)
self:RenderAdminESP(client, v, teamColor, pos, vEyePos, distance)
names[#names + 1] = {v, teamColor, distance}
end
cam.End3D()
local right = client:GetRight() * 25
for _, info in ipairs(names) do
local ply, teamColor, distance = info[1], info[2], info[3]
local plyPos = ply:GetPos()
local min, max = ply:GetModelRenderBounds()
min = min + plyPos + right
max = max + plyPos + right
local barMin = Vector((min.x + max.x) / 2, (min.y + max.y) / 2, min.z):ToScreen()
local barMax = Vector((min.x + max.x) / 2, (min.y + max.y) / 2, max.z):ToScreen()
local eyePos = ply:EyePos():ToScreen()
local rightS = math.min(math.max(barMin.x, barMax.x), eyePos.x + 150)
local barWidth = math.Remap(math.Clamp(distance, 200, 2000), 500, 2000, 120, 75)
local barHeight = math.abs(barMax.y - barMin.y)
local barX, barY = math.Clamp(rightS, marginX, scrW - marginX - barWidth), math.Clamp(barMin.y - barHeight + 18, marginY, scrH - marginY)
local alphaFar = math.Remap(math.Clamp(distance, 1500, 2000), 1500, 2000, 255, 0)
local alphaMid = math.Remap(math.Clamp(distance, 400, 700), 400, 700, 255, 0)
local alphaClose = math.Remap(math.Clamp(distance, 200, 500), 200, 500, 255, 0)
local bArmor = ply:Armor() > 0
surface.SetDrawColor(40, 40, 40, 200 * alphaFar / 255)
surface.DrawRect(barX - 1, barY - 1, barWidth + 2, 5)
if (bArmor) then surface.DrawRect(barX - 1, barY + 9, barWidth + 2, 5) end
surface.SetDrawColor(teamColor.r * 1.6, teamColor.g * 1.6, teamColor.b * 1.6, alphaFar)
surface.DrawRect(barX, barY, barWidth * math.Clamp(ply:Health() / ply:GetMaxHealth(), 0, 1), 3)
local extraHeight = 0
if (bArmor) then
extraHeight = 10
surface.SetDrawColor(255, 255, 255, alphaFar)
surface.DrawRect(barX, barY + 10, barWidth * math.Clamp(ply:Armor() / 50, 0, 1), 3)
end
surface.SetFont("WNBackFontNoClamp")
ix.util.DrawText(ply:Name(), barX, barY - 13, teamColor, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER, nil, 255)
if (ix.option.Get("steamESP")) then
surface.SetFont("WNMenuFontNoClamp")
local y = barY + extraHeight + 13
local toDraw = {}
hook.Run("GetPlayerESPText", ply, toDraw, distance, alphaFar, alphaMid, alphaClose)
table.sort(toDraw, sortFunc)
for _, v in ipairs(toDraw) do
if (v.alpha <= 0) then continue end
extraColor.a = v.alpha
ix.util.DrawText(v.text, barX, y, v.color or extraColor, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER, nil, v.alpha)
local _, txtHeight = surface.GetTextSize(v.text)
y = y + txtHeight
end
end
end
end
function PLUGIN:RenderAdminESP(client, target, color, clientPos, targetEyePos, distance)
render.SuppressEngineLighting(true)
render.SetColorModulation(color.r / 255, color.g / 255, color.b / 255)
self.traceFilter[2] = target
if (ix.option.Get("cheapBlur", false) or util.QuickTrace(clientPos, targetEyePos - clientPos, self.traceFilter).Fraction < 0.95) then
render.SetBlend(1)
else
render.SetBlend(math.Remap(math.Clamp(distance, 200, 4000), 200, 8000, 0.05, 1))
end
render.MaterialOverride(mat1)
target:DrawModel()
render.MaterialOverride()
render.SuppressEngineLighting(false)
end

View File

@@ -0,0 +1,43 @@
--[[
| 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 ix = ix
ix.observer = ix.observer or {}
ix.observer.types = ix.observer.types or {}
function ix.observer:RegisterESPType(type, func, optionName, optionNiceName, optionDesc, bDrawClamped)
optionName = string.lower(optionName)
local editCapital = string.utf8sub(optionName, 1, 1)
local capitalName = string.utf8upper(editCapital)..string.utf8sub(optionName, 2)
ix.option.Add(optionName.."ESP", ix.type.bool, false, {
category = "Observateur",
hidden = function()
return !CAMI.PlayerHasAccess(LocalPlayer(), "Helix - Observer Extra ESP")
end
})
ix.lang.AddTable("english", {
["opt"..capitalName.."ESP"] = optionNiceName or "Montrer "..capitalName.." ESP",
["optd"..capitalName.."ESP"] = optionDesc or "Activé / désactivé "..optionName.." ESP."
})
ix.observer.types[string.lower(type)] = {optionName.."ESP", func, bDrawClamped}
end
function ix.observer:ShouldRenderAnyTypes()
for _, v in pairs(ix.observer.types) do
if (ix.option.Get(v[1])) then
return true
end
end
return false
end

View File

@@ -0,0 +1,106 @@
--[[
| 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 ix = ix
local CAMI = CAMI
local LocalPlayer = LocalPlayer
local PLUGIN = PLUGIN
PLUGIN.name = "Better Observer"
PLUGIN.author = "Chessnut & Gr4Ss"
PLUGIN.description = "Adds on to the no-clip mode to prevent intrusion. Edited for WN by Gr4Ss."
ix.plugin.SetUnloaded("observer", true)
CAMI.RegisterPrivilege({
Name = "Helix - Observer",
MinAccess = "admin"
})
CAMI.RegisterPrivilege({
Name = "Helix - Observer Extra ESP",
MinAccess = "superadmin"
})
ix.option.Add("observerTeleportBack", ix.type.bool, true, {
bNetworked = true,
category = "Observateur",
hidden = function()
return !CAMI.PlayerHasAccess(LocalPlayer(), "Helix - Observer", nil)
end
})
ix.option.Add("observerESP", ix.type.bool, true, {
category = "Observateur",
hidden = function()
return !CAMI.PlayerHasAccess(LocalPlayer(), "Helix - Observer", nil)
end
})
ix.option.Add("steamESP", ix.type.bool, true, {
category = "Observateur",
hidden = function()
return !CAMI.PlayerHasAccess(LocalPlayer(), "Helix - Observer", nil)
end
})
ix.option.Add("mapscenesESP", ix.type.bool, false, {
category = "Observateur",
hidden = function()
return !CAMI.PlayerHasAccess(LocalPlayer(), "Helix - Observer", nil)
end
})
ix.option.Add("alwaysObserverLight", ix.type.bool, true, {
category = "Observateur",
hidden = function()
return !CAMI.PlayerHasAccess(LocalPlayer(), "Helix - Observer")
end,
bNetworked = true
})
ix.option.Add("observerFullBright", ix.type.bool, false, {
category = "Observateur",
hidden = function()
return !CAMI.PlayerHasAccess(LocalPlayer(), "Helix - Observer")
end,
bNetworked = true
})
ix.util.Include("cl_hooks.lua")
ix.util.Include("cl_plugin.lua")
ix.util.Include("sv_plugin.lua")
ix.lang.AddTable("english", {
optSteamESP = "Afficher les informations supplémentaires de l'ESP admin",
optdSteamESP = "Voir le SteamID d'un joueur et sa santé/armure sur l'ESP admin",
optMapscenesESP = "Afficher les scènes de la carte ESP",
optdMapscenesESP = "Montre les emplacements des scènes de carte dans l'ESP d'administration",
optAlwaysObserverLight = "Toujours allumer la lumière de l'observateur",
optdAlwaysObserverLight = "Allumez automatiquement votre lampe d'observateur lorsque vous entrez dans l'observateur. Sinon, elle suivra votre lampe de poche. Peut toujours être éteint manuellement",
optObserverFullBright = "Lumière de l'observateur complète",
optdObserverFullBright = "Eclairez toute la carte lorsque vous activez la lumière de l'observateur"
})
ix.lang.AddTable("french", {
optSteamESP = "Afficher les informations supplémentaires de l'ESP admin",
optdSteamESP = "Voir le SteamID d'un joueur et sa santé/armure sur l'ESP admin",
optMapscenesESP = "Afficher les scènes de la carte ESP",
optdMapscenesESP = "Montre les emplacements des scènes de carte dans l'ESP d'administration",
optAlwaysObserverLight = "Toujours allumer la lumière de l'observateur",
optdAlwaysObserverLight = "Allumez automatiquement votre lampe d'observateur lorsque vous entrez dans l'observateur. Sinon, elle suivra votre lampe de poche. Peut toujours être éteint manuellement",
optObserverFullBright = "Lumière de l'observateur Full Bright",
optdObserverFullBright = "Eclairez toute la carte lorsque vous activez la lumière de l'observateur"
})
ix.lang.AddTable("spanish", {
optdSteamESP = "Muestra el SteamID de un jugador, su salud/armadura en el admin ESP",
optdAlwaysObserverLight = "Enciende la luz del observer automáticamente al entrar en él. De lo contrario seguirá tu linterna. Se puede apagar manualmente.",
optAlwaysObserverLight = "Encender siempre la luz del observer",
optSteamESP = "Muestra la información extra del Admin ESP",
optdMapscenesESP = "Mostrar las localizaciones de Escenarios del Mapa en el Admin-ESP.",
optMapscenesESP = "Mostrar el ESP del Escenario"
})

View File

@@ -0,0 +1,173 @@
--[[
| 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 util = util
local string = string
local CAMI = CAMI
local timer = timer
local Vector = Vector
local net = net
local os = os
local ipairs = ipairs
local ix = ix
local hook = hook
local PLUGIN = PLUGIN
util.AddNetworkString("ixObserverDisableTP")
util.AddNetworkString("ixObserverFlashlight")
ix.log.AddType("observerEnter", function(client, ...)
return string.format("%s a activé le mode observateur.", client:Name())
end)
ix.log.AddType("observerExit", function(client, ...)
if (ix.option.Get(client, "observerTeleportBack", true)) then
return string.format("%s a désactivé le mode observateur.", client:Name())
else
return string.format("%s a désactivé le mode observateur à son point d'origine.", client:Name())
end
end)
function PLUGIN:CanPlayerEnterObserver(client)
if (CAMI.PlayerHasAccess(client, "Helix - Observer", nil)) then
return true
end
end
function PLUGIN:CanPlayerEnterVehicle(client, vehicle, role)
if (client:GetMoveType() == MOVETYPE_NOCLIP) then
return false
end
end
function PLUGIN:PlayerNoClip(client, state)
if (hook.Run("CanPlayerEnterObserver", client) or (!state and client.ixObsData)) then
if (state) then
client.ixObsData = {client:GetPos(), client:EyeAngles()}
-- Hide them so they are not visible.
client:SetNoDraw(true)
client:SetNotSolid(true)
client:DrawWorldModel(false)
client:DrawShadow(false)
client:GodEnable()
client:SetNoTarget(true)
hook.Run("OnPlayerObserve", client, state)
else
if (client.ixObsData) then
-- Move they player back if they want.
if (ix.option.Get(client, "observerTeleportBack", true)) then
local position, angles = client.ixObsData[1], client.ixObsData[2]
-- Do it the next frame since the player can not be moved right now.
timer.Simple(0, function()
client:SetPos(position)
client:SetEyeAngles(angles)
client:SetVelocity(Vector(0, 0, 0))
end)
end
client.ixObsData = nil
end
-- Make the player visible again.
client:SetNoDraw(false)
client:SetNotSolid(false)
client:DrawWorldModel(true)
client:DrawShadow(true)
client:GodDisable()
client:SetNoTarget(false)
hook.Run("OnPlayerObserve", client, state)
end
return true
end
end
function PLUGIN:OnPlayerObserve(client, state)
local flashlightOn = client:FlashlightIsOn()
if (state) then
if (flashlightOn) then
client:Flashlight(false)
end
client.ixObserverFlashlightReset = flashlightOn
client.ixObserverRestoreTP = nil
if (ix.config.Get("thirdperson")) then
net.Start("ixObserverDisableTP")
net.WriteBool(false)
net.Send(client)
end
ix.log.Add(client, "observerEnter")
else
local flashlightState = client.ixObserverFlashlightReset
client.ixObserverFlashlightReset = nil
if (flashlightOn != flashlightState) then
client:Flashlight(flashlightState)
end
if (ix.config.Get("thirdperson") and client.ixObserverRestoreTP) then
net.Start("ixObserverDisableTP")
net.WriteBool(true)
net.Send(client)
end
client.ixObserverRestoreTP = nil
ix.log.Add(client, "observerExit")
end
client:SetLocalVar("observerLight", state and (ix.option.Get(client, "alwaysObserverLight") or flashlightOn))
end
net.Receive("ixObserverDisableTP", function(len, client)
if (ix.config.Get("thirdperson")) then
client.ixObserverRestoreTP = true
end
end)
function PLUGIN:PlayerSwitchFlashlight(client, state)
if (!client.ixObsData or client.ixObserverFlashlightReset == nil) then return end
client:SetLocalVar("observerLight", !client:GetLocalVar("observerLight"))
net.Start("ixObserverFlashlight")
net.Send(client)
return false
end
function PLUGIN:OnItemSpawned(entity, bOnLoad)
entity:SetNetVar("spawnTime", os.time())
local owner = entity:GetNetVar("owner")
if (owner and ix.char.loaded[owner]) then
entity:SetNetVar("ownerName", ix.char.loaded[owner]:GetName())
else
entity:SetNetVar("ownerName", bOnLoad and "mapload" or "spawned")
end
entity:SetNetVar("itemID", entity.ixItemID)
end
function PLUGIN:OnSavedItemLoaded(items, entities)
for _, v in ipairs(entities) do
self:OnItemSpawned(v, true)
end
end
function PLUGIN:PlayerLoadedCharacter(client, character)
client.ixObsData = nil
client:SetLocalVar("observerLight", false)
end