Extend Death System; Add Revive-System
This commit is contained in:
@@ -30,7 +30,6 @@ mp.events.add("onPlayerRevived", () => {
|
|||||||
isDeath = false;
|
isDeath = false;
|
||||||
mp.gui.chat.activate(true);
|
mp.gui.chat.activate(true);
|
||||||
mp.game.gameplay.setFadeOutAfterDeath(false);
|
mp.game.gameplay.setFadeOutAfterDeath(false);
|
||||||
mp.events.callRemote('RespawnPlayerAtDeathpoint');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
mp.events.add("respawnDeathPlayer", () => {
|
mp.events.add("respawnDeathPlayer", () => {
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ 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)
|
||||||
{
|
{
|
||||||
@@ -64,6 +66,8 @@ namespace reallife_gamemode.Server.Commands
|
|||||||
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)
|
||||||
@@ -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,7 +22,7 @@ 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");
|
player.TriggerEvent("startDeathTimer");
|
||||||
|
|
||||||
//TODO: Zum Full Release entfernen
|
//TODO: Zum Full Release entfernen
|
||||||
@@ -65,14 +65,9 @@ namespace reallife_gamemode.Server.Events
|
|||||||
[RemoteEvent("RespawnPlayerAtHospital")]
|
[RemoteEvent("RespawnPlayerAtHospital")]
|
||||||
public void RespawnPlayerAtHospital(Client player)
|
public void RespawnPlayerAtHospital(Client player)
|
||||||
{
|
{
|
||||||
|
player.SetData("isDead", false);
|
||||||
player.RemoveAllWeapons();
|
player.RemoveAllWeapons();
|
||||||
NAPI.Player.SpawnPlayer(player, new Vector3(-495.45, -336.33, 34.5));
|
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -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