Skip to content

Commit 7ba62fd

Browse files
committed
Better CPPI checks
1 parent 44f630d commit 7ba62fd

File tree

1 file changed

+27
-14
lines changed

1 file changed

+27
-14
lines changed

lua/fpp/sh_cppi.lua

+27-14
Original file line numberDiff line numberDiff line change
@@ -67,41 +67,54 @@ if SERVER then
6767
end
6868

6969
function ENTITY:CPPICanTool(ply, tool)
70-
local Value = FPP.Protect.CanTool(ply, nil, tool, self)
71-
if Value ~= false and Value ~= true then Value = true end
72-
return Value
70+
local cantool = FPP.Protect.CanTool(ply, nil, tool, self)
71+
if cantool == nil then cantool = true end
72+
return cantool
7373
end
7474

7575
function ENTITY:CPPICanPhysgun(ply)
76-
return FPP.plyCanTouchEnt(ply, self, "Physgun")
76+
local canphysgun = FPP.Protect.PhysgunPickup(ply, self)
77+
if canphysgun == nil then canphysgun = true end
78+
return canphysgun
7779
end
7880

7981
function ENTITY:CPPICanPickup(ply)
80-
return FPP.plyCanTouchEnt(ply, self, "Gravgun")
82+
local canpickup = FPP.Protect.CanGravGunPickup(ply, self)
83+
if canpickup == nil then canpickup = true end
84+
return canpickup
8185
end
8286

8387
function ENTITY:CPPICanPunt(ply)
84-
return FPP.plyCanTouchEnt(ply, self, "Gravgun")
88+
local canpunt = FPP.Protect.GravGunPunt(ply, self)
89+
if canpunt == nil then canpunt = true end
90+
return canpunt
8591
end
8692

8793
function ENTITY:CPPICanUse(ply)
88-
return FPP.plyCanTouchEnt(ply, self, "PlayerUse")
94+
local canuse = FPP.Protect.PlayerUse(ply, self)
95+
if canuse == nil then canuse = true end
96+
return canuse
8997
end
9098

9199
function ENTITY:CPPICanDamage(ply)
92-
return FPP.plyCanTouchEnt(ply, self, "EntityDamage")
100+
local dmginfo = DamageInfo()
101+
dmginfo:SetAttacker(ply)
102+
dmginfo:SetDamage(-1)
103+
104+
FPP.Protect.EntityDamage(self, dmginfo)
105+
return dmginfo:GetDamage() ~= 0
93106
end
94107

95108
function ENTITY:CPPIDrive(ply)
96-
local Value = FPP.Protect.CanDrive(ply, self)
97-
if Value ~= false and Value ~= true then Value = true end
98-
return Value
109+
local candrive = FPP.Protect.CanDrive(ply, self)
110+
if candrive == nil then candrive = true end
111+
return candrive
99112
end
100113

101114
function ENTITY:CPPICanProperty(ply, property)
102-
local Value = FPP.Protect.CanProperty(ply, property, self)
103-
if Value ~= false and Value ~= true then Value = true end
104-
return Value
115+
local canproperty = FPP.Protect.CanProperty(ply, property, self)
116+
if canproperty == nil then canproperty = true end
117+
return canproperty
105118
end
106119

107120
function ENTITY:CPPICanEditVariable(ply, key, val, editTbl)

0 commit comments

Comments
 (0)