Client/Natives/IV/taskCarDriveWander: Difference between revisions
(used template for formatting) |
|||
Line 1: | Line 1: | ||
{{DISPLAYTITLE:natives.taskCarDriveWander}} | {{DISPLAYTITLE:natives.taskCarDriveWander}} | ||
{{ScriptItem | |||
|games = iv | |||
|type = function | |||
|name = natives.taskCarDriveWander | |||
|usage = make the vehicle randomly drive around using internal game path data. | |||
|parameters = Ped ped, Vehicle vehicle, float driveSpeed, int driveStyle | |||
|parameter1 = Ped ped The Ped to drive the Vehicle. | |||
|parameter2 = Vehicle vehicle The Vehicle to drive with. | |||
|parameter3 = float driveSpeed The speed of driving in meters per second. '''(default = 20)''' | |||
|parameter4 = int driveStyle The AI driving style (behavior) to use. (0-7, ''see details below'') | |||
|return1 = void | |||
|returnFail1 = void | |||
|exampleJSCS = /* example code provided by DrFauli */ | |||
addCommandHandler("drivestyle", function(cmdName, params) | |||
{ | |||
// current vehicle handle | |||
let thisVeh = null; | |||
// check if player is in a car | |||
if (!localPlayer.vehicle) | |||
{ | |||
natives.requestModel(-1685021548) // sabre GT | |||
natives.loadAllObjectsNow(); | |||
// spawn the car | |||
thisVeh = createVehicle2(-1685021548, localPlayer.position, true); | |||
thisVeh.heading = localPlayer.heading; | |||
// warp player into driver seat | |||
natives.taskWarpCharIntoCarAsDriver(localPlayer, thisVeh); | |||
} | |||
else | |||
{ | |||
thisVeh = localPlayer.vehicle; | |||
} | |||
== | // get speed and driveStyle from params | ||
let splitParams = params.split(" "); | |||
let driveSpeed = Number(splitParams[0]); // default is 20 | |||
let driveStyle = Number(splitParams[1]); // default is 1 (normal driving) | |||
// let the localPlayer drive around with this car | |||
natives.taskCarDriveWander(localPLayer, thisVeh, driveSpeed, driveStyle); | |||
return true; | |||
}); | |||
}} | |||
==driving style behavior== | ==driving style behavior== | ||
Line 46: | Line 83: | ||
|ignore | |ignore | ||
|not used | |not used | ||
| | |reverse | ||
|- | |- | ||
|4 | |4 | ||
Line 82: | Line 119: | ||
*using values '''< 0''' or '''> 7''' will behave like '''3''' | *using values '''< 0''' or '''> 7''' will behave like '''3''' | ||
There '''could be''' small distance and/or speed differences when "drive around" is used.<br/> | There '''could be''' small distance and/or speed differences when "drive around" is used.<br/> | ||
It is also unclear if the AI drivers are able to see light poles | It is also unclear if the AI drivers are able to see objects like light poles or traffic lights while evading. | ||
Revision as of 07:49, 3 July 2021
Function
undocumented endpoint
Online and Offline
Documentation Missing: Available since (Both server and client version is needed for shared items)
void natives.taskCarDriveWander(Ped ped, Vehicle vehicle, float driveSpeed, int driveStyle)
Parameters
1) | Ped | ped | The Ped to drive the Vehicle. |
2) | Vehicle | vehicle | The Vehicle to drive with. |
3) | float | driveSpeed | The speed of driving in meters per second. (default = 20). |
4) | int | driveStyle | The AI driving style (behavior) to use. (0-7, see details below). |
Return
void | This function doesn't return a value. |
Notes
There aren't any notes for this function.
Examples
Example 1 - JavaScript - Client-Side:
/* example code provided by DrFauli */ addCommandHandler("drivestyle", function(cmdName, params) { // current vehicle handle let thisVeh = null;
// check if player is in a car if (!localPlayer.vehicle) { natives.requestModel(-1685021548) // sabre GT natives.loadAllObjectsNow();
// spawn the car thisVeh = createVehicle2(-1685021548, localPlayer.position, true); thisVeh.heading = localPlayer.heading;
// warp player into driver seat natives.taskWarpCharIntoCarAsDriver(localPlayer, thisVeh); } else { thisVeh = localPlayer.vehicle; }
// get speed and driveStyle from params let splitParams = params.split(" "); let driveSpeed = Number(splitParams[0]); // default is 20 let driveStyle = Number(splitParams[1]); // default is 1 (normal driving)
// let the localPlayer drive around with this car natives.taskCarDriveWander(localPLayer, thisVeh, driveSpeed, driveStyle);
return true; });
Compatibility
There isn't any compatibility information for this function.
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 |
notes
- driving styles 0 and 2 seem to be identical.
- driving styles 1 and 7 seem to be identical.
- using values < 0 or > 7 will behave like 3
There could be small distance and/or speed differences when "drive around" is used.
It is also unclear if the AI drivers are able to see objects like light poles or traffic lights while evading.