Client/Natives/IV/taskCarDriveWander: Difference between revisions
Jump to navigation
Jump to search
(Created page with "{{DISPLAYTITLE:natives.taskCarDriveWander}} void natives.taskCarDriveWander(Ped ped, Vehicle veh, float driveSpeed, int driveStyle) ==parameters== *parameter1 = The Ped to d...") |
(No difference)
|
Revision as of 21:30, 2 July 2021
void natives.taskCarDriveWander(Ped ped, Vehicle veh, float driveSpeed, int driveStyle)
parameters
- parameter1 = The Ped to drive the Vehicle.
- parameter2 = The Vehicle to drive with.
- parameter3 = The speed of driving in meters per second. (default = 20)
- parameter4 = The AI driving style (behavior) to use. (0-7)
used for
Make the vehicle randomly drive around using internal game path data.
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 crossings | 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 crossings | 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 light poles (objects) while evading.
example code (javascript)
/* example code provided by DrFauli */ addCommandHandler("drivestyle", function(cmdName, params) { // current vehicle/ped handle let thisVeh = null; let thisPed = null; // check if player is in a car if (!localPlayer.vehicle) { natives.requestModel(-1685021548) // sabre GT natives.requestModel(1424670436); // french tom natives.loadAllObjectsNow(); // spawn the car thisVeh = createVehicle2(-1685021548, localPlayer.position, true); thisVeh.heading = localPlayer.heading; // spawn the driver thisPed = natives.createCharInsideCar(thisVeh, 1, 1424670436); // prevent ped from leaving the car screaming by marking it as mission_char first natives.setCharAsMissionChar(thisPed, true); natives.setCharStayInCarWhenJacked(thisPed, true); // warp player into passenger seat natives.warpCharIntoCarAsPassenger(localPlayer, thisVeh, 0); } else { thisVeh = localPlayer.vehicle; thisPed = thisVeh.getOccupant(0); } // get speed and driveStyle from params let splitParams = params.split(" "); let driveSpeed = (Number(splitParams[0]) || 20); // default is 20 let driveStyle = (Number(splitParams[1]) || 2); // let this car drive around natives.taskCarDriveWander(thisPed, thisVeh, driveSpeed, driveStyle); return true; });