Custom weather array
This commit is contained in:
@@ -387,7 +387,7 @@ function applyConfigToServer(tempServerConfig) {
|
|||||||
|
|
||||||
if (isWeatherSupported()) {
|
if (isWeatherSupported()) {
|
||||||
logToConsole(LOG_DEBUG, `[AGRP.Config]: Setting weather to ${tempServerConfig.weather}`);
|
logToConsole(LOG_DEBUG, `[AGRP.Config]: Setting weather to ${tempServerConfig.weather}`);
|
||||||
game.forceWeather(tempServerConfig.weather);
|
game.forceWeather(getWeatherData(tempServerConfig.weather).weatherId);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateServerRules();
|
updateServerRules();
|
||||||
@@ -583,19 +583,19 @@ function setWeatherCommand(command, params, client) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let weatherId = getWeatherFromParams(getParam(params, " ", 1));
|
let weatherIndex = getWeatherFromParams(getParam(params, " ", 1));
|
||||||
|
|
||||||
if (!weatherId) {
|
if (!getWeatherData(weatherIndex)) {
|
||||||
messagePlayerError(client, `That weather ID or name is invalid!`);
|
messagePlayerError(client, `That weather ID or name is invalid!`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
game.forceWeather(toInteger(weatherId));
|
game.forceWeather(getWeatherData(weatherIndex).weatherId);
|
||||||
getServerConfig().weather = weatherId;
|
getServerConfig().weather = weatherIndex;
|
||||||
|
|
||||||
getServerConfig().needsSaved = true;
|
getServerConfig().needsSaved = true;
|
||||||
|
|
||||||
announceAdminAction("ServerWeatherSet", getPlayerName(client), getGameConfig().weatherNames[getGame()][toInteger(weatherId)]);
|
announceAdminAction("ServerWeatherSet", getPlayerName(client), getWeatherData(weatherIndex).name);
|
||||||
updateServerRules();
|
updateServerRules();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,11 +134,18 @@ function thirtyMinuteTimerFunction() {
|
|||||||
checkPayDays();
|
checkPayDays();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkInactiveVehicleRespawns();
|
||||||
|
|
||||||
if (isGameFeatureSupported("snow")) {
|
if (isGameFeatureSupported("snow")) {
|
||||||
checkSnowChance();
|
setSnowWithChance();
|
||||||
}
|
}
|
||||||
|
|
||||||
checkInactiveVehicleRespawns();
|
if (isGameFeatureSupported("weather")) {
|
||||||
|
setRandomWeather();
|
||||||
|
}
|
||||||
|
|
||||||
|
updateServerRules();
|
||||||
|
|
||||||
saveServerDataToDatabase();
|
saveServerDataToDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -330,7 +337,7 @@ function checkInactiveVehicleRespawns() {
|
|||||||
if (getVehicleData(vehicles[i]).lastActiveTime != false) {
|
if (getVehicleData(vehicles[i]).lastActiveTime != false) {
|
||||||
if (getCurrentUnixTimestamp() - getVehicleData(vehicles[i]).lastActiveTime >= getGlobalConfig().vehicleInactiveRespawnDelay) {
|
if (getCurrentUnixTimestamp() - getVehicleData(vehicles[i]).lastActiveTime >= getGlobalConfig().vehicleInactiveRespawnDelay) {
|
||||||
respawnVehicle(vehicles[i]);
|
respawnVehicle(vehicles[i]);
|
||||||
getVehicleData(vehicles[i]).lastActiveTime = false;
|
//getVehicleData(vehicles[i]).lastActiveTime = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -342,13 +349,31 @@ function checkInactiveVehicleRespawns() {
|
|||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function checkSnowChance() {
|
function setSnowWithChance() {
|
||||||
let date = new Date();
|
let date = new Date();
|
||||||
|
|
||||||
let shouldBeSnowing = getRandomBoolWithProbability(getGlobalConfig().monthlyChanceOfSnow[date.getMonths()]);
|
let shouldBeSnowing = getRandomBoolWithProbability(getGlobalConfig().monthlyChanceOfSnow[date.getMonth()]);
|
||||||
getServerConfig().groundSnow = shouldBeSnowing;
|
getServerConfig().groundSnow = shouldBeSnowing;
|
||||||
getServerConfig().fallingSnow = shouldBeSnowing;
|
getServerConfig().fallingSnow = shouldBeSnowing;
|
||||||
|
|
||||||
updatePlayerSnowState(null);
|
updatePlayerSnowState(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
function setRandomWeather() {
|
||||||
|
let randomWeatherIndex = getRandom(0, getGameConfig().weather[getGame()].length - 1);
|
||||||
|
|
||||||
|
if (getServerConfig().fallingSnow == true) {
|
||||||
|
while (getWeatherData(randomWeatherIndex).allowWithSnow == false) {
|
||||||
|
randomWeatherIndex = getRandom(0, getGameConfig().weather[getGame()].length - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
game.forceWeather(getWeatherData(weatherIndex).weatherId);
|
||||||
|
getServerConfig().weather = weatherIndex;
|
||||||
|
|
||||||
|
getServerConfig().needsSaved = true;
|
||||||
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
@@ -101,8 +101,8 @@ function updateServerRules() {
|
|||||||
|
|
||||||
if (isWeatherSupported()) {
|
if (isWeatherSupported()) {
|
||||||
if (getServerConfig() != false) {
|
if (getServerConfig() != false) {
|
||||||
if (typeof getGameConfig().weatherNames[getGame()] != "undefined") {
|
if (getWeatherData(getServerConfig().weather) != false) {
|
||||||
let tempText = getGameConfig().weatherNames[getGame()][getServerConfig().weather];
|
let tempText = getWeatherData(getServerConfig().weather).name;
|
||||||
timeWeatherRule.push(tempText);
|
timeWeatherRule.push(tempText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -124,14 +124,16 @@ function updateServerRules() {
|
|||||||
|
|
||||||
function getWeatherFromParams(params) {
|
function getWeatherFromParams(params) {
|
||||||
if (isNaN(params)) {
|
if (isNaN(params)) {
|
||||||
for (let i in getGameConfig().weatherNames[getGame()]) {
|
for (let i in getGameConfig().weather[getGame()]) {
|
||||||
if (toLowerCase(getGameConfig().weatherNames[getGame()][i]).indexOf(toLowerCase(params)) != -1) {
|
if (toLowerCase(getGameConfig().weather[getGame()][i].name).indexOf(toLowerCase(params)) != -1) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (typeof getGameConfig().weatherNames[getGame()][params] != "undefined") {
|
for (let i in getGameConfig().weather[getGame()]) {
|
||||||
return toInteger(params);
|
if (typeof getGameConfig().weather[getGame()][i].weatherId != "undefined") {
|
||||||
|
return toInteger(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,16 @@ class AnimationData {
|
|||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
|
class WeatherData {
|
||||||
|
constructor(weatherId, name, allowWithSnow) {
|
||||||
|
this.weatherId = weatherId;
|
||||||
|
this.name = name;
|
||||||
|
this.allowWithSnow = allowWithSnow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
let supportedFeatures = {
|
let supportedFeatures = {
|
||||||
// Invalid, GTAIII, GTAVC, GTASA, Invalid, GTAIV, Invalid, Invalid, Invalid, M1, M2, M3, M1DE
|
// Invalid, GTAIII, GTAVC, GTASA, Invalid, GTAIV, Invalid, Invalid, Invalid, M1, M2, M3, M1DE
|
||||||
time: {
|
time: {
|
||||||
@@ -563,77 +573,79 @@ let gameData = {
|
|||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
weatherNames: {
|
weather: {
|
||||||
[AGRP_GAME_GTA_III]: [ // GTA III
|
[AGRP_GAME_GTA_III]: [ // GTA III
|
||||||
"Clear",
|
new WeatherData(0, "Clear", true),
|
||||||
"Overcast",
|
new WeatherData(1, "Overcast", false),
|
||||||
"Thunderstorm",
|
new WeatherData(2, "Thunderstorm", false),
|
||||||
"Fog",
|
new WeatherData(3, "Fog", true),
|
||||||
"Clear",
|
new WeatherData(4, "Clear", false),
|
||||||
"Rainy",
|
new WeatherData(5, "Rainy", false),
|
||||||
"Dark/Cloudy",
|
new WeatherData(6, "Dark/Cloudy", false),
|
||||||
"Light/Cloudy",
|
new WeatherData(7, "Light/Cloudy", false),
|
||||||
"Overcast/Cloudy",
|
new WeatherData(8, "Overcast/Cloudy", true),
|
||||||
"Grey/Cloudy"
|
new WeatherData(9, "Grey/Cloudy", false),
|
||||||
],
|
],
|
||||||
[AGRP_GAME_GTA_VC]: [ // GTA Vice City
|
[AGRP_GAME_GTA_VC]: [ // GTA Vice City
|
||||||
"Partly Cloudy",
|
new WeatherData(0, "Clear", true),
|
||||||
"Overcast",
|
new WeatherData(1, "Overcast", false),
|
||||||
"Thunderstorm",
|
new WeatherData(2, "Thunderstorm", false),
|
||||||
"Fog",
|
new WeatherData(3, "Fog", true),
|
||||||
"Sunny",
|
new WeatherData(4, "Sunny", false),
|
||||||
"Hurricane",
|
new WeatherData(5, "Hurricane", false),
|
||||||
"Dark/Cloudy",
|
new WeatherData(6, "Dark/Cloudy", false),
|
||||||
"Light/Cloudy",
|
new WeatherData(7, "Light/Cloudy", false),
|
||||||
"Overcast/Cloudy",
|
new WeatherData(8, "Overcast/Cloudy", true),
|
||||||
"Grey/Cloudy"
|
new WeatherData(9, "Grey/Cloudy", false),
|
||||||
],
|
],
|
||||||
[AGRP_GAME_GTA_SA]: [ // GTA San Andreas
|
[AGRP_GAME_GTA_SA]: [ // GTA San Andreas
|
||||||
"Blue Skies",
|
new WeatherData(0, "Blue Skies", false),
|
||||||
"Blue Skies",
|
new WeatherData(1, "Blue Skies", false),
|
||||||
"Blue Skies",
|
new WeatherData(2, "Blue Skies", false),
|
||||||
"Blue Skies",
|
new WeatherData(3, "Blue Skies", false),
|
||||||
"Blue Skies",
|
new WeatherData(4, "Blue Skies", false),
|
||||||
"Blue Skies",
|
new WeatherData(5, "Blue Skies", false),
|
||||||
"Blue Skies",
|
new WeatherData(6, "Blue Skies", false),
|
||||||
"Blue Skies",
|
new WeatherData(7, "Blue Skies", false),
|
||||||
"Thunderstorm",
|
new WeatherData(8, "Thunderstorm", false),
|
||||||
"Cloudy/Foggy",
|
new WeatherData(9, "Cloudy/Foggy", false),
|
||||||
"Clear Blue Skies",
|
new WeatherData(10, "Clear Blue Skies", false),
|
||||||
"Heatwave",
|
new WeatherData(11, "Heatwave", false),
|
||||||
"Dull/Colorless",
|
new WeatherData(12, "Dull/Colorless", false),
|
||||||
"Dull/Colorless",
|
new WeatherData(13, "Dull/Colorless", false),
|
||||||
"Dull/Colorless",
|
new WeatherData(14, "Dull/Colorless", false),
|
||||||
"Dull/Colorless",
|
new WeatherData(15, "Dull/Colorless", false),
|
||||||
"Dull/Rainy",
|
new WeatherData(16, "Dull/Rainy", false),
|
||||||
"Heatwave",
|
new WeatherData(17, "Heatwave", false),
|
||||||
"Heatwave",
|
new WeatherData(18, "Heatwave", false),
|
||||||
"Sandstorm",
|
new WeatherData(19, "Sandstorm", false),
|
||||||
"Greenish/Foggy"
|
new WeatherData(20, "Greenish/Foggy", false),
|
||||||
],
|
],
|
||||||
[AGRP_GAME_GTA_IV]: [ // GTA IV
|
[AGRP_GAME_GTA_IV]: [ // GTA IV
|
||||||
"Extra Sunny",
|
new WeatherData(1, "Blue Skies", false),
|
||||||
"Sunny",
|
new WeatherData(2, "Extra Sunny", false),
|
||||||
"Sunny/Windy",
|
new WeatherData(3, "Sunny", false),
|
||||||
"Cloudy",
|
new WeatherData(4, "Sunny/Windy", false),
|
||||||
"Rain",
|
new WeatherData(5, "Cloudy", false),
|
||||||
"Light Rain",
|
new WeatherData(6, "Rain", false),
|
||||||
"Foggy",
|
new WeatherData(7, "Light Rain", false),
|
||||||
"Thunderstorm",
|
new WeatherData(8, "Foggy", false),
|
||||||
"Extra Sunny",
|
new WeatherData(9, "Thunderstorm", false),
|
||||||
"Sunny/Windy",
|
new WeatherData(10, "Extra Sunny", false),
|
||||||
|
new WeatherData(11, "Sunny/Windy", false),
|
||||||
],
|
],
|
||||||
[AGRP_GAME_GTA_IV_EFLC]: [ // GTA IV EFLC
|
[AGRP_GAME_GTA_IV_EFLC]: [ // GTA IV EFLC
|
||||||
"Extra Sunny",
|
new WeatherData(1, "Blue Skies", false),
|
||||||
"Sunny",
|
new WeatherData(2, "Extra Sunny", false),
|
||||||
"Sunny/Windy",
|
new WeatherData(3, "Sunny", false),
|
||||||
"Cloudy",
|
new WeatherData(4, "Sunny/Windy", false),
|
||||||
"Rain",
|
new WeatherData(5, "Cloudy", false),
|
||||||
"Light Rain",
|
new WeatherData(6, "Rain", false),
|
||||||
"Foggy",
|
new WeatherData(7, "Light Rain", false),
|
||||||
"Thunderstorm",
|
new WeatherData(8, "Foggy", false),
|
||||||
"Extra Sunny",
|
new WeatherData(9, "Thunderstorm", false),
|
||||||
"Sunny/Windy",
|
new WeatherData(10, "Extra Sunny", false),
|
||||||
|
new WeatherData(11, "Sunny/Windy", false),
|
||||||
],
|
],
|
||||||
[AGRP_GAME_GTA_V]: [
|
[AGRP_GAME_GTA_V]: [
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user