diff options
Diffstat (limited to 'ftp_gmstranded/gamemode/spp/sh_cppi.lua')
| -rw-r--r-- | ftp_gmstranded/gamemode/spp/sh_cppi.lua | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/ftp_gmstranded/gamemode/spp/sh_cppi.lua b/ftp_gmstranded/gamemode/spp/sh_cppi.lua new file mode 100644 index 0000000..6bf923e --- /dev/null +++ b/ftp_gmstranded/gamemode/spp/sh_cppi.lua @@ -0,0 +1,88 @@ + +function CPPI:GetName() + return "Simple Prop Protection" +end + +function CPPI:GetVersion() + return SPropProtection.Version +end + +function CPPI:GetInterfaceVersion() + return 1.1 +end + +function CPPI:GetNameFromUID( uid ) + return CPPI_NOTIMPLEMENTED +end + +local Player = FindMetaTable( "Player" ) +if ( !Player ) then print( "EXTREME ERROR 1" ) return end + +function Player:CPPIGetFriends() + if ( SERVER ) then + local Table = {} + for k, v in pairs( player.GetAll() ) do + if ( table.HasValue( SPropProtection[ self:SteamID() ], v:SteamID() ) ) then table.insert( Table, v ) end + end + return Table + else + return CPPI_NOTIMPLEMENTED + end +end + +local Entity = FindMetaTable( "Entity" ) +if ( !Entity ) then print( "EXTREME ERROR 2" ) return end + +function Entity:CPPIGetOwner() + local Player = self:GetNetworkedEntity( "OwnerObj", false ) + if ( SERVER ) then Player = SPropProtection[ "Props" ][ self:EntIndex() ][ 3 ] end + if ( !IsValid( Player ) ) then return nil, CPPI_NOTIMPLEMENTED end + local UID = CPPI_NOTIMPLEMENTED + if ( SERVER ) then UID = Player:UniqueID() end + return Player, UID +end + +if ( SERVER ) then + function Entity:CPPISetOwner( ply ) + if ( !IsValid( ply ) or !ply:IsPlayer() ) then return false end + return SPropProtection.PlayerMakePropOwner( ply, self ) + end + + function Entity:CPPISetOwnerUID( uid ) + if ( !uid ) then return false end + local ply = player.GetByUniqueID( tostring( uid ) ) + if ( !ply ) then return false end + return SPropProtection.PlayerMakePropOwner( ply, self ) + end + + function Entity:CPPICanTool( ply, toolmode ) + if ( !IsValid( ply ) or !ply:IsPlayer() or !toolmode ) then return false end + return SPropProtection.PlayerCanTouch( ply, self ) + end + + function Entity:CPPICanPhysgun( ply ) + if ( !IsValid( ply ) or !ply:IsPlayer() ) then return false end + if ( SPropProtection.PhysGravGunPickup( ply, self ) == false ) then return false end + if ( self:GetClass() == "gms_gravestone" ) then return false end + return true + end + + function Entity:CPPICanPickup( ply ) + if ( !IsValid( ply ) or !ply:IsPlayer() ) then return false end + if ( SPropProtection.PhysGravGunPickup( ply, self ) == false ) then return false end + return true + end + + function Entity:CPPICanPunt(ply) + if ( !IsValid( ply ) or !ply:IsPlayer() ) then return false end + if ( SPropProtection.PhysGravGunPickup( ply, self ) == false ) then return false end + return true + end +end + +hook.Add( "Initialize", "CPPIInitGM", function() + function GAMEMODE:CPPIAssignOwnership( ply, ent ) + end + function GAMEMODE:CPPIFriendsChanged( ply, ent ) + end +end ) |
