Undo all fixes for IV
This commit is contained in:
@@ -217,15 +217,9 @@ function createTemporaryVehicleCommand(command, params, client) {
|
||||
let frontPos = getPosInFrontOfPos(getPlayerPosition(client), getPlayerHeading(client), getServerConfig().spawnCarDistance);
|
||||
let vehicleDataSlot = getServerData().vehicles.length;
|
||||
|
||||
let tempVehicleData = false;
|
||||
if(!isGTAIV()) {
|
||||
let vehicle = gta.createVehicle(modelId, frontPos, getPlayerHeading(client));
|
||||
addToWorld(vehicle);
|
||||
tempVehicleData = new serverClasses.vehicleData(false, vehicle);
|
||||
} else {
|
||||
triggerNetworkEvent("ag.vehicle", getClosestPlayer(frontPos), vehicleDataSlot, modelId, frontPos, getPlayerHeading(client), 133, 133, 0, false);
|
||||
tempVehicleData = new serverClasses.vehicleData(false, vehicle);
|
||||
}
|
||||
let vehicle = gta.createVehicle(modelId, frontPos, getPlayerHeading(client));
|
||||
addToWorld(vehicle);
|
||||
tempVehicleData = new serverClasses.vehicleData(false, vehicle);
|
||||
|
||||
tempVehicleData.databaseId = -1;
|
||||
|
||||
@@ -263,26 +257,30 @@ function vehicleLockCommand(command, params, client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(getPlayerVehicle(client)) {
|
||||
vehicleData = getPlayerVehicle(client);
|
||||
if(isPlayerInAnyVehicle(client)) {
|
||||
vehicle = getPlayerVehicle(client);
|
||||
if(!isPlayerInFrontVehicleSeat(client)) {
|
||||
messageClientError(client, "You need to be in the front seat!");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if(!doesClientHaveVehicleKeys(client, vehicleData)) {
|
||||
if(!doesClientHaveVehicleKeys(client, vehicle)) {
|
||||
messageClientError(client, "You don't have keys to this vehicle!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(vehicleData.locked) {
|
||||
if(getVehicleData(vehicle).locked) {
|
||||
vehicle.locked = false;
|
||||
vehicleData.locked = false;
|
||||
getVehicleData(vehicle).locked = false;
|
||||
} else {
|
||||
vehicle.locked = true;
|
||||
vehicleData.locked = true;
|
||||
getVehicleData(vehicle).locked = true;
|
||||
}
|
||||
|
||||
let lockText = (vehicleData.locked) ? "locked" : "unlocked";
|
||||
let lockText = (getVehicleData(vehicle).locked) ? "locked" : "unlocked";
|
||||
|
||||
meActionToNearbyPlayers(client, lockText + " the " + getVehicleName(vehicleData.model));
|
||||
meActionToNearbyPlayers(client, `${lockText} the ${getVehicleName(vehicle)}`);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -312,18 +310,18 @@ function vehicleLightsCommand(command, params, client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let vehicleData = getPlayerVehicle(client);
|
||||
let vehicle = getPlayerVehicle(client);
|
||||
|
||||
if(getPlayerVehicleSeat(client) > 1) {
|
||||
messageClientError(client, "You need to be in the front seat!");
|
||||
return false;
|
||||
}
|
||||
|
||||
triggerNetworkEvent("ag.veh.lights", getVehicleSyncer(vehicleData), vehicleData.syncId, lights);
|
||||
triggerNetworkEvent("ag.veh.lights", getVehicleSyncer(vehicle), getVehicleForNetworkEvent(vehicle), getVehicleData(vehicle).lights);
|
||||
|
||||
vehicleData.lights = !vehicleData.lights;
|
||||
getVehicleData(vehicle).lights = !getVehicleData(vehicle).lights;
|
||||
|
||||
meActionToNearbyPlayers(client, `turned the ${getVehicleName(vehicleData.model)}'s lights ${getOnOffFromBool(vehicleData.lights)}`);
|
||||
meActionToNearbyPlayers(client, `turned the ${getVehicleName(vehicle)}'s lights ${getOnOffFromBool(vehicle)}`);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -358,18 +356,18 @@ function vehicleEngineCommand(command, params, client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let vehicleData = getPlayerVehicle(client);
|
||||
let vehicle = getPlayerVehicle(client);
|
||||
|
||||
if(!doesClientHaveVehicleKeys(client, vehicleData)) {
|
||||
if(!doesClientHaveVehicleKeys(client, vehicle)) {
|
||||
messageClientError(client, "You don't have keys to this vehicle!");
|
||||
return false;
|
||||
}
|
||||
|
||||
vehicleData.engine = !vehicleData.engine;
|
||||
getVehicleData(vehicle).engine = !getVehicleData(vehicle).engine;
|
||||
|
||||
triggerNetworkEvent("ag.veh.engine", getVehicleSyncer(vehicleData), vehicleData.syncId, engine);
|
||||
triggerNetworkEvent("ag.veh.engine", getVehicleSyncer(vehicle), getVehicleForNetworkEvent(vehicle), getVehicleData(vehicle).engine);
|
||||
|
||||
meActionToNearbyPlayers(client, `turned the ${getVehicleName(vehicleData.model)}'s engine ${getOnOffFromBool(vehicleData.engine)}`);
|
||||
meActionToNearbyPlayers(client, `turned the ${getVehicleName(vehicle)}'s engine ${getOnOffFromBool(getVehicleData(vehicle).engine)}`);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -404,16 +402,17 @@ function vehicleSirenCommand(command, params, client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let vehicleData = getPlayerVehicle(client);
|
||||
let vehicle = getPlayerVehicle(client);
|
||||
|
||||
if(!doesClientHaveVehicleKeys(client, vehicleData)) {
|
||||
if(!doesClientHaveVehicleKeys(client, vehicle)) {
|
||||
messageClientError(client, "You don't have keys to this vehicle!");
|
||||
return false;
|
||||
}
|
||||
|
||||
vehicleData.siren = !vehicleData.siren;
|
||||
getVehicleData(vehicle).siren = !getVehicleData(vehicle).siren;
|
||||
vehicle.siren = getVehicleData(vehicle).siren;
|
||||
|
||||
meActionToNearbyPlayers(client, `turns the ${getVehicleName(vehicleData.model)}'s siren ${getOnOffFromBool(siren)}`);
|
||||
meActionToNearbyPlayers(client, `turns the ${getVehicleName(vehicle)}'s siren ${getOnOffFromBool(getVehicleData(vehicle).siren)}`);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -445,7 +444,7 @@ function setVehicleColourCommand(command, params, client) {
|
||||
|
||||
let vehicle = getPlayerVehicle(client);
|
||||
|
||||
if(!isVehicleAtPayAndSpray(vehicle)) {
|
||||
if(!isAtPayAndSpray(getVehiclePosition(vehicle))) {
|
||||
if(!doesClientHaveStaffPermission(client, getStaffFlagValue("manageVehicles"))) {
|
||||
messageClientError(client, "You need to be at a pay-n-spray!");
|
||||
return false;
|
||||
@@ -460,17 +459,12 @@ function setVehicleColourCommand(command, params, client) {
|
||||
let splitParams = params.split(" ");
|
||||
let colour1 = toInteger(splitParams[0]) || 0;
|
||||
let colour2 = toInteger(splitParams[1]) || 0;
|
||||
|
||||
|
||||
getClientCurrentSubAccount(client).cash -= getServerConfig().resprayVehicleCost;
|
||||
if(server.game == GAME_GTA_IV) {
|
||||
triggerNetworkEvent("ag.veh.colour", getVehicleData(vehicle).syncedBy, getVehicleData(vehicle).syncId, colour1, colour2)
|
||||
} else {
|
||||
vehicle.colour1 = colour1;
|
||||
vehicle.colour2 = colour2;
|
||||
getVehicleData(vehicle).colour1 = colour1;
|
||||
getVehicleData(vehicle).colour2 = colour1;
|
||||
}
|
||||
vehicle.colour1 = colour1;
|
||||
vehicle.colour2 = colour2;
|
||||
getVehicleData(vehicle).colour1 = colour1;
|
||||
getVehicleData(vehicle).colour2 = colour1;
|
||||
|
||||
meActionToNearbyPlayers(client, `resprays the ${getVehicleName(vehicle)}'s colours`);
|
||||
}
|
||||
@@ -502,9 +496,9 @@ function vehicleRepairCommand(command, params, client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let vehicleData = getPlayerVehicle(client);
|
||||
let vehicle = getPlayerVehicle(client);
|
||||
|
||||
if(!isAtPayAndSpray(vehicleData.syncPosition)) {
|
||||
if(!isAtPayAndSpray(getVehiclePosition(vehicle))) {
|
||||
if(!doesClientHaveStaffPermission(client, getStaffFlagValue("manageVehicles"))) {
|
||||
messageClientError(client, "You need to be at a pay-n-spray!");
|
||||
return false;
|
||||
@@ -518,9 +512,9 @@ function vehicleRepairCommand(command, params, client) {
|
||||
|
||||
|
||||
getClientCurrentSubAccount(client).cash -= getServerConfig().repairVehicleCost;
|
||||
repairVehicle(vehicleData);
|
||||
repairVehicle(vehicle);
|
||||
|
||||
meActionToNearbyPlayers(client, `repairs the ${getVehicleName(vehicleData.model)}!`);
|
||||
meActionToNearbyPlayers(client, `repairs the ${getVehicleName(vehicle)}!`);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -550,25 +544,22 @@ function buyVehicleCommand(command, params, client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let vehicleData = getPlayerVehicle(client);
|
||||
let vehicle = getPlayerVehicle(client);
|
||||
|
||||
if(!isAtPayAndSpray(vehicleData.syncPosition)) {
|
||||
if(!doesClientHaveStaffPermission(client, getStaffFlagValue("manageVehicles"))) {
|
||||
messageClientError(client, "You need to be at a pay-n-spray!");
|
||||
return false;
|
||||
}
|
||||
if(getVehicleData(vehicle).buyPrice <= 0) {
|
||||
messageClientError(client, `This ${getVehicleName(vehicle)} is not for sale!`);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(getClientCurrentSubAccount(client).cash < vehicleData.buyPrice) {
|
||||
messageClientError(client, `You don't have enough money to buy this vehicle (need $${vehicleData.buyPrice-getClientCurrentSubAccount(client).cash} more!)`);
|
||||
messageClientError(client, `You don't have enough money to buy this vehicle (need $${getVehicleData(vehicle).buyPrice-getClientCurrentSubAccount(client).cash} more!)`);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
getClientCurrentSubAccount(client).cash -= vehicleData.buyPrice;
|
||||
getClientCurrentSubAccount(client).cash -= getVehicleData(vehicle).buyPrice;
|
||||
setVehicleOwner(AG_VEHOWNER_PLAYER, getClientCurrentSubAccount(client).databaseId);
|
||||
|
||||
meActionToNearbyPlayers(client, `buys the ${getVehicleName(vehicleData.model)} and receives a set of vehicle keys!`);
|
||||
meActionToNearbyPlayers(client, `buys the ${getVehicleName(vehicle)} and receives a set of vehicle keys!`);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -598,14 +589,19 @@ function rentVehicleCommand(command, params, client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let vehicleData = getPlayerVehicle(client);
|
||||
let vehicle = getPlayerVehicle(client);
|
||||
|
||||
vehicleData.rentedBy = client;
|
||||
getClientCurrentSubAccount(client).rentingVehicle = vehicleData;
|
||||
vehicleData.rentStart = new Date().getTime();
|
||||
if(getVehicleData(vehicle).rentPrice <= 0) {
|
||||
messageClientError(client, `This ${getVehicleName(vehicle)} is not for rent!`);
|
||||
return false;
|
||||
}
|
||||
|
||||
getVehicleData(vehicle).rentedBy = client;
|
||||
getClientCurrentSubAccount(client).rentingVehicle = vehicle;
|
||||
getVehicleData(vehicle).rentStart = new Date().getTime();
|
||||
|
||||
meActionToNearbyPlayers(client, `rents the ${getVehicleName(vehicleData.model)} and receives a set of vehicle keys!`);
|
||||
messageClientAlert(client, `You will be charged ${vehicleData.rentPrice} per minute to use this vehicle. To stop renting this vehicle, use /vehrent again.`);
|
||||
meActionToNearbyPlayers(client, `rents the ${getVehicleName(vehicle)} and receives a set of vehicle keys!`);
|
||||
messageClientAlert(client, `You will be charged ${getVehicleData(vehicle).rentPrice} per minute to use this vehicle. To stop renting this vehicle, use /vehrent again.`);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -631,15 +627,17 @@ function stopRentingVehicleCommand(command, params, client) {
|
||||
}
|
||||
|
||||
//getClientCurrentSubAccount(client).cash -= getVehicleData(vehicle).rentPrice;
|
||||
let vehicleData = getClientCurrentSubAccount(client).rentingVehicle;
|
||||
let vehicle = getClientCurrentSubAccount(client).rentingVehicle;
|
||||
stopRentingVehicle(client);
|
||||
|
||||
messageClientAlert(client, `You are no longer renting the ${getVehicleName(vehicleData.model)}`);
|
||||
messageClientAlert(client, `You are no longer renting the ${getVehicleName(vehicle)}`);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function doesClientHaveVehicleKeys(client, vehicleData) {
|
||||
function doesClientHaveVehicleKeys(client, vehicle) {
|
||||
let vehicleData = getVehicleData(vehicle);
|
||||
|
||||
if(doesClientHaveStaffPermission(client, getStaffFlagValue("manageVehicles"))) {
|
||||
return true;
|
||||
}
|
||||
@@ -681,7 +679,9 @@ function doesClientHaveVehicleKeys(client, vehicleData) {
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function doesClientOwnVehicle(client, vehicleData) {
|
||||
function doesClientOwnVehicle(client, vehicle) {
|
||||
let vehicleData = getVehicleData(vehicle);
|
||||
|
||||
if(doesClientHaveStaffPermission(client, getStaffFlagValue("manageVehicles"))) {
|
||||
return true;
|
||||
}
|
||||
@@ -736,7 +736,7 @@ function setVehicleJobCommand(command, params, client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let vehicleData = getPlayerVehicle(client);
|
||||
let vehicle = getPlayerVehicle(client);
|
||||
|
||||
let closestJobLocation = getClosestJobLocation(getVehiclePosition(vehicleData));
|
||||
let jobId = closestJobLocation.job;
|
||||
@@ -751,10 +751,10 @@ function setVehicleJobCommand(command, params, client) {
|
||||
// return false;
|
||||
//}
|
||||
|
||||
vehicleData.ownerType = AG_VEHOWNER_JOB;
|
||||
vehicleData.ownerId = jobId;
|
||||
getVehicleData(vehicle).ownerType = AG_VEHOWNER_JOB;
|
||||
getVehicleData(vehicle).ownerId = jobId;
|
||||
|
||||
messageClientSuccess(client, `You set the ${getVehicleName(vehicleData.model)}'s owner to the ${getJobData(jobId).name} job! (ID ${jobId})`);
|
||||
messageClientSuccess(client, `You set the ${getVehicleName(vehicle)}'s owner to the ${getJobData(jobId).name} job! (ID ${jobId})`);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -784,7 +784,7 @@ function setVehicleClanCommand(command, params, client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let vehicleData = getPlayerVehicle(client);
|
||||
let vehicle = getPlayerVehicle(client);
|
||||
let clan = getClanFromParams(params);
|
||||
|
||||
if(!clan) {
|
||||
@@ -792,10 +792,10 @@ function setVehicleClanCommand(command, params, client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
vehicleData.ownerType = AG_VEHOWNER_CLAN;
|
||||
vehicleData.ownerId = clan.databaseId;
|
||||
getVehicleData(vehicle).ownerType = AG_VEHOWNER_CLAN;
|
||||
getVehicleData(vehicle).ownerId = clan.databaseId;
|
||||
|
||||
messageClientSuccess(client, `You set the ${getVehicleName(vehicleData.model)}'s owner to the ${clan.name} clan!`);
|
||||
messageClientSuccess(client, `You set the ${getVehicleName(vehicle)}'s owner to the ${clan.name} clan!`);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -825,7 +825,7 @@ function setVehicleOwnerCommand(command, params, client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let vehicleData = getPlayerVehicle(client);
|
||||
let vehicle = getPlayerVehicle(client);
|
||||
let targetClient = getClientFromParams(params);
|
||||
|
||||
if(!targetClient) {
|
||||
@@ -833,10 +833,10 @@ function setVehicleOwnerCommand(command, params, client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
vehicleData.ownerType = AG_VEHOWNER_PLAYER;
|
||||
vehicleData.ownerId = getClientCurrentSubAccount(client).databaseId;
|
||||
getVehicleData(vehicle).ownerType = AG_VEHOWNER_PLAYER;
|
||||
getVehicleData(vehicle).ownerId = getClientCurrentSubAccount(client).databaseId;
|
||||
|
||||
messageClientSuccess(client, `You set the ${getVehicleName(vehicleData.model)}'s owner to ${getClientSubAccountName(client)}!`);
|
||||
messageClientSuccess(client, `You set the ${getVehicleName(vehicle)}'s owner to ${getClientSubAccountName(client)}!`);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -866,9 +866,9 @@ function setVehicleRentPriceCommand(command, params, client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let vehicleData = getPlayerVehicle(client);
|
||||
let vehicle = getPlayerVehicle(client);
|
||||
|
||||
if(!doesClientOwnVehicle(client, vehicleData)) {
|
||||
if(!doesClientOwnVehicle(client, vehicle)) {
|
||||
if(!doesClientHaveStaffPermission(client, getStaffFlagValue("manageVehicles"))) {
|
||||
messageClientError(client, "You can't set the rent price for this vehicle!");
|
||||
}
|
||||
@@ -876,9 +876,9 @@ function setVehicleRentPriceCommand(command, params, client) {
|
||||
|
||||
let amount = toInteger(params) || 0;
|
||||
|
||||
vehicleData.rentPrice = amount;
|
||||
getVehicleData(vehicle).rentPrice = amount;
|
||||
|
||||
messageClientSuccess(client, `You set the ${getVehicleName(vehicleData.model)}'s rent price to $${amount}!`);
|
||||
messageClientSuccess(client, `You set the ${getVehicleName(vehicle)}'s rent price to $${amount}!`);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -908,9 +908,9 @@ function setVehicleBuyPriceCommand(command, params, client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let vehicleData = getPlayerVehicle(client);
|
||||
let vehicle = getPlayerVehicle(client);
|
||||
|
||||
if(!doesClientOwnVehicle(client, vehicleData)) {
|
||||
if(!doesClientOwnVehicle(client, vehicle)) {
|
||||
if(!doesClientHaveStaffPermission(client, getStaffFlagValue("manageVehicles"))) {
|
||||
messageClientError(client, "You can't set the buy price for this vehicle!");
|
||||
}
|
||||
@@ -918,9 +918,9 @@ function setVehicleBuyPriceCommand(command, params, client) {
|
||||
|
||||
let amount = toInteger(params) || 0;
|
||||
|
||||
vehicleData.buyPrice = amount;
|
||||
getVehicleData(vehicle).buyPrice = amount;
|
||||
|
||||
messageClientSuccess(client, `You set the ${getVehicleName(vehicleData.model)}'s buy price to $${amount}!`);
|
||||
messageClientSuccess(client, `You set the ${getVehicleName(vehicle)}'s buy price to $${amount}!`);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -950,7 +950,7 @@ function removeVehicleOwnerCommand(command, params, client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let vehicleData = getPlayerVehicle(client);
|
||||
let vehicle = getPlayerVehicle(client);
|
||||
let targetClient = getClientFromParams(params);
|
||||
|
||||
if(!targetClient) {
|
||||
@@ -958,10 +958,10 @@ function removeVehicleOwnerCommand(command, params, client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
vehicleData.ownerType = AG_VEHOWNER_NONE;
|
||||
vehicleData.ownerId = 0;
|
||||
getVehicleData(vehicle).ownerType = AG_VEHOWNER_NONE;
|
||||
getVehicleData(vehicle).ownerId = 0;
|
||||
|
||||
messageClientSuccess(client, `You set the ${getVehicleName(vehicleData.model)}'s owner to nobody!`);
|
||||
messageClientSuccess(client, `You set the ${getVehicleName(vehicle)}'s owner to nobody!`);
|
||||
messageClientInfo(client, `Nobody will be able to use this vehicle until it receives a new owner (either bought or set by admin).`);
|
||||
}
|
||||
|
||||
@@ -992,10 +992,12 @@ function getVehicleInfoCommand(command, params, client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let vehicleData = getPlayerVehicle(client);
|
||||
let vehicle = getPlayerVehicle(client);
|
||||
let vehicleData = getVehicleData(vehicle);
|
||||
|
||||
let ownerName = "Nobody";
|
||||
let ownerType = "None";
|
||||
ownerType = toLowerCase(getVehicleOwnerTypeText(vehicleData.ownerType));
|
||||
switch(vehicleData.ownerType) {
|
||||
case AG_VEHOWNER_CLAN:
|
||||
ownerName = getClanData(vehicleData.ownerId).name;
|
||||
@@ -1022,41 +1024,6 @@ function getVehicleInfoCommand(command, params, client) {
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function parkVehicleCommand(command, params, client) {
|
||||
if(getCommand(command).requireLogin) {
|
||||
if(!isClientLoggedIn(client)) {
|
||||
messageClientError(client, "You must be logged in to use this command!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(isClientFromDiscord(client)) {
|
||||
if(!isCommandAllowedOnDiscord(command)) {
|
||||
messageClientError(client, "That command isn't available on discord!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
|
||||
messageClientError(client, "You do not have permission to use this command!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!isPlayerInAnyVehicle(client)) {
|
||||
messageClientError(client, "You need to be in a vehicle!");
|
||||
return false;
|
||||
}
|
||||
|
||||
let vehicleData = getPlayerVehicle(client);
|
||||
|
||||
getVehicleData(vehicle).spawnPosition = getVehiclePosition(vehicleData);
|
||||
getVehicleData(vehicle).spawnRotation = getVehicleHeading(vehicleData);
|
||||
|
||||
messageClientInfo(client, `This vehicle will now spawn here.`);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function toggleVehicleSpawnLockCommand(command, params, client) {
|
||||
if(getCommand(command).requireLogin) {
|
||||
if(!isClientLoggedIn(client)) {
|
||||
@@ -1082,16 +1049,17 @@ function toggleVehicleSpawnLockCommand(command, params, client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let vehicleData = getPlayerVehicle(client);
|
||||
let vehicle = getPlayerVehicle(client);
|
||||
|
||||
let spawnLocked = vehicleData.spawnLocked;
|
||||
vehicleData.spawnLocked = !spawnLocked;
|
||||
let spawnLocked = getVehicleData(vehicle).spawnLocked;
|
||||
getVehicleData(vehicle).spawnLocked = !spawnLocked;
|
||||
if(spawnLocked) {
|
||||
vehicleData.spawnPosition = getVehiclePosition(vehicleData);
|
||||
vehicleData.spawnRotation = getVehicleHeading(vehicleData);
|
||||
}
|
||||
getVehicleData(vehicle).spawnPosition = getVehiclePosition(vehicle);
|
||||
getVehicleData(vehicle).spawnRotation = getVehicleHeading(vehicle);
|
||||
getVehicleData(vehicle).spawnLocked = spawnLocked;
|
||||
}
|
||||
|
||||
messageClientInfo(client, `This vehicle will now spawn ${(spawnLocked) ? "here" : "wherever a player leaves it."}`);
|
||||
messageClientInfo(client, `This ${getVehicleName(vehicle)} will now spawn ${(spawnLocked) ? "here" : "wherever a player leaves it."}`);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -1109,7 +1077,7 @@ function reloadAllVehiclesCommand(command, params, client) {
|
||||
messageClientError(client, "That command isn't available on discord!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) {
|
||||
messageClientError(client, "You do not have permission to use this command!");
|
||||
@@ -1118,7 +1086,7 @@ function reloadAllVehiclesCommand(command, params, client) {
|
||||
|
||||
for(let i in getServerData().vehicles) {
|
||||
if(getServerData().vehicles[i].vehicle) {
|
||||
destroyElement(getServerData().vehicles[i].vehicle);
|
||||
deleteGameElement(getServerData().vehicles[i].vehicle);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1153,7 +1121,7 @@ function respawnAllVehiclesCommand(command, params, client) {
|
||||
|
||||
for(let i in getServerData().vehicles) {
|
||||
if(getServerData().vehicles[i].vehicle) {
|
||||
destroyElement(getServerData().vehicles[i].vehicle);
|
||||
deleteGameElement(getServerData().vehicles[i].vehicle);
|
||||
getServerData().vehicles[i].vehicle = null;
|
||||
}
|
||||
}
|
||||
@@ -1165,37 +1133,6 @@ function respawnAllVehiclesCommand(command, params, client) {
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function sendAllVehiclesToClient(client) {
|
||||
/*
|
||||
let tempVehicles = [];
|
||||
for(let i in getServerData().vehicles) {
|
||||
let thisVehicle = getServerData().vehicles[i];
|
||||
|
||||
tempVehicles.push({
|
||||
model: thisVehicle.model,
|
||||
spawnPosition: thisVehicle.spawnPosition,
|
||||
spawnHeading: thisVehicle.spawnHeading,
|
||||
colours: [thisVehicle.colour1, thisVehicle.colour2, thisVehicle.colour3, thisVehicle.colour4],
|
||||
locked: thisVehicle.locked,
|
||||
});
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function getVehicleDataFromIVSyncId(syncId) {
|
||||
for(let i in getServerData().vehicles) {
|
||||
if(getServerData().vehicles[i].ivSyncId != -1) {
|
||||
if(getServerData().vehicles[i].ivSyncId == syncId) {
|
||||
return getServerData().vehicles[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function stopRentingVehicle(client) {
|
||||
let vehicleData = getClientData(client).rentingVehicle;
|
||||
getClientData(client).rentingVehicle = false;
|
||||
@@ -1209,14 +1146,10 @@ function respawnVehicle(vehicleData) {
|
||||
let vehicles = getServerData().vehicles;
|
||||
for(let i in vehicles) {
|
||||
if(vehicleData == vehicles[i]) {
|
||||
if(!isGTAIV()) {
|
||||
destroyElement(vehicle);
|
||||
let vehicle = spawnVehicle(vehicles[i]);
|
||||
vehicles[i].vehicle = vehicle;
|
||||
setEntityData(vehicle, "ag.dataSlot", i, false);
|
||||
} else {
|
||||
triggerNetworkEvent("ag.vehicle", getClosestPlayer(vehicleData.spawnPosition), i, vehicleData.model, vehicleData.spawnPosition, vehicleData.spawnRotation, vehicleData.colour1, vehicleData.colour2, vehicleData.locked, vehicleData.lights);
|
||||
}
|
||||
destroyElement(vehicle);
|
||||
let vehicle = spawnVehicle(vehicles[i]);
|
||||
vehicles[i].vehicle = vehicle;
|
||||
setEntityData(vehicle, "ag.dataSlot", i, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1224,10 +1157,6 @@ function respawnVehicle(vehicleData) {
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function spawnVehicle(vehicleData) {
|
||||
if(isGTAIV()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let vehicle = gta.createVehicle(vehicleData.model, vehicleData.spawnPosition, vehicleData.spawnRotation);
|
||||
addToWorld(vehicle);
|
||||
|
||||
@@ -1248,9 +1177,8 @@ function spawnVehicle(vehicleData) {
|
||||
vehicle.heading = vehicleData.spawnRotation;
|
||||
|
||||
vehicle.locked = intToBool(vehicleData.locked);
|
||||
setEntityData(vehicle, "ag.siren", intToBool(vehicleData.siren), true);
|
||||
setEntityData(vehicle, "ag.engine", intToBool(vehicleData.engine), true);
|
||||
setEntityData(vehicle, "ag.lights", intToBool(vehicleData.lights), true);
|
||||
|
||||
vehicleData.vehicle = vehicle;
|
||||
|
||||
return vehicle;
|
||||
}
|
||||
@@ -1258,8 +1186,8 @@ function spawnVehicle(vehicleData) {
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function isVehicleAtPayAndSpray(vehicle) {
|
||||
for(let i in getServerData().payAndSprays[server.game]) {
|
||||
if(vehicle.position.distance(getServerData().payAndSprays[server.game][i].position) <= getServerConfig().payAndSprayDistance) {
|
||||
for(let i in getServerData().payAndSprays[getServerGame()]) {
|
||||
if(getDistance(getVehiclePosition(vehicle), getServerData().payAndSprays[getServerGame()][i].position) <= getServerConfig().payAndSprayDistance) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1269,69 +1197,50 @@ function isVehicleAtPayAndSpray(vehicle) {
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function repairVehicle(vehicleData) {
|
||||
if(isGTAIV()) {
|
||||
triggerNetworkEvent("ag.veh.fix", vehicleData.syncedBy, vehicleData.syncId);
|
||||
} else {
|
||||
vehicleData.vehicle.fix();
|
||||
}
|
||||
vehicleData.vehicle.fix();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function setVehicleColours(vehicleData, colour1, colour2) {
|
||||
if(isGTAIV()) {
|
||||
triggerNetworkEvent("ag.veh.colour", vehicleData.syncedBy, vehicleData.syncId, colour1, colour2);
|
||||
} else {
|
||||
vehicleData.vehicle.colour1 = colour1;
|
||||
vehicleData.vehicle.colour2 = colour2;
|
||||
}
|
||||
function setVehicleColours(vehicle, colour1, colour2) {
|
||||
vehicle.colour1 = colour1;
|
||||
vehicle.colour2 = colour2;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function setVehicleLights(vehicleData, lights) {
|
||||
if(isGTAIV()) {
|
||||
triggerNetworkEvent("ag.veh.lights", vehicleData.syncedBy, vehicleData.syncId, lights);
|
||||
} else {
|
||||
triggerNetworkEvent("ag.veh.lights", null, vehicleData.vehicle, lights);
|
||||
}
|
||||
function setVehicleLights(vehicle, lights) {
|
||||
vehicle.lights = lights;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function setVehicleEngine(vehicleData, engine) {
|
||||
if(isGTAIV()) {
|
||||
triggerNetworkEvent("ag.veh.engine", vehicleData.syncedBy, vehicleData.syncId, engine);
|
||||
} else {
|
||||
triggerNetworkEvent("ag.veh.engine", null, vehicleData.vehicle, engine);
|
||||
}
|
||||
function setVehicleEngine(vehicle, engine) {
|
||||
vehicle.engine = engine;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function setVehicleLocked(vehicleData, locked) {
|
||||
if(isGTAIV()) {
|
||||
triggerNetworkEvent("ag.veh.locked", vehicleData.syncedBy, vehicleData.syncId, locked);
|
||||
} else {
|
||||
triggerNetworkEvent("ag.veh.locked", null, vehicleData.vehicle, locked);
|
||||
}
|
||||
function setVehicleLocked(vehicle, locked) {
|
||||
vehicle.locked = locked;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
function getVehicleDataFromSyncId(syncId) {
|
||||
let vehicles = getServerData().vehicles;
|
||||
for(let i in vehicles) {
|
||||
if(vehicles[i].syncId == syncId) {
|
||||
return vehicles[i];
|
||||
}
|
||||
}
|
||||
function getVehicleOwnerTypeText(ownerType) {
|
||||
switch(ownerType) {
|
||||
case AG_VEHOWNER_CLAN:
|
||||
return "clan";
|
||||
|
||||
return false;
|
||||
case AG_VEHOWNER_JOB:
|
||||
return "job";
|
||||
|
||||
case AG_VEHOWNER_PLAYER:
|
||||
return "player";
|
||||
|
||||
default:
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
function transferVehicleSyncToAnotherClient(vehicleData) {
|
||||
let closestClient = getClosestPlayer(vehicleData.syncPosition);
|
||||
}
|
||||
// ----------------------------------------------------------------------------
|
||||
Reference in New Issue
Block a user