:siren: Note that this is a WIP (Work in Progress). Feel free to start implementing this in your prop protection, but we are seeking feedback before we submit a final standard.:siren:
[highlight]Purpose of CPPI: Define a standard interface for prop protectors to use for easy third-party integration with any prop protector. I realize this is a long shot, but I don't think anyone has tried something like this within the gmod community to date, so I suppose it's worth a shot.[/highlight]
Now onto the standard:
[highlight]
Namespace: CPPI (store these in the global table 'CPPI')[/highlight]
Function:
GetName() - Returns the name of the active prop protection (IE, "Amazing Prop Sprite")
- Return value constraints: String, less than 255 characters
- Both client and server side.
Function:
GetDate() - Returns the Unix time stamp of the date/time this was released (IE '1199142000' for January 1, 2008. See os.time() or http://soft.zoneo.net/Unixtime/index.php to generate the time).
- Return value constraints: Number
- Both client and server side.
- Use UTC time.
Function:
GetVersion() - Returns the version of the active prop protection (IE, "1.0" or "1.5.6a rev258")
- Return value constraints: String, less than 255 characters
- Both client and server side.
Function:
GetFriends( ply ) - Returns the friends of a player, other players allowed to manipulate the specified players objects.
- Ply argument: A valid player object.
- Return value constraints: Table, less than 64 elements
- Hint: If your prop protection does not implement such a feature, return an empty table.
- Both client and server side, but client side is only required to implement this function for the local player.
Function:
GetInterfaceVersion() - Returns the version of the interface (the version of this standard that the interface is using)
- Return value constraints: returns the number 1
- Both client and server side.
Function:
NameFromUID( uid ) - Returns the name of the player that was using that UID (ply:GetUniqueID())
- uid will be a number specifying a UID (but do error checking regardless)
- Return value constraints: String of player name less than 32 characters, or nil.
- Both client and server side, only required to function on the local player's UID client-side.
[highlight]
Namespace: Entity (the entity metatable)[/highlight]
Function:
CPPIGetOwner() - Returns the owner of this entity
- Returns the player object that owns this entity first and the UID (ply:GetUniqueID()) second. Both values should be nil if no one owns it, first value should be nil if the player is disconnected.
- Must function on both the server and client side for any entity.
Function:
CPPISetOwner( ply ) - Sets a new owner for this entity
- Returns true on success, false on failure
- ply will be a player entity (do error checking regardless)
- ONLY on server
Function:
CPPISetOwnerUID( uid ) - Sets a new owner for this entity
- Returns true on success, false on failure
- uid will be a uid for a player (do error checking regardless)
- ONLY on server
Function:
CPPICanTool( ply, toolmode ) - Checks if a player can tool this object with specified tool. This function MUST NOT reassign ownership; that the player will actually use the tool is not guaranteed.
- Returns true if they can, false if they can't.
- ply will be a player entity (do error checking regardless)
- toolmode will be a string specifying the tool mode to check. May not be one of the default GMod tools.
- Hint: This should be a close alias of your CanTool hook
- ONLY on server
Function:
CPPICanPhysgun( ply ) - Checks if a player can physgun this object. This function MUST NOT reassign ownership; that the player will actually use the physgun is not guaranteed.
- Returns true if they can, false if they can't.
- ply will be a player entity (do error checking regardless)
- Hint: This should be a close alias of your PhysgunPickup hook
- ONLY on server
Function:
CPPICanPickup( ply ) - Checks if a player can pick up this object with '+use' or the gravgun. This function MUST NOT reassign ownership; that the player will actually pick up the object is not guaranteed.
- Returns true if they can, false if they can't.
- ply will be a player entity (do error checking regardless)
- Hint: This should be a close alias of your GravGunPickupAllowed hook
- ONLY on server
Function:
CPPICanPunt( ply ) - Checks if a player can punt this object with the gravgun. This function MUST NOT reassign ownership; that the player will actually punt the object is not guaranteed.
- Returns true if they can, false if they can't.
- ply will be a player entity (do error checking regardless)
- Hint: This should be a close alias of your GravGunPunt hook
- ONLY on server
[highlight]
Namespace: Hooks (normal gamemode hooks called using gamemode.Call() and hooked using hook.Add())[/highlight]
Function:
CPPIAssignOwnership( ply, ent ) - Called when ply assumes ownership of ent.
- If the hook is blocked (by returning true or false), ownership should not be assigned.
- ply should be a valid player entity assuming the ownership or nil if removing ownership
- ent should be a valid entity that the ply now owns
- Hint: This should be called both after a player spawns a new ent and when ownership is reassigned
- Only required on the server, but preferred on client as well.
Function:
CPPIFriendsChanged( ply, newfrends ) - Called when ply gains or loses friends (other players who are allowed access to their ents).
- Should be called after friends are re-assigned, cannot be blocked.
- ply should be a valid player entity that had their friends changed
- newfriends should be a table containing the player's friends.
- Hint: This should be called both after a player spawns in the server and when their friends change
- Only required on the server, but preferred on client as well (at least for local player).