NPC.StopMoving

From GMod Wiki

Jump to: navigation, search
Function
Syntax NPC:StopMoving( )
Description:
Order an NPC to stop moving.
Returns: nil
In Object: Npc
Realm: NewerServer.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=NPC.StopMoving]NPC.StopMoving [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionCreates an npc_kleiner you can order to move or stop.
Used onNewerServer.png
Code
function makeKleiner(ply)
	kleiner = ents.Create("npc_kleiner") // Creating the npc.
	kleiner:SetPos(ply:GetEyeTrace().HitPos) // setting it's position where the player is looking at.
	kleiner:Spawn() // Spawning it.
end
concommand.Add("makeKleiner", makeKleiner ) // Linking the concommand makeKleiner to the function of the same name.
 
function moveKleiner(ply)
	kleiner:SetLastPosition( util.QuickTrace( ply:GetShootPos(), ply:GetAimVector()*1000 ).HitPos ) // Giving the previously spawned NPC a target.
	kleiner:SetSchedule( SCHED_FORCED_GO ) // Ordering him to reach it.
end
concommand.Add("moveKleiner", moveKleiner )
 
function stopKleiner()
	kleiner:StopMoving() // Ordering him to stop moving.
end
concommand.Add("stopKleiner", stopKleiner )
OutputN/A
Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox