SlashCo Wiki

Player

Player

This contains all function that SlashCo adds on top of Garry's Mod default functions.
Garry's Mod Wiki: https://wiki.facepunch.com/gmod/Player

Methods

Player:AddEffect( string effectName, number duration )
Applies an effect to the player for the given duration, calling its EFFECT.OnApplied callback (and EFFECT.OnExpired first if the effect wasn't already active and doesn't handle EFFECT.OnRemoved).
Once the duration ends, the effect expires automatically unless another instance of the same effect is still active.
Player:AddRoundPoints( string key, number amount )
Adds a round point entry to the player under the given key, contributing to their total score shown at the end of the round.
Multiple calls with the same key stack instead of replacing each other. On the server, the added points are networked to the player.
Player:AddSpeedEffect( string key, number speed, number priority )
Registers a named speed modifier for the player and immediately recalculates their movement speed via Player:UpdateSpeed.
If multiple speed effects are active, the one with the highest priority wins.
boolean Player:CanBeSeen( )
Returns whether the player can currently be seen.
Survivors and slashers may override visibility through their active item or slasher.
Slasher visibility can also be disabled for spectators through the SLASHER.CannotBeSpectated field.
Spectators are always considered unseeable.
If no override applies, the player's Player:IsVisible state is used.
Returns whether the player can see flashlights.
Survivors and slashers may override this through their active item or slasher.
If no override applies, the player's SlashCoSeeFlashlights networked boolean is returned.
Player:ChatText( any ... )
Sends a translated chat message to this player, following the same rules as SlashCo.ChatText.
To pass a translation key that needs formatting arguments, use a table: {key, ...}.
Player:ClearEffect( string effectName )
Immediately removes a specific active effect from the player (all stacked instances of it), calling its EFFECT.OnRemoved (or EFFECT.OnExpired) callback and cancelling its expiry timer(s).
Player:ClearEffects()
Immediately removes all of the player's active effects, calling each effect's EFFECT.OnRemoved (or EFFECT.OnExpired) callback and cancelling all expiry timers.
any Player:EffectFunction( string effectName, string funcName, any ... )
Calls the given callback function (e.g. EFFECT.OnApplied, EFFECT.OnExpired, EFFECT.OnRemoved) of one of the player's active effects, forwarding any extra arguments.
Does nothing if the player doesn't have that effect active, or the effect doesn't define the callback.
table Player:FindPlayersInView( number distance, number radius, bool notrace = false )
Finds all players in a cone from our player's view and doing traces to filter for players obstructed by objects.
For slashers this respects the value of Player:GetCanSeePlayers returning an empty table if thir blind
Returns the Survivor player class's Inventory table.
This reads the class-level PLAYER.Inventory field rather than a per-player value, since the function does not use self.
string Player:GetItem( string slot )
Returns the name of the item the player currently has equipped in the given slot.
Returns the total points and number of entries the player has recorded under the given key.
Returns the round point categories the player currently has points recorded for.
Returns the player's stored slasher chance, used when picking who becomes the Slasher.
Returns the sum of the player's points across every round point category.
Returns the content the player has unlocked, as previously set with Player:SetUnlockedContent.
Player:GiveDocument( string name, number rating )
Gives the player a document with the given rating and persists it to the database.
If the player already has the document, its rating is only updated when the new rating is higher than the stored one. Networks the (updated) document to the player afterwards.
boolean Player:HasItem( string item, boolean isSecondary )
Returns whether the player has the given item equipped in the primary (or secondary) slot.
boolean Player:IsStuck( boolean worldOnly )
Checks if the player's current position is stuck inside solid geometry, by tracing their player hull at their own position.
Always returns false for spectators and players who are noclipping.
boolean Player:IsVisible( )
Returns the player's base visibility state.
This does not account for item or slasher effects.
Use Player:CanBeSeen when checking whether the player can actually be seen.
This is an alias for Player:GetVisible.
any Player:ItemFunction( string funcName, any ... )
Calls the given callback function of the player's primary item, checking their active effects first via Player:ItemFunctionInternal.
any Player:ItemFunctionInternal( string value, string slot, any ... )
This is used internally - although you're able to use it you probably shouldn't.
Internal helper used by Player:ItemFunction and Player:SecondaryItemFunction.
Calls the given callback on each of the player's active effects first; if none of them return a non-nil value, falls back to calling it on the item equipped in the given slot.
any Player:ItemFunctionOrElse( string funcName, table fallback, any ... )
Same as Player:ItemFunction, but returns the given fallback table's values (unpacked) if the callback doesn't return a truthy value.
any Player:ItemValue( string valueName, any fallback, boolean isSecondary )
Returns the value of the given field from one of the player's active effects, or from the item in the primary (or secondary) slot if no active effect defines it.
Returns fallback if neither does. Assumes a survivor-only context and doesn't check the player's team.
Player:LoadDocuments()
Loads the player's collected documents from the slashco_documents database table.
Duplicate rows for the same document are collapsed into a single entry using the highest rating found. Networks the loaded documents to the player afterwards. Called automatically on PlayerInitialSpawn.
Player:NetworkDocument( string name )
Sends a single document (with its rating) to the player over the network, or a deletion notice if the player no longer has it.
Sends all of the player's collected documents (with their ratings) to them over the network.
any Player:PerkValue( string valueName, any fallback )
Returns a value from the player's active perks.
The first active perk containing the requested value is used.
If no active perk provides the value, the fallback is returned.
Player:PlayDamageSound( number additionalRange )
Plays a random damage sound effect at the player's position using SlashCo.AudioSystem.PlaySound.
Removes all points recorded under the given key for the player.
Does nothing if the player has no round points recorded yet. On the server, the change is networked to the player.
Player:RemoveSpeedEffect( string key )
Removes a previously added named speed modifier and recalculates the player's movement speed via Player:UpdateSpeed.
Player:RevokeDocument( string name )
Removes the given document from the player, deleting it from the database and networking the deletion to them.
any Player:SecondaryItemFunction( string funcName, any ... )
Calls the given callback function of the player's secondary item, checking their active effects first via Player:ItemFunctionInternal.
any Player:SecondaryItemFunctionOrElse( string funcName, table fallback, any ... )
Same as Player:SecondaryItemFunction, but returns the given fallback table's values (unpacked) if the callback doesn't return a truthy value.
Player:SetImpervious( bool impervious )
Sets if the player is Impervious or not.
If enabled, a player will have no collisions with other players or doors.
Player:SetItem( string slot, string item )
Sets the item (or effect) the player has equipped in the given slot.
If slot is omitted, it is inferred from item's ITEM.IsSecondary field ("item2" if set, "item" otherwise); if item isn't a registered item, the call does nothing.
Throws a Lua error if slot isn't "item"/"item2", or if item isn't "none" and isn't a registered ITEM or EFFECT.
Player:SetRoundPoints( string key, number amount, number num )
Overrides the points the player has recorded under the given key, replacing any points previously added for it.
Does nothing if the player has no round points recorded yet (i.e. Player:AddRoundPoints hasn't been called before). On the server, the change is networked to the player.
Player:SetSlasherChance( number value )
Sets the player's stored slasher chance, used when picking who becomes the Slasher.
This value is tracked serverside only and must be kept in sync with the database stats.
Player:SetUnlockedContent( string value )
Sets the content the player has unlocked.
Player:SetupHands( Player spec_ply )
Overrides the base gamemode's hands setup, which creates the gmod_hands entity used to render held view models.
The override's body is currently commented out in the source, so it has no effect and the base gamemode's default SetupHands behavior is used instead. Called automatically for Survivors when they spawn.
Player:SlamDoor( Entity door )
Tries to slam the given door open
any Player:SlasherFunction( string value, any ... )
Calls a function stored on the player's current SlasherClass table, passing the player itself as the first argument.
Assumes the player is on the slasher team; no team check is performed.
Does nothing and returns nothing if the slasher table doesn't have a function under that name.
Player:SlasherHudFunc( string funcName, any ... )
Calls a function named funcName on the player's slasher HUD panel, on their client.
Internally networks the call to the owning client via SlashCo.SendValue, which doesn't support keyed tables or materials as arguments.
Returns whether the player is currently deafened, as set by Player:SlasherStunDeafen.
Player:SlasherStunDeafen( number duration )
Deafens the player for the given duration by pushing back their deafen time.
If the player is already deafened for longer than duration, this does nothing.
any Player:SlasherValue( string value, any fallback )
Returns a value from the player's current SlasherClass table.
Assumes the player is on the slasher team; no team check is performed.
If the player's slasher doesn't provide the value, the fallback is returned.
number Player:StackedItemValue( string valueName, any initialValue )
Sums the given field across every source that can affect the player: their active perks, active effects, and both item slots.
Returns initialValue if nothing contributes to the sum, otherwise the summed value clamped to a minimum of 0.1.
Player:SurvivorPing()
Creates a new Ping.
Unlike the function name suggests, this works on any player in any team. Not just survivors.
Player:TakeDamageWithEffect( number damageAmount, Entity attacker, Entity inflictor )
Plays a damage sound via Player:PlayDamageSound (its range scaled by the damage amount) and then applies damage to the player with TakeDamage.
Player:UpdateSpeed()
Recalculates and applies the player's run, walk and slow-walk speed based on the highest-priority active speed effect (see Player:AddSpeedEffect), or resets to the base speeds (300/200/100) if none are active.