Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions lua/autorun/cppi.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,9 @@ if CLIENT then return end
-- Set owner of an entity
function ENTITY:CPPISetOwner(ply)
if hook.Run('CPPIAssignOwnership', ply, self, CPPI.CPPI_NOTIMPLEMENTED) == false then return false end
self.ppowner = ply
net.Start("pprotect_send_owner")
net.WriteEntity(self)
net.WriteEntity(self.ppowner)
net.Broadcast()
self:SetNWEntity("ppowner", ply)
self:SetNWString("ppownerid", ply:SteamID())
self.ppowner = ply
return true
end

Expand Down
2 changes: 1 addition & 1 deletion lua/patchprotect/client/hud.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ local function showOwner()
local Owner, IsShared, IsBuddy = sh_PProtect.GetOwner(ent), sh_PProtect.IsShared(ent), sh_PProtect.IsBuddy(Owner, LocalPlayer())

local txt = nil
if Owner == nil then
if sh_PProtect.IsWorld(ent) then
txt = 'World'
elseif Owner == "wait" then
txt = 'Waiting for server...'
Expand Down
10 changes: 1 addition & 9 deletions lua/patchprotect/client/propprotection.lua
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,4 @@ function cl_PProtect.setBuddyPerm(budent, p, c)
return c
end

--------------------------
-- PP DATA SYNC FUNCTIONS
--------------------------
net.Receive('pprotect_send_owner', function(len)
local ent = net.ReadEntity()
local owner = net.ReadEntity()
if owner == game.GetWorld() then owner = "world" end
ent.ppowner = owner
end)

5 changes: 4 additions & 1 deletion lua/patchprotect/server/cleanup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,10 @@ hook.Add('PlayerInitialSpawn', 'pprotect_abortcleanupgetply', function(ply)
if v.pprotect_cleanup and v.pprotect_cleanup == ply:SteamID() then
v.pprotect_cleanup = nil
aborting[ply:SteamID()] = nil
v:CPPISetOwner(ply)
timer.Simple(3, function()
if !IsValid(ply) or !IsValid(v) then return end
v:CPPISetOwner(ply)
end)
end
end
end)
17 changes: 3 additions & 14 deletions lua/patchprotect/server/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ util.AddNetworkString('pprotect_notify')
util.AddNetworkString('pprotect_request_cl_data')
util.AddNetworkString('pprotect_send_buddies')
util.AddNetworkString('pprotect_send_isworld')
util.AddNetworkString('pprotect_send_owner')

----------------------
-- DEFAULT CONFIG --
Expand Down Expand Up @@ -421,18 +420,6 @@ net.Receive('pprotect_request_cl_data', function(len, ply)
sv_PProtect_sendbuddies(net.ReadEntity(), ply)
return
end
if typ == "owner" then
local ent = net.ReadEntity()
net.Start("pprotect_send_owner")
net.WriteEntity(ent)
if ent.ppowner == nil then
net.WriteEntity(game.GetWorld())
else
net.WriteEntity(ent.ppowner)
end
net.Send(ply)
return
end
end)


Expand All @@ -442,4 +429,6 @@ hook.Add('PlayerInitialSpawn', 'pprotect_playersettings', sendSettings)
-- Receive admin bypass setting
net.Receive('pprotect_setadminbypass', function(len,pl)
pl.ppadminbypass = net.ReadBool()
end)
end)


7 changes: 5 additions & 2 deletions lua/patchprotect/server/propprotection.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ end
-- Checks if the given entity is a world prop and if players are allowed to interact with them for the given setting
-- ent: valid entity to check
-- sett: PatchProtect setting to use to check for world-premissions
local function CheckWorld(ent, sett)
local function CheckWorld(ent, sett, tool)
if tool == 'creator' then return false end
if tool == 'advdupe2' then return false end
if tool == 'weld' then return false end
if sv_PProtect.Settings.Propprotection['world' .. sett] and sh_PProtect.IsWorld(ent) then return true end
return false
end
Expand Down Expand Up @@ -192,7 +195,7 @@ function sv_PProtect.CanTool(ply, ent, tool)
if CheckPPAdmin(ply) then return end

-- Check World
if CheckWorld(ent, 'tool') then return end
if CheckWorld(ent, 'tool',tool) then return end

-- Check Shared
if sh_PProtect.IsShared(ent, 'tool') then return end
Expand Down
26 changes: 13 additions & 13 deletions lua/patchprotect/shared/patchprotect.lua
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
-- GET OWNER
-- ent: valid entity to get owner player object.
function sh_PProtect.GetOwner(ent)
if CLIENT and ent.ppowner == nil then
net.Start('pprotect_request_cl_data')
net.WriteString("owner")
net.WriteEntity(ent)
net.SendToServer()
ent.ppowner = "wait"
return "wait"
local ply = ent:GetNWEntity("ppowner")
if !IsValid(ply) and !sh_PProtect.IsWorld(ent) then
ply = player.GetBySteamID(ent:GetNWString("ppownerid"))
if IsValid(ply) then
ent:SetNWEntity("ppowner",ply)
return ply
end
end
if CLIENT and ent.ppowner == "world" then return nil end
return ent.ppowner
return ply
end

-- CHECK SHARED
Expand All @@ -27,7 +26,8 @@ end

-- CHECK BUDDY
function sh_PProtect.IsBuddy(ply, bud, mode)
if ply == nil or bud == nil then return false end
if !IsValid(ply) or !IsValid(bud) then return false end
if !ply:IsPlayer() then return false end
if ply == "wait" or bud == "wait" then return false end
if ply == bud then return true end
--if not IsValid(ply) then return false end
Expand All @@ -48,10 +48,10 @@ end
-- CHECK WORLD
-- ent: valid entity to check for being world owned.
function sh_PProtect.IsWorld(ent)
if CLIENT then
return ent.ppowner == "world" or ent:IsWorld()
if !ent:GetNWString("ppownerid"):find("STEAM") then
return true
else
return ent.ppowner == nil or ent:IsWorld()
return false
end
end

Expand Down