Add DeathLogs
This commit is contained in:
@@ -36,13 +36,16 @@ namespace reallife_gamemode.Model
|
||||
base.OnModelCreating(modelBuilder);
|
||||
}
|
||||
|
||||
//User
|
||||
public DbSet<Server.Entities.User> Users { get; set; }
|
||||
public DbSet<Server.Entities.UserVehicle> UserVehicles { get; set; }
|
||||
public DbSet<Server.Entities.UserBankAccount> BankAccounts { get; set; }
|
||||
|
||||
public DbSet<Server.Logs.BankAccountTransactionHistory> BankAccountTransactionHistories { get; set; }
|
||||
public DbSet<Server.Logs.Death> Deaths { get; set; }
|
||||
//Logs
|
||||
public DbSet<Server.Logs.BankAccountTransactionHistory> BankAccountTransactionLogs { get; set; }
|
||||
public DbSet<Server.Logs.Death> DeathLogs { get; set; }
|
||||
|
||||
//Saves
|
||||
public DbSet<Server.Saves.SavedBlip> Blips { get; set; }
|
||||
public DbSet<Server.Saves.SavedMarker> Markers { get; set; }
|
||||
public DbSet<Server.Saves.SavedPed> Peds { get; set; }
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using GTANetworkMethods;
|
||||
using reallife_gamemode.Model;
|
||||
using reallife_gamemode.Server.Extensions;
|
||||
|
||||
/*
|
||||
* Author: balbo
|
||||
@@ -19,6 +20,36 @@ namespace reallife_gamemode.Server.Events
|
||||
public void OnPlayerDeath(Client player, Client killer, uint reason)
|
||||
{
|
||||
NAPI.Chat.SendChatMessageToPlayer(player, "Du bist durch " + killer.Name + " gestorben: " + reason.ToString());
|
||||
|
||||
var killerId = 0;
|
||||
var killerPosX = 0f;
|
||||
var killerPosY = 0f;
|
||||
var killerPosZ = 0f;
|
||||
var killerHeading = 0f;
|
||||
|
||||
if (killer.IsNull)
|
||||
{
|
||||
killerId = -1;
|
||||
killerPosX = -1;
|
||||
killerPosY = -1;
|
||||
killerPosZ = -1;
|
||||
killerHeading = -1;
|
||||
} else {
|
||||
killerId = killer.GetUser().Id;
|
||||
killerPosX = killer.Position.X;
|
||||
killerPosY = killer.Position.Y;
|
||||
killerPosZ = killer.Position.Z;
|
||||
killerHeading = killer.Heading;
|
||||
}
|
||||
|
||||
using (var userDeath = new DatabaseContext())
|
||||
{
|
||||
var dead = new Logs.Death { VictimId = player.GetUser().Id, KillerId = killerId, KillerPositionX = killerPosX, KillerPositionY = killerPosY,
|
||||
KillerPositionZ = killerPosZ, KillerHeading = killerHeading, VictimPositionX = player.Position.X, VictimPositionY = player.Position.Y,
|
||||
VictimPositionZ = player.Position.Z, VictimHeading = player.Heading, CauseOfDeath = reason.ToString()};
|
||||
userDeath.DeathLogs.Add(dead);
|
||||
userDeath.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ namespace reallife_gamemode.Server.Events
|
||||
}
|
||||
player.TriggerEvent("registerSuccess");
|
||||
NAPI.Player.SpawnPlayer(player, Main.DEFAULT_SPAWN_POSITION, Main.DEFAULT_SPAWN_HEADING);
|
||||
player.SetData("isLoggedIn", true);
|
||||
}
|
||||
else if (player.SocialClubName == checkedUser.SocialClubName)
|
||||
{
|
||||
|
||||
@@ -18,24 +18,25 @@ namespace reallife_gamemode.Server.Logs
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
[ForeignKey("Victim")]
|
||||
public int VictimId { get; set; }
|
||||
public User Victim { get; set; }
|
||||
|
||||
[ForeignKey("Killer")]
|
||||
public int? KillerId { get; set; }
|
||||
public User Killer { get; set; }
|
||||
[ForeignKey("Victim")]
|
||||
public int VictimId { get; set; }
|
||||
public User Victim { get; set; }
|
||||
|
||||
public float VictimPositionX { get; set; }
|
||||
public float VictimPositionY { get; set; }
|
||||
public float VictimPositionZ { get; set; }
|
||||
public float VictimHeading { get; set; }
|
||||
|
||||
public float KillerPositionX { get; set; }
|
||||
public float KillerPositionY { get; set; }
|
||||
public float KillerPositionZ { get; set; }
|
||||
public float KillerHeading { get; set; }
|
||||
|
||||
public float VictimPositionX { get; set; }
|
||||
public float VictimPositionY { get; set; }
|
||||
public float VictimPositionZ { get; set; }
|
||||
public float VictimHeading { get; set; }
|
||||
|
||||
[StringLength(64)]
|
||||
public string CauseOfDeath { get; set; }
|
||||
[Timestamp]
|
||||
|
||||
Reference in New Issue
Block a user