Garry's Mod Wiki

Revision Difference

NPC:SetSchedule#510434

<function name="SetSchedule" parent="NPC" type="classfunc">⤶ <description>Sets the NPC's current schedule.</description>⤶ <realm>Server</realm>⤶ <args>⤶ <arg name="schedule" type="number">The NPC schedule, see &lt;page&gt;SCHED&lt;/page&gt;.</arg>⤶ </args>⤶ </function>⤶ ⤶ <example>⤶ <description>Function which forces an NPC to walk to an entity.</description>⤶ <code>⤶ function NPCMoveTo(npc, ent)⤶ ⤶ if(!IsValid(npc) or !IsValid(ent)) then return end⤶ ⤶ npc:SetSaveValue("m_vecLastPosition", ent:GetPos())⤶ npc:SetSchedule(SCHED_FORCED_GO)⤶ ⤶ end⤶ </code>⤶ ⤶ </example>