Garry's Mod Wiki

Revision Difference

Entity:AddSpawnFlags#563023

<function name="AddSpawnFlags" parent="Entity" type="classfunc">⤶ <description>⤶ Adds onto the current SpawnFlags of an Entity.⤶ SpawnFlags can easily be found on https://developer.valvesoftware.com/wiki/.⤶ ⤶ </description>⤶ <realm>Shared</realm>⤶ ⤶ <args>⤶ <arg name="flag" type="number" default="nil">The SpawnFlag to add to the Entity</arg>⤶ </args>⤶ </function>⤶ ⤶ <example>⤶ <description>When a turret Entity is created, it adds the `Out of Ammo` SpawnFlag, therefore it doesn't have ammo.</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⤶ ⤶ ent:AddSpawnFlags(256) -- https://developer.valvesoftware.com/wiki/Npc_turret_floor#Flags⤶ end )⤶ end )⤶ </code>⤶ </example>