Garry's Mod Wiki

Entity:SetSpawnFlags

  Entity:SetSpawnFlags( number flags )

Recently Added

This was recently added in version (2024.12.04). It might only be available on the Dev Branch right now.

Description

Sets the SpawnFlags to set of an Entity

SpawnFlags can easily be found on https://developer.valvesoftware.com/wiki/.

Arguments

1 number flags
The SpawnFlag to remove from the Entity

Example

When a turret Entity is created, if it doesn't have the SpawnFlags Out of Ammo and Fast Retire, then it sets it's SpawnFlags to just them two.

hook.Add( "OnEntityCreated", "AddSpawnFlagsExample", function( ent ) timer.Simple( 0.1, function() if ( !IsValid(ent) or ent:GetClass() != "npc_turret_floor" ) then return end if ( !ent:HasSpawnFlags(256) and !ent:HasSpawnFlags(128) ) then return end ent:SetSpawnFlags(256 + 128) -- https://developer.valvesoftware.com/wiki/Npc_turret_floor#Flags end ) end )