Extend death-system
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
var playerName;
|
||||
var playerId;
|
||||
var playerMoney;
|
||||
var dutyMedics = 0;
|
||||
|
||||
var isDeath = false;
|
||||
var deathTime;
|
||||
@@ -16,13 +17,19 @@ var fade;
|
||||
|
||||
mp.game.gameplay.setFadeOutAfterDeath(false);
|
||||
|
||||
mp.events.add("startDeathTimer", () => {
|
||||
mp.events.add("startDeathTimer", (isAdmin) => {
|
||||
if (isDeath === false) {
|
||||
isDeath = true;
|
||||
mp.gui.chat.activate(false);
|
||||
if (isAdmin) {
|
||||
mp.gui.chat.activate(true);
|
||||
}
|
||||
else {
|
||||
mp.gui.chat.activate(false);
|
||||
}
|
||||
deathDate = new Date();
|
||||
respawnTime = Math.floor(deathDate.getTime() / 1000 + 120);
|
||||
fade = 255 - 120;
|
||||
mp.game.graphics.requestStreamedTextureDict("Mptattoos", true);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -39,21 +46,51 @@ mp.events.add("respawnDeathPlayer", () => {
|
||||
mp.events.callRemote('RespawnPlayerAtHospital');
|
||||
});
|
||||
|
||||
mp.events.add("updateDutyMedics", (count) => {
|
||||
if (count == true)
|
||||
{
|
||||
dutyMedics++;
|
||||
}
|
||||
else
|
||||
{
|
||||
dutyMedics--;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
mp.events.add("render", () => {
|
||||
currentDate = new Date();
|
||||
|
||||
if (isDeath === true) {
|
||||
|
||||
var medicString;
|
||||
if (dutyMedics > 0) {
|
||||
medicString = "Derzeit sind ~g~" + dutyMedics + " Medics ~s~im Dienst ~c~und versuchen dich wiederzubeleben...";
|
||||
} else {
|
||||
medicString = "Derzeit sind ~r~keine Medics ~s~im Dienst."
|
||||
}
|
||||
|
||||
deathSeconds = respawnTime - Math.floor(currentDate.getTime() / 1000);
|
||||
var alpha = fade + (Math.floor((currentDate.getTime() / 1000) - (deathDate.getTime() / 1000)));
|
||||
if (deathSeconds >= 0) {
|
||||
mp.game.graphics.drawText("~y~" + deathSeconds, [0.5, 0.5],
|
||||
mp.game.graphics.drawSprite("Mptattoos", "clearout", 0.625, 0.52, 0.1, 0.1, 0, 255, 255, 255, 236);
|
||||
mp.game.graphics.drawText("Respawn in: ~y~" + deathSeconds, [0.5, 0.5],
|
||||
{
|
||||
font: 7,
|
||||
color: [255, 255, 255, 255],
|
||||
scale: [0.8, 0.8],
|
||||
outline: true
|
||||
})
|
||||
mp.game.graphics.drawText(medicString, [0.5, 0.975],
|
||||
{
|
||||
font: 4,
|
||||
color: [255, 255, 255, 255],
|
||||
scale: [0.4, 0.4],
|
||||
outline: true
|
||||
})
|
||||
mp.game.graphics.drawRect(0.5, 0.5, 1, 1, 0, 0, 0, alpha);
|
||||
|
||||
} else {
|
||||
mp.events.call("respawnDeathPlayer");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user