Edit Death System
This commit is contained in:
@@ -12,30 +12,41 @@ var isDeath = false;
|
|||||||
var deathTime;
|
var deathTime;
|
||||||
var respawnTime;
|
var respawnTime;
|
||||||
var deathSeconds;
|
var deathSeconds;
|
||||||
|
var fade;
|
||||||
|
|
||||||
|
mp.game.gameplay.setFadeOutAfterDeath(false);
|
||||||
|
|
||||||
mp.events.add("startDeathTimer", () => {
|
mp.events.add("startDeathTimer", () => {
|
||||||
if (isDeath === false) {
|
if (isDeath === false) {
|
||||||
isDeath = true;
|
isDeath = true;
|
||||||
mp.gui.chat.activate(false);
|
mp.gui.chat.activate(false);
|
||||||
mp.gui.chat.show(false);
|
|
||||||
deathDate = new Date();
|
deathDate = new Date();
|
||||||
respawnTime = deathDate.getSeconds() + 120;
|
respawnTime = Math.floor(deathDate.getTime() / 1000 + 120);
|
||||||
secondsToAlpha = 120;
|
fade = 255 - 120;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mp.events.add("onPlayerRevived", () => {
|
mp.events.add("onPlayerRevived", () => {
|
||||||
isDeath = false;
|
isDeath = false;
|
||||||
mp.gui.chat.activate(true);
|
mp.gui.chat.activate(true);
|
||||||
mp.gui.chat.show(true);
|
mp.game.gameplay.setFadeOutAfterDeath(false);
|
||||||
|
mp.events.callRemote('RespawnPlayerAtDeathpoint');
|
||||||
|
});
|
||||||
|
|
||||||
|
mp.events.add("respawnDeathPlayer", () => {
|
||||||
|
isDeath = false;
|
||||||
|
mp.gui.chat.activate(true);
|
||||||
|
mp.game.gameplay.setFadeOutAfterDeath(false);
|
||||||
|
mp.events.callRemote('RespawnPlayerAtHospital');
|
||||||
});
|
});
|
||||||
|
|
||||||
mp.events.add("render", () => {
|
mp.events.add("render", () => {
|
||||||
|
|
||||||
if (isDeath === true) {
|
|
||||||
currentDate = new Date();
|
currentDate = new Date();
|
||||||
|
|
||||||
deathSeconds = respawnTime - currentDate.getSeconds();
|
if (isDeath === true) {
|
||||||
|
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.drawText("~y~" + deathSeconds, [0.5, 0.5],
|
||||||
{
|
{
|
||||||
font: 7,
|
font: 7,
|
||||||
@@ -43,7 +54,9 @@ mp.events.add("render", () => {
|
|||||||
scale: [0.8, 0.8],
|
scale: [0.8, 0.8],
|
||||||
outline: true
|
outline: true
|
||||||
})
|
})
|
||||||
mp.game.graphics.drawRect(0.5, 0.5, 1, 1, 0, 0, 0, deathSeconds);
|
mp.game.graphics.drawRect(0.5, 0.5, 1, 1, 0, 0, 0, alpha);
|
||||||
|
} else {
|
||||||
|
mp.events.call("respawnDeathPlayer");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -62,5 +62,17 @@ namespace reallife_gamemode.Server.Events
|
|||||||
userDeath.SaveChanges();
|
userDeath.SaveChanges();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
[RemoteEvent("RespawnPlayerAtHospital")]
|
||||||
|
public void RespawnPlayerAtHospital(Client player)
|
||||||
|
{
|
||||||
|
player.RemoveAllWeapons();
|
||||||
|
NAPI.Player.SpawnPlayer(player, new Vector3(-495.45, -336.33, 34.5));
|
||||||
|
}
|
||||||
|
[RemoteEvent("RespawnPlayerAtDeathpoint")]
|
||||||
|
public void RespawnPlayerAtDeathpoint(Client player)
|
||||||
|
{
|
||||||
|
NAPI.Player.SpawnPlayer(player, player.Position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user