Changed whole project structure (split client and server into separat projects)
This commit is contained in:
109
ReallifeGamemode.Server/Events/Death.cs
Normal file
109
ReallifeGamemode.Server/Events/Death.cs
Normal file
@@ -0,0 +1,109 @@
|
||||
using System;
|
||||
using GTANetworkAPI;
|
||||
using reallife_gamemode.Server.Extensions;
|
||||
using reallife_gamemode.Server.Factions.Medic;
|
||||
using reallife_gamemode.Server.Models;
|
||||
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)
|
||||
{
|
||||
if (!player.IsLoggedIn()) player.Kick();
|
||||
player.SetData("isDead", true);
|
||||
|
||||
if (player.GetUser().IsAdmin(AdminLevel.ADMIN) == true)
|
||||
{
|
||||
player.TriggerEvent("startDeathTimer", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.TriggerEvent("startDeathTimer", false);
|
||||
}
|
||||
|
||||
//var dutyMedics = 0;
|
||||
//var allPlayers = NAPI.Pools.GetAllPlayers();
|
||||
|
||||
//foreach (Client medic in allPlayers)
|
||||
//{
|
||||
// if (medic.GetUser()?.FactionId == 2)
|
||||
// {
|
||||
// dutyMedics++;
|
||||
// }
|
||||
//}
|
||||
//player.TriggerEvent("medicInfo", dutyMedics);
|
||||
|
||||
//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;
|
||||
if(player != killer)
|
||||
{
|
||||
string message = "~y~[HINWEIS]: " + killer.Name + " hat " + player.Name + " getötet (" + NAPI.Player.GetPlayerCurrentWeapon(killer) + ")";
|
||||
ChatService.BroadcastAdmin(message, AdminLevel.ADMIN);
|
||||
}
|
||||
}
|
||||
//MEDIC AUFTRAG
|
||||
MedicTask reviveTask = new MedicTask()
|
||||
{
|
||||
Victim = player.Name,
|
||||
Position = player.Position,
|
||||
CauseOfDeath = reason.ToString(),
|
||||
Caller = null,
|
||||
Description = "Gestorben",
|
||||
Time = DateTime.Now,
|
||||
Type = 0,
|
||||
MedicName = "none"
|
||||
};
|
||||
Medic.AddTaskToList(reviveTask);
|
||||
|
||||
//TODO PICTURE NOTIFICATION + SOUND für Medics
|
||||
|
||||
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.SetData("isDead", false);
|
||||
player.RemoveAllWeapons();
|
||||
NAPI.Player.SpawnPlayer(player, new Vector3(-495.45, -336.33, 34.5));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user