Use local vars + save veh/biz/house radio

This commit is contained in:
Vortrex
2022-05-03 12:06:59 -05:00
parent 98ed89a497
commit 970b007cf9

View File

@@ -63,13 +63,16 @@ function playStreamingRadioCommand(command, params, client) {
} }
if(isPlayerInAnyVehicle(client)) { if(isPlayerInAnyVehicle(client)) {
if(!getVehicleData(getPlayerVehicle(client))) { let vehicle = getPlayerVehicle(client);
if(!getVehicleData(vehicle)) {
messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled")); messagePlayerError(client, getLocaleString(client, "RandomVehicleCommandsDisabled"));
return false; return false;
} }
if(radioStationId == 0) { if(radioStationId == 0) {
getVehicleData(getPlayerVehicle(client)).streamingRadioStation = -1; getVehicleData(vehicle).streamingRadioStation = -1;
getVehicleData(vehicle).needsSaved = true;
getPlayerData(client).streamingRadioStation = -1; getPlayerData(client).streamingRadioStation = -1;
meActionToNearbyPlayers(client, `turns off their vehicle's radio`); meActionToNearbyPlayers(client, `turns off their vehicle's radio`);
@@ -82,13 +85,13 @@ function playStreamingRadioCommand(command, params, client) {
return false; return false;
} }
getVehicleData(getPlayerVehicle(client)).streamingRadioStation = radioStationId-1; getVehicleData(vehicle).streamingRadioStation = radioStationId-1;
getPlayerData(client).streamingRadioStation = radioStationId-1; getPlayerData(client).streamingRadioStation = radioStationId-1;
meActionToNearbyPlayers(client, getLocaleString(client, "ActionVehicleRadioStationChange", getRadioStationData(radioStationId-1).name, getRadioStationData(radioStationId-1).genre)); meActionToNearbyPlayers(client, getLocaleString(client, "ActionVehicleRadioStationChange", getRadioStationData(radioStationId-1).name, getRadioStationData(radioStationId-1).genre));
let clients = getClients(); let clients = getClients();
for(let i in clients) { for(let i in clients) {
if(getPlayerVehicle(client) == getPlayerVehicle(clients[i])) { if(vehicle == getPlayerVehicle(clients[i])) {
playRadioStreamForPlayer(clients[i], getRadioStationData(radioStationId-1).url, true, getPlayerStreamingRadioVolume(client)); playRadioStreamForPlayer(clients[i], getRadioStationData(radioStationId-1).url, true, getPlayerStreamingRadioVolume(client));
} }
} }
@@ -97,6 +100,7 @@ function playStreamingRadioCommand(command, params, client) {
let houseId = getEntityData(client, "vrr.inHouse"); let houseId = getEntityData(client, "vrr.inHouse");
if(radioStationId == 0) { if(radioStationId == 0) {
getHouseData(houseId).streamingRadioStation = -1; getHouseData(houseId).streamingRadioStation = -1;
getHouseData(houseId).needsSaved = true;
getPlayerData(client).streamingRadioStation = -1; getPlayerData(client).streamingRadioStation = -1;
meActionToNearbyPlayers(client, `turns off the house radio`); meActionToNearbyPlayers(client, `turns off the house radio`);
@@ -108,6 +112,7 @@ function playStreamingRadioCommand(command, params, client) {
} }
} else { } else {
getHouseData(houseId).streamingRadioStation = radioStationId-1; getHouseData(houseId).streamingRadioStation = radioStationId-1;
getHouseData(houseId).needsSaved = true;
getPlayerData(client).streamingRadioStation = radioStationId-1; getPlayerData(client).streamingRadioStation = radioStationId-1;
meActionToNearbyPlayers(client, getLocaleString(client, "ActionHouseRadioStationChange", getRadioStationData(radioStationId-1).name, getRadioStationData(radioStationId-1).genre)); meActionToNearbyPlayers(client, getLocaleString(client, "ActionHouseRadioStationChange", getRadioStationData(radioStationId-1).name, getRadioStationData(radioStationId-1).genre));
@@ -122,6 +127,7 @@ function playStreamingRadioCommand(command, params, client) {
let businessId = getPlayerBusiness(client); let businessId = getPlayerBusiness(client);
if(radioStationId == 0) { if(radioStationId == 0) {
getBusinessData(businessId).streamingRadioStation = -1; getBusinessData(businessId).streamingRadioStation = -1;
getBusinessData(businessId).needsSaved = true;
getPlayerData(client).streamingRadioStation = -1; getPlayerData(client).streamingRadioStation = -1;
meActionToNearbyPlayers(client, `turns off the business radio`); meActionToNearbyPlayers(client, `turns off the business radio`);
@@ -133,6 +139,7 @@ function playStreamingRadioCommand(command, params, client) {
} }
} else { } else {
getBusinessData(businessId).streamingRadioStation = radioStationId-1; getBusinessData(businessId).streamingRadioStation = radioStationId-1;
getBusinessData(businessId).needsSaved = true;
getPlayerData(client).streamingRadioStation = radioStationId-1; getPlayerData(client).streamingRadioStation = radioStationId-1;
meActionToNearbyPlayers(client, getLocaleString(client, "ActionBusinessRadioStationChange", getRadioStationData(radioStationId-1).name, getRadioStationData(radioStationId-1).genre)); meActionToNearbyPlayers(client, getLocaleString(client, "ActionBusinessRadioStationChange", getRadioStationData(radioStationId-1).name, getRadioStationData(radioStationId-1).genre));