natives.taskCarMissionPedTarget

From GTA Connected
Revision as of 10:28, 6 July 2021 by MexTest1 (talk | contribs) (page created; including Javascript example)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


Function Client Only icon-iv.png Online and Offline

Available since Client 1.0.0

void natives.taskCarMissionPedTarget(Ped ped, Vehicle vehicle, Ped target, int driveFlag, float driveSpeed, int driveStyle, int stopDist, int chaseDist)

The natives.taskCarMissionPedTarget function is used to make the vehicle follow the target using internal game path data.

Parameters

1) Ped ped The Ped to drive the Vehicle.
2) Vehicle vehicle The Vehicle to drive with.
3) Ped target The targetPed to chase after.
4) int driveFlag The AI driving/chasing behavior to use. (0-13, see details below).
5) float driveSpeed The speed of driving in meters per second. (default = 20).
6) int driveStyle The AI driving style (behavior) to use. (0-7, see details below).
7) int stopDist Special distance flag #1, depending on selected driveFlag; vehicle may stop within.
8) int chaseDist Special distance flag #2, depending on selected driveFlag; direct chase mode within.

Return

void This function doesn't return a value.

Notes

  • direct chase mode = cut corners; no braking before intersections; ignore obstacles; follow target directly;.

Examples

Example 1 - JavaScript - Client-Side:

// find a random char inside a vehicle function getPedInVehicle() { // array of all peds (includes localPlayer) let allPeds = getPeds();

// loop thru peds array for (let i=0; i < allPeds.length; i++) { // filter by peds in vehicles if (allPeds[i] != localPlayer && allPeds[i].isInVehicle) { return allPeds[i]; } }

return null; }

/* example code provided by DrFauli */ addCommandHandler("chasetarget", function(cmdName, params) { // find a random char inside a vehicle let thisPed = getPedInVehicle(); if (thisPed == null) return false;

let driveSpeed = 25; let driveFlag = 6; // 6 = chase after target (player) and stay on throttle let driveStyle = 2 // ignore traffic lights; drive around peds and cars let stopDist = 10; // dist behavior flag 1 (stop within) let chaseDist = 25; // dist behavior flag 2 (chase within)

// prevent ped from leaving the car screaming by marking it as mission_char first natives.setCharAsMissionChar(thisPed, true); natives.setCharStayInCarWhenJacked(thisPed, true); natives.setCharInvincible(thisPed, true); natives.clearCharTasks(thisPed);

// let ped follow player and crash into him (driveFlag: 6) // [syntax]: PedHandle, CarHandle, TargetCharHandle, flag, speed, style, stopDist, chaseDist natives.taskCarMissionPedTarget(thisPed, thisPed.vehicle, localPlayer, driveFlag, driveSpeed, driveStyle, stopDist, chaseDist);

// add a blip to make the ped more visible to the player natives.addBlipForChar(thisPed);

return true; });

Compatibility

There isn't any compatibility information for this function.

Related

Client Related

icon-iii.png icon-vc.png icon-sa.png gta.cancelMission
icon-iii.png icon-vc.png icon-sa.png gta.onMission
icon-iii.png icon-vc.png icon-sa.png gta.startMission

driving flag behavior

behavior ramming overtaking stopDist chaseDist
0 follow target from behind (+braking) stay behind not used direct chase within
1 drive wander ignore target ignore target not used not used
2 follow target from behind (+braking) stay behind not used direct chase within
3 follow target from sides overtake then stop not used direct chase within
4 follow target none overtake then stop stop within (forever) direct chase within
5 do nothing / / / /
6 follow target from behind (+full throttle) stay behind (+full throttle) not used direct chase within
7 follow target none stay behind stop within direct chase within
8 drive wander ignore target ignore target not used not used
9 follow target none circle around then stop distance left side distance right side
10 follow target none drive parallel (left) not used parallel within
11 follow target none drive parallel (right) not used parallel within
12 follow target none drive parallel (rear) not used parallel within
13 follow target none drive parallel (front) not used parallel within

driving flag notes

  • all flags will follow the selected driveStyle (parameter 6)
  • driveStyle will be ignored within radius of chaseDist(direct chase mode)
  • flag 0 and 2 seem to be identical.
  • flag 1 and 8 seem to be identical.

driving style behavior

traffic lights other cars pedestrians blinkers when stuck
0 ignore drive around drive around not used reverse
1 stop on red stay behind stop and honk used on intersections wait
2 ignore drive around drive around not used reverse
3 ignore ignore ignore not used reverse
4 ignore stay behind stop and honk not used wait
5 stop on red drive around drive around not used reverse
6 stop+reversing drive around drive around not used reverse
7 stop on red stay behind stop and honk used on intersections wait

driving style notes

  • driving styles 0 and 2 seem to be identical.
  • driving styles 1 and 7 seem to be identical.