Prop protection

Problem
Players can touch administrators or aboves things, administrators cannot touch their things. Also trying to make it so admins can touch world props as well

Here is the cod
[lua]
function _R.Player:CanTouch( objEnt )
if( objEnt:IsPlayer( ) ) then return false; end
if( objEnt.CPPIControlled ) then
if( objEnt:CPPIGetOwner( ) ) then
local objOwner = player.GetByUniqueID( objEnt:CPPIGetOwner( ) );
return objOwner && objOwner:IsBuddy( self ) || false;
end
end
return false;
end
[/lua]

Here is the code we added a line to but all it did was make it so everyone could touch everyones stuff

[lua]
function _R.Player:CanTouch( objEnt )
if( objEnt:IsAdmin( self ) ) then return true; end
if( objEnt:IsPlayer( ) ) then return false; end
if( objEnt.CPPIControlled ) then
if( objEnt:CPPIGetOwner( ) ) then
local objOwner = player.GetByUniqueID( objEnt:CPPIGetOwner( ) );
return objOwner && objOwner:IsBuddy( self ) || false;
end
end
return false;
end
[/lua]

try:

[lua]
function _R.Player:CanTouch( objEnt )
if self:IsAdmin() then return true end
if( objEnt:IsPlayer( ) ) then return false; end
if( objEnt.CPPIControlled ) then
if( objEnt:CPPIGetOwner( ) ) then
local objOwner = player.GetByUniqueID( objEnt:CPPIGetOwner( ) );
return objOwner && objOwner:IsBuddy( self ) || false;
end
end
return false;
end
[/lua]

this should make all admins be able to touch all things

That worked perfect, thank you. Now it’s just the matter of why people can touch the admin+s things.

[lua]
function _R.Player:CanTouch( objEnt )
if self:IsAdmin() then return true end
if( objEnt:IsPlayer( ) ) then return false; end
if( objEnt.CPPIControlled ) then
if( objEnt:CPPIGetOwner( ) and not objEnt:CPPIGetOwner():IsAdmin() ) then
local objOwner = player.GetByUniqueID( objEnt:CPPIGetOwner( ) );
return objOwner && objOwner:IsBuddy( self ) || false;
end
end
return false;
end
[/lua]

Ignore above, I wasn’t paying attention.

Nope, now every group can pick up everyones things with the code you put in there. It’s weird, even the one who made the prop protection said this is really buggy. I wish someone would just make another prop protection, it doesn’t seem hard but apparently it is.

[lua]local objOwner = player.GetByUniqueID( objEnt:CPPIGetOwner( ) );[/lua]

Isn’t objEnt:CPPIGetOwner() returning a player?

since this is my prop protection, no, it returns the owner’s UniqueID, that way you don’t end up with people leaving, someone else joining, and suddenly having ownership of props

Line 5 from Derek is wrong then.

if you’re content on using my unreleased prop protection, edit the IsBuddy function to

[lua]function _R.Player:IsBuddy( objPl )
if( self == objPl ) then return true; end
if( SERVER && fruit.Buddies[self:UniqueID( )] ) then
return fruit.Buddies[self:UniqueID( )][objPl:UniqueID( )] || ( _R.Player.IsMod && self:IsMod( ) || self:IsAdmin( ) );
end
return _R.Player.IsMod && self:IsMod( ) || self:IsAdmin( );
end[/lua]