summaryrefslogtreecommitdiff
path: root/gamemode/spp/sh_cppi.lua
diff options
context:
space:
mode:
authorAlexander Pickering <Alexander.Pickering@anondomain.site90.net>2016-04-16 02:02:00 -0400
committerAlexander Pickering <Alexander.Pickering@anondomain.site90.net>2016-04-16 02:02:00 -0400
commit7e5db609550cca0d8b8a76c4bf78ba4658962167 (patch)
tree4df54e0c4eccff0b022e0732c258b7b193fd6cfe /gamemode/spp/sh_cppi.lua
downloadgmstranded-7e5db609550cca0d8b8a76c4bf78ba4658962167.tar.gz
gmstranded-7e5db609550cca0d8b8a76c4bf78ba4658962167.tar.bz2
gmstranded-7e5db609550cca0d8b8a76c4bf78ba4658962167.zip
Initial commit
Diffstat (limited to 'gamemode/spp/sh_cppi.lua')
-rw-r--r--gamemode/spp/sh_cppi.lua87
1 files changed, 87 insertions, 0 deletions
diff --git a/gamemode/spp/sh_cppi.lua b/gamemode/spp/sh_cppi.lua
new file mode 100644
index 0000000..c5bc3aa
--- /dev/null
+++ b/gamemode/spp/sh_cppi.lua
@@ -0,0 +1,87 @@
+
+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
+ 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 )