Add nearby vehicles cmd

This commit is contained in:
Vortrex
2022-01-21 20:34:00 -06:00
parent 5691e9e1db
commit b828d5e598

View File

@@ -255,6 +255,27 @@ function createTemporaryVehicleCommand(command, params, client) {
// ===========================================================================
function getNearbyVehiclesCommand(command, params, client) {
let distance = getParam(params, " ", 1) || 10.0;
let nearbyVehicles = getElementsByTypeInRange(ELEMENT_VEHICLE, getPlayerPosition, distance);
if(nearbyVehicles.length == 0) {
messagePlayerAlert(client, getLocaleString(client, "NoVehiclesWithinRange", distance));
return false;
}
let vehiclesList = getServerData().radioStations.map(function(x) { return `{ALTCOLOUR}${getVehicleData(x).index}: {MAINCOLOUR}${getVehicleName(x)} {darkGrey}(${getDistance(getPlayerPosition(client), getVehiclePosition(x))} ${getLocaleString(client, "Meters")} ${getGroupedLocaleString(client, "CardinalDirections")[getCardinalDirection(getPlayerPosition(client), getVehiclePosition(x))]}})`; });
let chunkedList = splitArrayIntoChunks(vehiclesList, 4);
messagePlayerNormal(client, makeChatBoxSectionHeader(getLocaleString(client, "HeaderVehiclesInRangeList")));
for(let i in chunkedList) {
messagePlayerInfo(client, chunkedList[i].join(", "));
}
}
// ===========================================================================
function vehicleLockCommand(command, params, client) {
let vehicle = getClosestVehicle(getPlayerPosition(client));