Garry's Mod Wiki

GM:PlayerCheckLimit

  boolean GM:PlayerCheckLimit( Player ply, string limitName, number current, number defaultMax )

Description

Called whenever a player is about to spawn something to see if they hit a limit for whatever they are spawning.

This hook will not be called in singleplayer, as singleplayer does not have limits.

Arguments

1 Player ply
The player who is trying to spawn something.
2 string limitName
The limit's name.
3 number current
The amount of whatever player is trying to spawn that the player already has spawned.
4 number defaultMax
The default maximum count, as dictated by the sbox_max<limitName> convar on the server. This is the amount that will be used if nothing is returned from this hook.

Returns

1 boolean
Return false to indicate the limit was hit, or nothing otherwise

Example

Having multiple PlayerCheckLimit hooks that return values WILL conflict

Removes prop spawn limit for admins.

hook.Add("PlayerCheckLimit", "no_admin_limits", function(ply, name, cur, max) if name == "props" and ply:IsAdmin() then return true end end)

Example

Doubles prop spawn limit for admins.

hook.Add("PlayerCheckLimit", "admin_double_limits", function(ply, name, cur, max) if name == "props" and ply:IsAdmin() then if cur >= max*2 then return false end return true end end)