Revision Difference
Entity:SetSpawnFlags#563026
<function name="SetSpawnFlags" parent="Entity" type="classfunc">⤶
<description>⤶
Sets the SpawnFlags to set of an Entity⤶
⤶
SpawnFlags can easily be found on https://developer.valvesoftware.com/wiki/.⤶
⤶
<note>See also <page>Entity:RemoveSpawnFlags</page>, <page>Entity:AddSpawnFlags</page> </note>⤶
⤶
</description>⤶
<realm>Shared</realm>⤶
⤶
<args>⤶
<arg name="flags" type="number">The SpawnFlag to remove from the Entity</arg>⤶
</args>⤶
</function>⤶
⤶
<example>⤶
<description>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.</description>⤶
<code>⤶
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 )⤶
</code>⤶
</example>