200 lines
6.8 KiB
JavaScript
Executable File
200 lines
6.8 KiB
JavaScript
Executable File
$(document).ready(function () {
|
|
setTimeout(function () {
|
|
ADis_Check_Call_Police_Active();
|
|
}, 500);
|
|
});
|
|
|
|
function ADis_Check_Call_Police_Active() {
|
|
if ($('#h2_prisoners').length > 0) {
|
|
ADis_Collect_Jails();
|
|
} else {
|
|
ADis_RemovePoliceSprechwunschFromQueue(MissionID).then((deleteCount) => {
|
|
$("#adis-sprechwunsch-police-frame").attr("src", "");
|
|
$("#adis-sprechwunsch-police-frame").attr("mission_id", "empty");
|
|
});
|
|
}
|
|
}
|
|
|
|
// Gefängnis auswählen
|
|
function ADis_Collect_Jails() {
|
|
var CountGefangene = Number(parseInt($('#h2_prisoners').text()));
|
|
var parentNode = $('#mission_vehicle_at_mission tr > td:nth-child(5) > a:contains("Jomaar")').parent().parent();
|
|
var GefKw = parentNode.find('td:nth-child(2) > a[vehicle_type_id="52"]');
|
|
var FuStW = parentNode.find('td:nth-child(2) > a[vehicle_type_id="32"]');
|
|
var GefKwGefaegnisse = $(GefKw[0]).parent().parent().next('tr');
|
|
var FuStWGefaegnisse = $(FuStW[0]).parent().parent().next('tr');
|
|
|
|
GefKwGefaegnisse.find("a:contains('Freie Zellen')").each(function () {
|
|
var JailHref = $(this).attr("href");
|
|
var JailID = JailHref.split("/").pop();
|
|
var JailText = $(this).text();
|
|
var JailFreeBeds = 0;
|
|
var JailDistance = 0;
|
|
var JailTax = 0;
|
|
let m;
|
|
while ((m = JailRegEx.exec(JailText)) !== null) {
|
|
// This is necessary to avoid infinite loops with zero-width matches
|
|
if (m.index === JailRegEx.lastIndex) {
|
|
JailRegEx.lastIndex++;
|
|
}
|
|
|
|
// The result can be accessed through the `m`-variable.
|
|
m.forEach((match, groupIndex) => {
|
|
if (groupIndex == 1) {
|
|
JailFreeBeds = parseInt(match.trim());
|
|
} else if (groupIndex == 2) {
|
|
JailDistance = parseInt(match.trim());
|
|
} else if (groupIndex == 3 && typeof match != "undefined") {
|
|
JailTax = parseInt(match.trim());
|
|
}
|
|
});
|
|
}
|
|
|
|
var JailValue = JailDistance * 450 * -1;
|
|
JailValue += 11; //GefKw bevorzugt
|
|
|
|
if (JailTax == 0) {
|
|
JailValue += 10000;
|
|
} else if (JailTax > 0 && JailTax <= 10) {
|
|
JailValue += 5000;
|
|
} else if (JailTax > 10 && JailTax <= 20) {
|
|
JailValue += 1000;
|
|
} else {
|
|
JailValue -= 10000;
|
|
}
|
|
|
|
if (JailFreeBeds >= 5) {
|
|
JailValue += 15000;
|
|
} else if (JailFreeBeds >= 1) {
|
|
JailValue += 1000;
|
|
} else {
|
|
JailValue -= 5000;
|
|
}
|
|
|
|
if (JailFreeBeds >= 5) {
|
|
Jails.push({
|
|
"id": JailID,
|
|
"value": JailValue + 1000,
|
|
"text": JailText,
|
|
"distance": JailDistance,
|
|
"href": JailHref
|
|
});
|
|
} else if (JailFreeBeds >= 1) {
|
|
Jails.push({
|
|
"id": JailID,
|
|
"value": JailValue,
|
|
"text": JailText,
|
|
"distance": JailDistance,
|
|
"href": JailHref
|
|
});
|
|
}
|
|
});
|
|
FuStWGefaegnisse.find("a:contains('Freie Zellen')").each(function () {
|
|
var JailHref = $(this).attr("href");
|
|
var JailID = JailHref.split("/").pop();
|
|
var JailText = $(this).text();
|
|
var JailFreeBeds = 0;
|
|
var JailDistance = 0;
|
|
var JailTax = 0;
|
|
let m;
|
|
while ((m = JailRegEx.exec(JailText)) !== null) {
|
|
// This is necessary to avoid infinite loops with zero-width matches
|
|
if (m.index === JailRegEx.lastIndex) {
|
|
JailRegEx.lastIndex++;
|
|
}
|
|
|
|
// The result can be accessed through the `m`-variable.
|
|
m.forEach((match, groupIndex) => {
|
|
if (groupIndex == 1) {
|
|
JailFreeBeds = parseInt(match.trim());
|
|
} else if (groupIndex == 2) {
|
|
JailDistance = parseInt(match.trim());
|
|
} else if (groupIndex == 3 && typeof match != "undefined") {
|
|
JailTax = parseInt(match.trim());
|
|
}
|
|
});
|
|
}
|
|
|
|
var JailValue = JailDistance * 450 * -1;
|
|
|
|
if (JailTax == 0) {
|
|
JailValue += 10000;
|
|
} else if (JailTax > 0 && JailTax <= 10) {
|
|
JailValue += 5000;
|
|
} else if (JailTax > 10 && JailTax <= 20) {
|
|
JailValue += 1000;
|
|
} else {
|
|
JailValue -= 10000;
|
|
}
|
|
|
|
if (JailFreeBeds >= 5) {
|
|
JailValue += 15000;
|
|
} else if (JailFreeBeds >= 1) {
|
|
JailValue += 1000;
|
|
} else {
|
|
JailValue -= 5000;
|
|
}
|
|
|
|
if (JailFreeBeds >= CountGefangene) {
|
|
Jails.push({
|
|
"id": JailID,
|
|
"value": JailValue + 1000,
|
|
"text": JailText,
|
|
"distance": JailDistance,
|
|
"href": JailHref
|
|
});
|
|
} else if (JailFreeBeds >= 1) {
|
|
Jails.push({
|
|
"id": JailID,
|
|
"value": JailValue,
|
|
"text": JailText,
|
|
"distance": JailDistance,
|
|
"href": JailHref
|
|
});
|
|
}
|
|
});
|
|
|
|
Jails.sort(function (a, b) {
|
|
return a.value - b.value;
|
|
});
|
|
|
|
Jails.reverse();
|
|
if (Jails.length > 0) {
|
|
ADis_Send_Vehicle_To_Jail()
|
|
} else {
|
|
$("#mission_vehicle_driving tbody, #mission_vehicle_at_mission tbody").find("tr").each(function () {
|
|
var CalledVehicleID = parseInt($(this).find("a").first().attr("vehicle_type_id"));
|
|
if (CalledVehicleID == 52) {
|
|
CountGefangene -= 5;
|
|
} else if (CalledVehicleID == 32) {
|
|
CountGefangene -= 1;
|
|
}
|
|
});
|
|
|
|
if ($('#vehicle_show_table_all tr[vehicle_type="GefKw"] input[type="checkbox"]').size() > 0 && CountGefangene >= 5) {
|
|
$('#vehicle_show_table_all tr[vehicle_type="GefKw"] input[type="checkbox"]').each(function () {
|
|
if (CountGefangene > 0) {
|
|
$(this).click()
|
|
CountGefangene -= 5;
|
|
}
|
|
});
|
|
}
|
|
if ($('#vehicle_show_table_all tr[vehicle_type="FuStW"] input[type="checkbox"]').size() > 0 && CountGefangene > 0) {
|
|
$('#vehicle_show_table_all tr[vehicle_type="FuStW"] input[type="checkbox"]').each(function () {
|
|
if (CountGefangene > 0) {
|
|
$(this).click()
|
|
CountGefangene -= 1;
|
|
}
|
|
});
|
|
}
|
|
if ($('#vehicle_show_table_all input[type="checkbox"]:checked').size() > 0) {
|
|
$('#mission_alarm_btn').click();
|
|
}
|
|
}
|
|
}
|
|
|
|
// Gefängnis einlieferung
|
|
function ADis_Send_Vehicle_To_Jail() {
|
|
var JailHref = Jails[0].href
|
|
document.location.href = document.location.origin + JailHref;
|
|
} |