Merge branch 'feature/deathEvent' into develop
This commit is contained in:
61
Client/Gui/deathscreen.js
Normal file
61
Client/Gui/deathscreen.js
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
/**
|
||||||
|
* @overview Life of German Reallife - Gui Infobox infobox.js
|
||||||
|
* @author VegaZ
|
||||||
|
* @copyright (c) 2008 - 2018 Life of German
|
||||||
|
*/
|
||||||
|
|
||||||
|
var playerName;
|
||||||
|
var playerId;
|
||||||
|
var playerMoney;
|
||||||
|
|
||||||
|
var isDeath = false;
|
||||||
|
var deathTime;
|
||||||
|
var respawnTime;
|
||||||
|
var deathSeconds;
|
||||||
|
var fade;
|
||||||
|
|
||||||
|
mp.game.gameplay.setFadeOutAfterDeath(false);
|
||||||
|
|
||||||
|
mp.events.add("startDeathTimer", () => {
|
||||||
|
if (isDeath === false) {
|
||||||
|
isDeath = true;
|
||||||
|
mp.gui.chat.activate(false);
|
||||||
|
deathDate = new Date();
|
||||||
|
respawnTime = Math.floor(deathDate.getTime() / 1000 + 120);
|
||||||
|
fade = 255 - 120;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
mp.events.add("onPlayerRevived", () => {
|
||||||
|
isDeath = false;
|
||||||
|
mp.gui.chat.activate(true);
|
||||||
|
mp.game.gameplay.setFadeOutAfterDeath(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
mp.events.add("respawnDeathPlayer", () => {
|
||||||
|
isDeath = false;
|
||||||
|
mp.gui.chat.activate(true);
|
||||||
|
mp.game.gameplay.setFadeOutAfterDeath(false);
|
||||||
|
mp.events.callRemote('RespawnPlayerAtHospital');
|
||||||
|
});
|
||||||
|
|
||||||
|
mp.events.add("render", () => {
|
||||||
|
currentDate = new Date();
|
||||||
|
|
||||||
|
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],
|
||||||
|
{
|
||||||
|
font: 7,
|
||||||
|
color: [255, 255, 255, 255],
|
||||||
|
scale: [0.8, 0.8],
|
||||||
|
outline: true
|
||||||
|
})
|
||||||
|
mp.game.graphics.drawRect(0.5, 0.5, 1, 1, 0, 0, 0, alpha);
|
||||||
|
} else {
|
||||||
|
mp.events.call("respawnDeathPlayer");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
require('./Login/main.js');
|
require('./Login/main.js');
|
||||||
require('./Save/main.js');
|
require('./Save/main.js');
|
||||||
require('./Save/save.js');
|
require('./Save/save.js');
|
||||||
|
require('./Gui/deathscreen.js');
|
||||||
require('./Gui/infobox.js');
|
require('./Gui/infobox.js');
|
||||||
require('./Gui/playerlist.js');
|
require('./Gui/playerlist.js');
|
||||||
require('./Login/main.js');
|
require('./Login/main.js');
|
||||||
|
|||||||
1
Main.cs
1
Main.cs
@@ -24,6 +24,7 @@ namespace reallife_gamemode
|
|||||||
NAPI.Server.SetCommandErrorMessage("~r~[FEHLER]~s~ Dieser Command existiert nicht.");
|
NAPI.Server.SetCommandErrorMessage("~r~[FEHLER]~s~ Dieser Command existiert nicht.");
|
||||||
NAPI.Server.SetDefaultSpawnLocation(DEFAULT_SPAWN_POSITION, DEFAULT_SPAWN_HEADING);
|
NAPI.Server.SetDefaultSpawnLocation(DEFAULT_SPAWN_POSITION, DEFAULT_SPAWN_HEADING);
|
||||||
NAPI.Server.SetAutoSpawnOnConnect(false);
|
NAPI.Server.SetAutoSpawnOnConnect(false);
|
||||||
|
NAPI.Server.SetAutoRespawnAfterDeath(false);
|
||||||
|
|
||||||
using (var context = new DatabaseContext())
|
using (var context = new DatabaseContext())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,11 +20,13 @@ namespace reallife_gamemode.Server.Commands
|
|||||||
{
|
{
|
||||||
class Faction : Script
|
class Faction : Script
|
||||||
{
|
{
|
||||||
|
#region Chat Commands
|
||||||
|
|
||||||
[Command("f", "~m~Benutzung: ~s~/f [Nachricht]", GreedyArg = true)]
|
[Command("f", "~m~Benutzung: ~s~/f [Nachricht]", GreedyArg = true)]
|
||||||
public void CmdFactionF(Client player, string message)
|
public void CmdFactionF(Client player, string message)
|
||||||
{
|
{
|
||||||
Entities.Faction f = player.GetUser()?.GetFaction();
|
Entities.Faction f = player.GetUser()?.GetFaction();
|
||||||
if(f == null || f.StateOwned)
|
if (f == null || f.StateOwned)
|
||||||
{
|
{
|
||||||
ChatService.NotAuthorized(player);
|
ChatService.NotAuthorized(player);
|
||||||
return;
|
return;
|
||||||
@@ -59,16 +61,18 @@ namespace reallife_gamemode.Server.Commands
|
|||||||
}
|
}
|
||||||
|
|
||||||
string broadcastMessage = "!{CC3333}** " + player.GetUser().GetFactionRank().RankName + " " + player.Name + ": " + message + ", over **";
|
string broadcastMessage = "!{CC3333}** " + player.GetUser().GetFactionRank().RankName + " " + player.Name + ": " + message + ", over **";
|
||||||
using(var context = new DatabaseContext())
|
using (var context = new DatabaseContext())
|
||||||
{
|
{
|
||||||
ChatService.BroadcastFaction(broadcastMessage, context.Factions.ToList().FindAll(c => c.StateOwned));
|
ChatService.BroadcastFaction(broadcastMessage, context.Factions.ToList().FindAll(c => c.StateOwned));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
#region Leader Commands
|
||||||
|
|
||||||
[Command("invite", "~m~Benutzung: ~s~/invite [Name]")]
|
[Command("invite", "~m~Benutzung: ~s~/invite [Name]")]
|
||||||
public void CmdFactionInvite(Client player, string name)
|
public void CmdFactionInvite(Client player, string name)
|
||||||
{
|
{
|
||||||
if(player.GetUser()?.FactionId == null || player.GetUser().FactionLeader == false)
|
if (player.GetUser()?.FactionId == null || player.GetUser().FactionLeader == false)
|
||||||
{
|
{
|
||||||
ChatService.NotAuthorized(player);
|
ChatService.NotAuthorized(player);
|
||||||
return;
|
return;
|
||||||
@@ -81,7 +85,7 @@ namespace reallife_gamemode.Server.Commands
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(target.GetUser()?.FactionId != null)
|
if (target.GetUser()?.FactionId != null)
|
||||||
{
|
{
|
||||||
player.SendChatMessage("~r~[FEHLER]~s~ Dieser Spieler ist schon in einer Fraktion.");
|
player.SendChatMessage("~r~[FEHLER]~s~ Dieser Spieler ist schon in einer Fraktion.");
|
||||||
return;
|
return;
|
||||||
@@ -121,7 +125,7 @@ namespace reallife_gamemode.Server.Commands
|
|||||||
using (var dbContext = new DatabaseContext())
|
using (var dbContext = new DatabaseContext())
|
||||||
{
|
{
|
||||||
FactionRank fr = dbContext.FactionRanks.FirstOrDefault(r => r.RankName == rank && r.FactionId == player.GetUser(dbContext).FactionId);
|
FactionRank fr = dbContext.FactionRanks.FirstOrDefault(r => r.RankName == rank && r.FactionId == player.GetUser(dbContext).FactionId);
|
||||||
if(fr == null)
|
if (fr == null)
|
||||||
{
|
{
|
||||||
player.SendChatMessage("~r~[FEHLER]~s~ Dieser Rang existiert nicht.");
|
player.SendChatMessage("~r~[FEHLER]~s~ Dieser Rang existiert nicht.");
|
||||||
return;
|
return;
|
||||||
@@ -158,13 +162,13 @@ namespace reallife_gamemode.Server.Commands
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(player.Handle == target.Handle)
|
if (player.Handle == target.Handle)
|
||||||
{
|
{
|
||||||
player.SendChatMessage("~r~[FEHLER]~s~ Du kannst dich nicht selber uninviten.");
|
player.SendChatMessage("~r~[FEHLER]~s~ Du kannst dich nicht selber uninviten.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(target.GetUser()?.FactionLeader ?? false)
|
if (target.GetUser()?.FactionLeader ?? false)
|
||||||
{
|
{
|
||||||
player.SendChatMessage("~r~[FEHLER]~s~ Du kannst keinen Leader uninviten.");
|
player.SendChatMessage("~r~[FEHLER]~s~ Du kannst keinen Leader uninviten.");
|
||||||
return;
|
return;
|
||||||
@@ -199,5 +203,27 @@ namespace reallife_gamemode.Server.Commands
|
|||||||
if (p.GetUser()?.FactionLeader ?? false) p.SendChatMessage(broadcastMsg);
|
if (p.GetUser()?.FactionLeader ?? false) p.SendChatMessage(broadcastMsg);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
#region Sanitäter Commands
|
||||||
|
|
||||||
|
[Command("revive", "~m~Benutzung: ~s~/invite")]
|
||||||
|
public void CmdFactionMedicRevive(Client player)
|
||||||
|
{
|
||||||
|
if (player.GetUser()?.FactionId == null || player.GetUser().FactionId != 2)
|
||||||
|
{
|
||||||
|
ChatService.NotAuthorized(player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var nearPlayers = NAPI.Player.GetPlayersInRadiusOfPlayer(2, player);
|
||||||
|
var deadPlayer = nearPlayers.Where(i => i.GetData("isDead") == true).FirstOrDefault();
|
||||||
|
|
||||||
|
deadPlayer.TriggerEvent("onPlayerRevived");
|
||||||
|
deadPlayer.SendNotification("Du wurdest von ~y~" + player.Name + "~s~ wiederbelebt.");
|
||||||
|
deadPlayer.SetData("isDead", false);
|
||||||
|
NAPI.Player.SpawnPlayer(deadPlayer, deadPlayer.Position);
|
||||||
|
deadPlayer.Health = 50;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ namespace reallife_gamemode.Server.Entities
|
|||||||
public string Email { get; set; }
|
public string Email { get; set; }
|
||||||
public AdminLevel AdminLevel { get; set; }
|
public AdminLevel AdminLevel { get; set; }
|
||||||
|
|
||||||
|
public bool Dead { get; set; }
|
||||||
|
|
||||||
public float PositionX { get; set; }
|
public float PositionX { get; set; }
|
||||||
public float PositionY { get; set; }
|
public float PositionY { get; set; }
|
||||||
public float PositionZ { get; set; }
|
public float PositionZ { get; set; }
|
||||||
|
|||||||
@@ -47,6 +47,21 @@ namespace reallife_gamemode.Server.Events
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using (var loginUser = new DatabaseContext())
|
||||||
|
{
|
||||||
|
var user = loginUser.Users.SingleOrDefault(b => b.Name == player.Name);
|
||||||
|
if(user.Dead == true)
|
||||||
|
{
|
||||||
|
player.TriggerEvent("startDeathTimer");
|
||||||
|
player.SetData("isDead", true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.SetData("isDead", false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
player.SetData("isLoggedIn", false);
|
player.SetData("isLoggedIn", false);
|
||||||
player.Position = new Vector3(-1883.736, -781.4911, -10);
|
player.Position = new Vector3(-1883.736, -781.4911, -10);
|
||||||
player.FreezePosition = true;
|
player.FreezePosition = true;
|
||||||
|
|||||||
@@ -22,6 +22,9 @@ namespace reallife_gamemode.Server.Events
|
|||||||
[ServerEvent(Event.PlayerDeath)]
|
[ServerEvent(Event.PlayerDeath)]
|
||||||
public void OnPlayerDeath(Client player, Client killer, uint reason)
|
public void OnPlayerDeath(Client player, Client killer, uint reason)
|
||||||
{
|
{
|
||||||
|
player.SetData("isDead", true);
|
||||||
|
player.TriggerEvent("startDeathTimer");
|
||||||
|
|
||||||
//TODO: Zum Full Release entfernen
|
//TODO: Zum Full Release entfernen
|
||||||
NAPI.Chat.SendChatMessageToPlayer(player, "Du bist durch " + killer.Name + " gestorben: " + reason.ToString());
|
NAPI.Chat.SendChatMessageToPlayer(player, "Du bist durch " + killer.Name + " gestorben: " + reason.ToString());
|
||||||
|
|
||||||
@@ -59,5 +62,12 @@ namespace reallife_gamemode.Server.Events
|
|||||||
userDeath.SaveChanges();
|
userDeath.SaveChanges();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
[RemoteEvent("RespawnPlayerAtHospital")]
|
||||||
|
public void RespawnPlayerAtHospital(Client player)
|
||||||
|
{
|
||||||
|
player.SetData("isDead", false);
|
||||||
|
player.RemoveAllWeapons();
|
||||||
|
NAPI.Player.SpawnPlayer(player, new Vector3(-495.45, -336.33, 34.5));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ namespace reallife_gamemode.Server.Events
|
|||||||
user.PositionX = player.Position.X;
|
user.PositionX = player.Position.X;
|
||||||
user.PositionY = player.Position.Y;
|
user.PositionY = player.Position.Y;
|
||||||
user.PositionZ = player.Position.Z;
|
user.PositionZ = player.Position.Z;
|
||||||
|
user.Dead = player.GetData("isDead");
|
||||||
saveUser.SaveChanges();
|
saveUser.SaveChanges();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user