local function LimitReachedProcess( ply, str )
// Always allow in single player
if (SinglePlayer()) then return true end
local c = server_settings.Int( "sbox_max"..str, 0 )
if ply:Admin() or ply:IsSuperAdmin() then
return true
end
if ( ply:GetCount( str ) < c || c < 0 ) then return true end
ply:LimitHit( str )
return false
end
local function init()
/*---------------------------------------------------------
Name: gamemode:PlayerSpawnRagdoll( ply, model )
Desc: Return true if it's allowed
---------------------------------------------------------*/
function GAMEMODE:PlayerSpawnRagdoll( ply, model )
return LimitReachedProcess( ply, "ragdolls" )
end
/*---------------------------------------------------------
Name: gamemode:PlayerSpawnProp( ply, model )
Desc: Return true if it's allowed
---------------------------------------------------------*/
function GAMEMODE:PlayerSpawnProp( ply, model )
return LimitReachedProcess( ply, "props" )
end
/*---------------------------------------------------------
Name: gamemode:PlayerSpawnEffect( ply, model )
Desc: Return true if it's allowed
---------------------------------------------------------*/
function GAMEMODE:PlayerSpawnEffect( ply, model )
return LimitReachedProcess( ply, "effects" )
end
/*---------------------------------------------------------
Name: gamemode:PlayerSpawnVehicle( ply )
Desc: Return true if it's allowed
---------------------------------------------------------*/
function GAMEMODE:PlayerSpawnVehicle( ply )
return LimitReachedProcess( ply, "vehicles" )
end
/*---------------------------------------------------------
Name: gamemode:PlayerSpawnSENT( ply, name )
Desc: Return true if player is allowed to spawn the SENT
---------------------------------------------------------*/
function GAMEMODE:PlayerSpawnSENT( ply, name )
return LimitReachedProcess( ply, "sents" )
end
/*---------------------------------------------------------
Name: gamemode:PlayerSpawnNPC( ply, npc_type )
Desc: Return true if player is allowed to spawn the NPC
---------------------------------------------------------*/
function GAMEMODE:PlayerSpawnNPC( ply, npc_type, equipment )
return LimitReachedProcess( ply, "npcs" )
end
local meta = FindMetaTable( "Player" )
// Return if there's nothing to add on to
if (!meta) then return end
function meta:CheckLimit( str )
// No limits in single player
if (SinglePlayer()) then return true end
local c = server_settings.Int( "sbox_max"..str, 0 )
if self:IsAdmin() or self:IsSuperAdmin() then
return true
end
if ( c < 0 ) then return true end
if ( self:GetCount( str ) > c-1 ) then self:LimitHit( str ) return false end
return true
end
end
hook.Add( "Initialize", "LimitInitilize", init )