CityRP Documentation Repository

SPropProtection

Simple Prop Protection - server-side ownership tracking and permission engine. Originally by Spacetech (code.google.com/p/simplepropprotection).

Functions

Servercleanup.Add(Player, Type, Entity)Source ☍

Parameters

  • Playerany
  • Typeany
  • Entityany
ClientSPropProtection.AdminPanel(Panel)Source ☍

Populates the Q-menu "Admin" panel with spp_* settings and per-player/global cleanup buttons. No-ops for non-admins.

Parameters

  • PanelPanelThe DForm/derma panel to populate.
ServerSPropProtection.AdminReload()Source ☍

Pushes the current spp_* admin settings to every connected player.

ServerSPropProtection.AdminReloadPlayer(ply)Source ☍

Pushes the current spp_* admin settings to a single player's client convars.

Parameters

  • plyPlayerThe player to sync.
ServerSPropProtection.ApplyFriends(ply, cmd, args)Source ☍

Console command (spp_applyfriends): applies the caller's spp_friend_* convar selections to their (session-only, unpersisted) friends list and fires CPPIFriendsChanged if it changed.

Parameters

  • plyPlayerThe invoking player.
  • cmdstringThe concommand name.
  • argstableCommand arguments (unused).
ServerSPropProtection.ApplySettings(ply, cmd, args)Source ☍

Console command (spp_apply): persists an admin's spp_* setting convars to the local SQLite settings table and pushes the new config to every player.

Parameters

  • plyPlayerThe invoking player (must be an admin).
  • cmdstringThe concommand name.
  • argstableCommand arguments (unused).
ServerSPropProtection.CanTool(ply, tr, mode) → boolean|nilSource ☍

Generic tool-use ownership check. CityRP-specific carve-outs (submaterial-on-player Assistant/EventMgr override, vehicle-weld REP/Mechanic override, vehicle MaterialURL staff-only override, vehicle-submaterial REP/Mechanic override) are NOT handled here - they live in GM:CanTool (gamemode/init.lua), which consults this function for anything not already decided by those carve-outs.

Parameters

  • plyPlayerThe acting player.
  • trtableThe tool trace (as passed to GM:CanTool).
  • modestringThe tool mode.

Returns

  1. boolean|nilnil abstains.
ServerSPropProtection.CanToolGeneric(ply, ent) → booleanSource ☍

