Organize a lot of utils

This commit is contained in:
Vortrex
2022-01-09 17:19:53 -06:00
parent 2684ffae7d
commit 5dfe47a3e8
16 changed files with 905 additions and 1069 deletions

View File

@@ -2083,4 +2083,44 @@ function setAllJobIndexes() {
}
}
}
}
}
// ===========================================================================
function getJobFromParams(params) {
if(isNaN(params)) {
for(let i in getServerData().jobs) {
if(toLowerCase(getServerData().jobs[i].name).indexOf(toLowerCase(params)) != -1) {
return i;
}
}
} else {
if(typeof getServerData().jobs[params] != "undefined") {
return params;
}
}
return false;
}
// ===========================================================================
function getClosestJobLocation(position) {
let closestJobLocation = false;
for(let i in getServerData().jobs) {
for(let j in getServerData().jobs[i].locations) {
if(!closestJobLocation || getServerData().jobs[i].locations[j].position.distance(position) < closestJobLocation.position.distance(position)) {
closestJobLocation = getServerData().jobs[i].locations[j];
}
}
}
return closestJobLocation;
}
// ===========================================================================
function getJobPointsInRange(position, distance) {
return getServerData().jobs[getServerGame()].filter(x => x.position.distance(position) <= distance);
}
// ===========================================================================