Skip to content

Commit

Permalink
fix: non CPPI compliant prop protections
Browse files Browse the repository at this point in the history
  • Loading branch information
TomDotBat committed May 26, 2021
1 parent 36ff800 commit 09bc57a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
22 changes: 21 additions & 1 deletion lua/entities/pixel_kart.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,17 @@ function ENT:Initialize()

if CLIENT then return end

if not (self.CPPIGetOwner and IsValid(self:CPPIGetOwner())) then
if not self.CPPIGetOwner then
function self:CPPIGetOwner()
return self.PIXELKartsOwner
end

function self:CPPISetOwner(ply)
self.PIXELKartsOwner = ply
end
end

if not IsValid(self:CPPIGetOwner()) then
SafeRemoveEntityDelayed(self, .1)
return
end
Expand All @@ -36,6 +46,16 @@ function ENT:Initialize()
return
end

if not veh.CPPIGetOwner then
function veh:CPPIGetOwner()
return self.PIXELKartsOwner
end

function veh:CPPISetOwner(ply)
self.PIXELKartsOwner = ply
end
end

veh:SetPos(self:GetPos())
veh:SetAngles(self:GetAngles())
veh:SetModel("models/freeman/vehicles/electric_go-kart.mdl")
Expand Down
4 changes: 3 additions & 1 deletion lua/pixelkarts/garage/sv_networking.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ local function togglePlayerGarageState(ply, forced)
local kart = ents.Create("pixel_kart") --{{ user_id sha256 key }}
if not IsValid(kart) then return end

kart:CPPISetOwner(ply)
kart.PIXELKartsOwner = ply
if kart.CPPISetOwner then kart:CPPISetOwner(ply) end

kart.NoUndo = true
kart:SetPos(garageConfig.SpawnPos)
kart:SetAngles(garageConfig.SpawnAngle)
Expand Down

0 comments on commit 09bc57a

Please sign in to comment.