79 lines
2.8 KiB
C#
79 lines
2.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using GTANetworkAPI;
|
|
using GTANetworkMethods;
|
|
using reallife_gamemode.Model;
|
|
using reallife_gamemode.Server.Extensions;
|
|
using reallife_gamemode.Server.Services;
|
|
using reallife_gamemode.Server.Util;
|
|
|
|
/**
|
|
* @overview Life of German Reallife - Events Death (Death.cs)
|
|
* @author VegaZ
|
|
* @copyright (c) 2008 - 2018 Life of German
|
|
*/
|
|
|
|
namespace reallife_gamemode.Server.Events
|
|
{
|
|
public class Death : Script
|
|
{
|
|
[ServerEvent(Event.PlayerDeath)]
|
|
public void OnPlayerDeath(Client player, Client killer, uint reason)
|
|
{
|
|
|
|
player.TriggerEvent("startDeathTimer");
|
|
|
|
//TODO: Zum Full Release entfernen
|
|
NAPI.Chat.SendChatMessageToPlayer(player, "Du bist durch " + killer.Name + " gestorben: " + reason.ToString());
|
|
|
|
int? killerId;
|
|
float killerPosX;
|
|
float killerPosY;
|
|
float killerPosZ;
|
|
float killerHeading;
|
|
|
|
if (killer.IsNull)
|
|
{
|
|
killerId = null;
|
|
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;
|
|
string message = "~y~[HINWEIS]: " + killer.Name + " hat " + player.Name + " getötet (" + NAPI.Player.GetPlayerCurrentWeapon(killer) + ")";
|
|
ChatService.BroadcastAdmin(message, AdminLevel.ADMIN);
|
|
}
|
|
|
|
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();
|
|
}
|
|
}
|
|
[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);
|
|
}
|
|
}
|
|
|
|
}
|