bigmap timer rein

This commit is contained in:
Luke
2021-05-09 20:31:02 +02:00
parent 3e4dd82194
commit b5ceb0d4a7

View File

@@ -1,7 +1,7 @@
import { GlobalData } from ".."; import { GlobalData } from "..";
export default function bigmap() { export default function bigmap() {
let bigMapEnabled = false; var bigmap = { enabled: false, timer: null };
mp.game.ui.setRadarZoom(0.0); mp.game.ui.setRadarZoom(0.0);
mp.game.ui.setRadarBigmapEnabled(false, false); mp.game.ui.setRadarBigmapEnabled(false, false);
@@ -9,14 +9,26 @@ export default function bigmap() {
mp.events.add("render", () => { mp.events.add("render", () => {
mp.game.controls.disableControlAction(0, 48, true); mp.game.controls.disableControlAction(0, 48, true);
if (mp.game.controls.isDisabledControlJustPressed(0, 48) && !GlobalData.InChat) { if (mp.game.controls.isDisabledControlJustPressed(0, 48) && !GlobalData.InChat) {
if (!bigMapEnabled) { if (bigmap.timer != null) {
clearTimeout(bigmap.timer);
bigmap.timer = null;
}
if (!bigmap.enabled) {
mp.game.ui.setRadarBigmapEnabled(true, false); mp.game.ui.setRadarBigmapEnabled(true, false);
mp.game.ui.setRadarZoom(1.0); mp.game.ui.setRadarZoom(1.0);
bigMapEnabled = true; bigmap.enabled = true;
bigmap.timer = setTimeout(() => {
mp.game.ui.setRadarBigmapEnabled(false, false);
mp.game.ui.setRadarZoom(0.0);
bigmap.enabled = false;
bigmap.timer = null;
}, 5000);
} else { } else {
mp.game.ui.setRadarBigmapEnabled(false, false); mp.game.ui.setRadarBigmapEnabled(false, false);
mp.game.ui.setRadarZoom(0.0); mp.game.ui.setRadarZoom(0.0);
bigMapEnabled = false; bigmap.enabled = false;
} }
} }
}); });