Garry's Mod Wiki

Revision Difference

NPC:SetMovementActivity#517648

<function name="SetMovementActivity" parent="NPC" type="classfunc"> <description>Sets the activity the NPC uses when it moves.</description> <realm>Server</realm> <args> <arg name="activity" type="number">The movement activity, see &lt;page&gt;ACT&lt;/page&gt;.</arg> <arg name="activity" type="number">The movement activity, see <page>ACT</page>.</arg> </args> </function> <example> <description>Makes all NPCs walk instead of run.</description> <code> function GM:Think() for _, npc in pairs(ents.FindByClass("npc_*")) do if(IsValid(npc) &amp;&amp; npc:IsNPC() &amp;&amp; npc:GetMovementActivity() != ACT_WALK) then if(IsValid(npc) && npc:IsNPC() && npc:GetMovementActivity() != ACT_WALK) then npc:SetMovementActivity(ACT_WALK) end end end </code> </example>