SetNPCFollowVehicle: Difference between revisions

From Onset Developer Wiki
Created page with "{{Info|Function|Server|1.0}} {{FuncDescription|__EDIT_ME__}} {{FuncSyntax|SetNPCFollowVehicle(npc, vehicle [, speed])}} {{FuncParameters}} {{FuncParam|npc|__EDIT_ME__}} {{F..."
 
No edit summary
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
{{Info|Function|Server|1.0}}
{{Info|Function|Server|1.0}}


{{FuncDescription|__EDIT_ME__}}
{{FuncDescription|Make a NPC follow the vehicle.}}


{{FuncSyntax|SetNPCFollowVehicle(npc, vehicle [, speed])}}
{{FuncSyntax|SetNPCFollowVehicle(npc, vehicle [, speed])}}


{{FuncParameters}}
{{FuncParameters}}
{{FuncParam|npc|__EDIT_ME__}}
{{FuncParam|npc|The NPC identifier.}}
{{FuncParam|vehicle |__EDIT_ME__}}
{{FuncParam|vehicle |The vehicle identifier.}}
{{FuncParamOptional|speed|__EDIT_ME__}}
{{FuncParamOptional|speed|The speed in floating point.}}


{{FuncReturnValue|__EDIT_ME__}}
{{FuncReturnValue|This function returns nothing.}}


== Example ==
== Example ==
__EDIT_ME__
<syntaxhighlight lang="Lua">
AddCommand("follow", function(player)
  local vehicle = GetPlayerVehicle(player)
 
  if (not vehicle) then
    return AddPlayerChat(player, "You must be in a vehicle!")
  end
 
  SetNPCFollowVehicle(npc, vehicle)
end)
</syntaxhighlight>


{{RelatedFunctions}}
{{RelatedFunctions}}
__EDIT_ME__
{{Template:NPCFunctions}}

Latest revision as of 14:27, 26 June 2021

SetNPCFollowVehicle

Type: Function
Context: Server
Introduced: v1.0

Description

Make a NPC follow the vehicle.

Syntax

SetNPCFollowVehicle(npc, vehicle [, speed])

Parameters

  • npc
    The NPC identifier.
  • vehicle
    The vehicle identifier.
  • speed (optional)
    The speed in floating point.

Return Value

  • This function returns nothing.

Example

AddCommand("follow", function(player)
  local vehicle = GetPlayerVehicle(player)

  if (not vehicle) then
    return AddPlayerChat(player, "You must be in a vehicle!")
  end

  SetNPCFollowVehicle(npc, vehicle)
end)

See also