mirror of
https://github.com/lifestorm/wnsrc.git
synced 2025-12-17 05:43:46 +03:00
140 lines
3.6 KiB
Lua
140 lines
3.6 KiB
Lua
--[[
|
|
| 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/
|
|
--]]
|
|
|
|
|
|
require("niknaks")
|
|
|
|
local PLUGIN = PLUGIN
|
|
|
|
PLUGIN.name = "Clientside Props"
|
|
PLUGIN.description = "Adds a way to convert server props to clientside props for performance reasons."
|
|
PLUGIN.author = "Aspect™"
|
|
|
|
PLUGIN.clientProps = PLUGIN.clientProps or {}
|
|
|
|
ix.util.Include("cl_hooks.lua")
|
|
ix.util.Include("cl_plugin.lua")
|
|
ix.util.Include("sv_hooks.lua")
|
|
ix.util.Include("sv_plugin.lua")
|
|
|
|
CAMI.RegisterPrivilege({
|
|
Name = "Helix - Manage Clientside Props",
|
|
MinAccess = "admin"
|
|
})
|
|
|
|
ix.option.Add("csentRenderSpeed", ix.type.number, 50, {
|
|
category = "performance",
|
|
min = 1,
|
|
max = 500
|
|
})
|
|
|
|
ix.lang.AddTable("english", {
|
|
optCsentRenderSpeed = "Prędkość renderowana Propów Clientside",
|
|
optdCsentRenderSpeed = "Ile propów clientside powinno być kalkulowanych co klatkę. Niższe wartości = więcej FPS, ale wolniej renderuje. Wyższe wartości = mniej FPS, ale szybciej renderuje.",
|
|
cmdRemoveClientProps = "Usuń wszystkie propy clientside w promieniu wokół ciebie."
|
|
})
|
|
|
|
ix.lang.AddTable("polish", {
|
|
optCsentRenderSpeed = "Prędkość renderowana Propów Clientside",
|
|
optdCsentRenderSpeed = "Ile propów clientside powinno być kalkulowanych co klatkę. Niższe wartości = więcej FPS, ale wolniej renderuje. Wyższe wartości = mniej FPS, ale szybciej renderuje.",
|
|
cmdRemoveClientProps = "Usuń wszystkie propy clientside w promieniu wokół ciebie."
|
|
})
|
|
|
|
ix.command.Add("RemoveClientProps", {
|
|
description = "@cmdRemoveClientProps",
|
|
adminOnly = true,
|
|
arguments = {
|
|
ix.type.number
|
|
},
|
|
OnRun = function(self, client, radius)
|
|
if (radius < 0) then
|
|
client:Notify("Radius must be a positive number!")
|
|
|
|
return
|
|
end
|
|
|
|
local newTable = {}
|
|
|
|
for k, propData in ipairs(PLUGIN.clientProps) do
|
|
if (propData.position:Distance(client:GetPos()) <= radius) then continue end
|
|
|
|
newTable[#newTable + 1] = propData
|
|
end
|
|
|
|
PLUGIN.clientProps = newTable
|
|
|
|
net.Start("ixClientProps.MassRemoveProps")
|
|
net.WriteVector(client:GetPos())
|
|
net.WriteUInt(radius, 16)
|
|
net.Broadcast()
|
|
|
|
client:Notify("Removed all clientside props in a radius of " .. radius .. " units.")
|
|
end
|
|
})
|
|
|
|
local PERSISTENCE = ix.plugin.Get("persistence")
|
|
|
|
properties.Add("clientprop", {
|
|
MenuLabel = "Convert to Client Prop",
|
|
Order = 400,
|
|
MenuIcon = "icon16/contrast_low.png",
|
|
|
|
Filter = function(self, entity, client)
|
|
return entity:GetClass() == "prop_physics" and CAMI.PlayerHasAccess(client, "Helix - Manage Clientside Props")
|
|
end,
|
|
|
|
Action = function(self, entity)
|
|
self:MsgStart()
|
|
net.WriteEntity(entity)
|
|
self:MsgEnd()
|
|
end,
|
|
|
|
Receive = function(self, length, client)
|
|
local entity = net.ReadEntity()
|
|
|
|
if (!IsValid(entity)) then return end
|
|
if (!self:Filter(entity, client)) then return end
|
|
|
|
if (!entity:TestPVS(client)) then
|
|
client:Notify("That prop cannot be converted because its origin is outside the world!")
|
|
|
|
return
|
|
end
|
|
|
|
-- Unpersist it if it's persisted
|
|
if (PERSISTENCE) then
|
|
for k, v in ipairs(PERSISTENCE.stored) do
|
|
if (v == entity) then
|
|
table.remove(PERSISTENCE.stored, k)
|
|
|
|
break
|
|
end
|
|
end
|
|
|
|
entity:SetNetVar("Persistent", false)
|
|
end
|
|
|
|
local propData = {
|
|
position = entity:GetPos(),
|
|
angles = entity:GetAngles(),
|
|
model = entity:GetModel(),
|
|
skin = entity:GetSkin(),
|
|
color = entity:GetColor(),
|
|
material = entity:GetMaterial()
|
|
}
|
|
|
|
entity:Remove()
|
|
|
|
PLUGIN.clientProps[#PLUGIN.clientProps + 1] = propData
|
|
|
|
PLUGIN:NetworkProp(propData)
|
|
end
|
|
})
|