ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Shared functions
  3. setPedFocus

Function

setPedFocus

Server and clientPedsTrilogy Hub only

Makes an NPC keep looking at a chosen element: the ped turns its whole body toward it, optionally its head too, and follows it as it moves. On the server everyone sees it. On the client it only works in this game and overrides the server's setting; nil brings back what the server set. Useful for shopkeepers, guards and NPCs in cutscenes.

Syntax

bool setPedFocus(ped ped, element target [, bool head = true])

Arguments

pedped
An NPC (a ped element).
targetelement
The element to look at (player, vehicle, object...), other than the NPC itself. nil = stop.
headbool, optional = true
true = also turns the head, false = body only.

Returns

true on success.

Example

addEventHandler("onPlayerJoin", root, function()
    setPedFocus(shopkeeper, source, true)
end)

See also