Generic tool-use gate: ownership plus the mapper-set spp_cantool keyvalue override. Shared by SPropProtection.CanTool (the toolgun hook, which also runs trace-dependent checks for "nail"/WeirdTraces modes that need real trace geometry) and Entity:CPPICanTool (which only receives a tool mode, no trace, so can't run those).

Parameters

  • plyPlayerThe acting player.
  • entEntityThe entity being tooled.

Returns

  1. boolean
ServerSPropProtection.CDP(ply, cmd, args)Source ☍

Console command (spp_cdp): removes every owned entity whose owner (by OwnerSID) is no longer connected. Entities are collected before any are removed, per the same ents.Iterator() caveat noted on DRemove.

Parameters

  • plyPlayer|nilThe invoking player, or nil/invalid from server console.
  • cmdstringThe concommand name.
  • argstableCommand arguments (unused).
ServerSPropProtection.CheckConstraints(ply, ent) → booleanSource ☍

Checks whether ply may touch every entity constrained to ent (used to gate the "remover" tool so it can't indirectly delete someone else's constrained props).

Parameters

  • plyPlayerThe acting player.
  • entEntityThe entity whose constrained set is checked.

Returns

  1. boolean
ServerSPropProtection.CheckKeyvalue(ent, key, val)Source ☍

Reads mapper-set spp_cantouch/spp_canuse/spp_cantool keyvalues so map-placed entities can override the default protection behaviour.

Parameters

  • entEntityThe entity carrying the keyvalue.
  • keystringThe keyvalue name.
  • valstringThe keyvalue value.
ServerSPropProtection.CleanupPlayerProps(ply)Source ☍

Removes every entity currently owned by ply (by OwnerSID). Entities are collected before any are removed, per the same ents.Iterator() caveat noted on DRemove.

Parameters

  • plyPlayerThe player whose props are removed.
ServerSPropProtection.CleanupProps(ply, cmd, args)Source ☍

Console command (spp_cleanupprops): with no argument, cleans up the caller's own props; with an entity index argument, staff can clean up another player's props.

Parameters

  • plyPlayer|nilThe invoking player, or nil/invalid from server console.
  • cmdstringThe concommand name.
  • argstableargs[1], optionally an EntIndex to target another player.
ServerSPropProtection.ClearFriends(ply, cmd, args)Source ☍

Console command (spp_clearfriends): clears the caller's (session-only, unpersisted) friends list and resets the corresponding spp_friend_* convars.

Parameters

  • plyPlayerThe invoking player.
  • cmdstringThe concommand name.
  • argstableCommand arguments (unused).
ClientSPropProtection.ClientPanel(Panel)Source ☍

Populates the Q-menu "Client" panel with the caller's own cleanup button and friends list checkboxes.

Parameters

  • PanelPanelThe DForm/derma panel to populate.
ServerSPropProtection.Disconnect(ply)Source ☍

Schedules a delayed removal of a disconnected player's props, per spp_dpd/spp_dae/ spp_delay settings.

Parameters

  • plyPlayerThe disconnecting player.
ServerSPropProtection.DRemove(sid)Source ☍

Removes every entity currently owned by sid (used by the delayed disconnect-cleanup timer). Scans ents.Iterator() by OwnerSID rather than any owner index, so entities are collected before any are removed - ents.Iterator()'s underlying table is cached and shared, and the wiki warns against mutating things mid-iteration over it.

Parameters

  • sidstringThe owner's SteamID64/CommunityID.
ServerSPropProtection.EntityTakeDamageFireCheck(ent)Source ☍

Extinguishes an entity shortly after a blocked damage event (only reachable from the dead/commented-out EntityTakeDamage hook below).

Parameters

  • entEntityThe entity to extinguish.
ServerSPropProtection.GetFriends(ply) → Player[]Source ☍

Returns the currently online players who are on ply's friends list.

Parameters

  • plyPlayerThe player whose friends list is checked.

Returns

  1. Player[]The currently online players ply has marked as friends.
ClientSPropProtection.GetLocalFriends() → Player[]Source ☍

Returns the online players the local player has marked as friends, via the spp_friend_* client convars set from the Q-menu Client panel. Client-side friend data only exists for the local player - there's no way to ask about anyone else.

Returns

  1. Player[]The local player's online friends.
ClientSPropProtection.HUDPaint()Source ☍

Draws an "Owner: <name>" overlay near screen-centre for whatever the local player is looking at.

ServerSPropProtection.IsFriend(ply, ent) → boolean|nilSource ☍

Checks whether ply is on the friends list of ent's owner.

Parameters

  • plyPlayerThe player requesting access.
  • entEntityThe entity, whose owner's friends list is checked.

Returns

  1. boolean|nilnil if ent has no tracked owner.
ServerSPropProtection.Notify(ply, Text)Source ☍

Sends a notification to a single player (on-screen popup plus console message).

Parameters

  • plyPlayerThe recipient.
  • TextstringThe message to send.
ServerSPropProtection.NotifyAll(Text)Source ☍

Sends a notification to every connected player and logs it.

Parameters

  • TextstringThe message to broadcast.
ServerSPropProtection.OnPhysgunReload(weapon, ply) → boolean|nilSource ☍

Ownership check for physgun-reload prop removal.

Parameters

Returns

  1. boolean|nilnil abstains.
ServerSPropProtection.PhysGravGunPickup(ply, ent) → boolean|nilSource ☍

Shared ownership check for the physgun/gravgun pickup and punt events (identical logic for all three - the game event determines what the return value means).

Parameters

  • plyPlayerThe acting player.
  • entEntityThe entity being picked up/punted.

Returns

  1. boolean|nilnil abstains (defers to the caller's own default).
ServerSPropProtection.PlayerCanTouch(ply, ent) → booleanSource ☍

Core ownership check: can ply generally interact with ent (own it, be a friend of the owner, be staff with the relevant override enabled, etc). This is the check CPPICanTool/CPPICanPhysgun/CPPICanPickup/CPPICanPunt all ultimately delegate to.

Parameters

  • plyPlayerThe acting player.
  • entEntityThe entity being interacted with.

Returns

  1. boolean
ServerSPropProtection.PlayerInitialSpawn(ply)Source ☍

Initializes a spawning player's (session-only, unpersisted) friends list and admin settings, re-links OwnerObj for any props they still own from a prior session, and clears any pending disconnect-cleanup timer left over from a prior session.

Parameters

  • plyPlayerThe spawning player.
ServerSPropProtection.PlayerMakePropOwner(ply, ent) → booleanSource ☍

Assigns ownership of an entity to a player, tagging it with the networked owner fields CPPI/UI code reads (OwnerObj/Owner/OwnerSID - the owner Player, name, and SteamID respectively) and firing the CPPIAssignOwnership event. Passing nil or game.GetWorld() as ply clears ownership instead: OwnerSID is unset, Owner is set to "World", and OwnerObj is unset.

Parameters

  • plyPlayer|nilThe new owner, or nil/game.GetWorld() to clear ownership.
  • entEntityThe entity to assign.

Returns

  1. booleanFalse if ent is a player, or ply is neither nil/the world nor a valid player.
ServerSPropProtection.PlayerSpawnedSENT(ply, ent)Source ☍

Assigns ownership of a spawned SENT to its spawner.

Parameters

ServerSPropProtection.PlayerSpawnedVehicle(ply, ent)Source ☍

Tags a spawned vehicle as world-owned (vehicle-specific ownership, e.g. for the weld carve-out, is tracked separately via the "cityrp_Owner" NW key).

Parameters

ServerSPropProtection.PlayerUse(ply, ent) → boolean|nilSource ☍

function SPropProtection.EntityTakeDamage(ent, inflictor, attacker, amount, dmginfo) if(tonumber(SPropProtection.Config["edmg"]) == 0) then return end if(!ent:IsValid() or ent:IsPlayer() or !attacker:IsPlayer()) then return end if(!SPropProtection.PlayerCanTouch(attacker, ent)) then dmginfo:SetDamage(0) timer.Simple(0.1, SPropProtection.EntityTakeDamageFireCheck, ent) end end hook.Add("EntityTakeDamage", "SPropProtection.EntityTakeDamage", SPropProtection.EntityTakeDamage)

Don't need damage protection Ownership check for the "use" (+use) event.

Parameters

  • plyPlayerThe acting player.
  • entEntityThe entity being used.

Returns

  1. boolean|nilnil abstains.
ClientSPropProtection.PopulateToolMenu()Source ☍

Registers the "Simple Prop Protection" Admin/Client entries under the Utilities tool menu category.

ServerSPropProtection.RelinkOwnerObj(ply)Source ☍

Re-points OwnerObj (a direct Entity reference) at ply's new Player object for every entity ply still owns by OwnerSID. OwnerObj goes stale across a disconnect/reconnect

  • the old Player object was removed on disconnect, so it becomes an invalid entity reference - even though OwnerSID/Owner stay correct the whole time. CPPIGetOwner and several first-party consumers (sh_contextmenu.lua, sv_access.lua, propsave, etc.) read OwnerObj directly, so without this they'd treat a rejoined player's props as unowned.

Parameters

  • plyPlayerThe reconnecting player.
ServerSPropProtection.SetupSettings() → tableSource ☍

Ensures the local SQLite settings table exists.

Returns

  1. tableThe current spp_* settings row.
ClientSPropProtection.SpawnMenuOpen()Source ☍

Re-populates the Admin/Client panels (if open) whenever the spawn menu re-opens.

ServerSPropProtection.WorldOwner()Source ☍

One-time startup sweep that tags any ownerless prop_/func_ entity as world-owned.

Tables

ClientSPropProtectionSource ☍

Simple Prop Protection - client-side HUD and Q-menu panels. Originally by Spacetech (code.google.com/p/simplepropprotection).

ServerSPropProtection.FriendsSource ☍

Each connected player's friends list, keyed by SteamID64/CommunityID, valued as a hashmap of the SteamID64s they've marked as friends. Initialized on spawn and cleared on disconnect - this is in-memory only, not persisted.

ClientSPropProtection.HideOwnerClassesSource ☍

Entity classes whose owner the "Owner: X" HUD overlay must not reveal to an arbitrary onlooker - metagaming risk for things like contraband, where who placed it shouldn't be knowable without an IC reason. Add classes here; the overlay still shows for the entity's own owner, or staff phased/noclipped.

ServerSPropProtection.WeirdTracesSource ☍

Fields

ClientSPropProtection.AdminCPanelSource ☍
ClientSPropProtection.ClientCPanelSource ☍
ServerSPropProtection.ConfigSource ☍
ServerSPropProtection.KVcantoolSource ☍
ServerSPropProtection.KVcantouchSource ☍

Modification allowing mappers to add keyvalues to entites that will override settings of spp so setting spp_canuse to 2 in some entity would make it possible for everyone to use it.

Author: Sebi Keyed by Entity (weak keys, so entries are dropped once the entity is garbage-collected) rather than EntIndex - EntIndex gets reused after an entity is removed, which would otherwise leak a stale override onto whatever unrelated entity spawns at that index next.

ServerSPropProtection.KVcanuseSource ☍
ServerSPropProtection.LoggerSource ☍

A namespaced, level-filterable logger. Obtain instances via cityrp.logging.GetLogger rather than constructing directly.

ClientSPropProtection.VersionSource ☍