formatted code
This commit is contained in:
@@ -24,7 +24,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
if(!dbContext.WhitelistEntries.Any(w => w.SocialClubName.ToLower() == player.SocialClubName.ToLower()))
|
||||
if (!dbContext.WhitelistEntries.Any(w => w.SocialClubName.ToLower() == player.SocialClubName.ToLower()))
|
||||
{
|
||||
string msg2 = "~m~*** " + player.Name + "[" + player.SocialClubName + "] (" + player.Address + ") hat versucht, sich einzuloggen, steht aber nicht auf der Whitelist.";
|
||||
ChatService.BroadcastAdmin(msg2, AdminLevel.ADMIN);
|
||||
@@ -44,7 +44,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
string msg = "~m~*** " + player.Name + " [" + player.SocialClubName + "] [ID:" + player.Handle.Value + "] (" + player.Address + ")";
|
||||
ChatService.BroadcastAdmin(msg, AdminLevel.ADMIN);
|
||||
}
|
||||
|
||||
|
||||
private bool IsPlayerBanned(Client player)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
@@ -69,7 +69,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
var timeStamp = bannedUser.UntilDateTime;
|
||||
int unixTimestamp = (int)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
|
||||
|
||||
if(timeStamp > unixTimestamp)
|
||||
if (timeStamp > unixTimestamp)
|
||||
{
|
||||
player.SendChatMessage("Du bist noch bis zum !{#FF4040}" + dt.AddSeconds(timeStamp).ToLocalTime() + " Uhr ~s~gebannt. [" + bannedUser.Reason + "]");
|
||||
player.Kick();
|
||||
@@ -80,7 +80,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
user.BanId = null;
|
||||
dbContext.SaveChanges();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
//player.TriggerEvent("medicInfo", dutyMedics);
|
||||
|
||||
//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());
|
||||
|
||||
int? killerId;
|
||||
float killerPosX;
|
||||
@@ -67,7 +67,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
killerPosY = killer.Position.Y;
|
||||
killerPosZ = killer.Position.Z;
|
||||
killerHeading = killer.Heading;
|
||||
if(player != killer)
|
||||
if (player != killer)
|
||||
{
|
||||
string message = "~y~[HINWEIS]: " + killer.Name + " hat " + player.Name + " getötet (" + NAPI.Player.GetPlayerCurrentWeapon(killer) + ")";
|
||||
ChatService.BroadcastAdmin(message, AdminLevel.ADMIN);
|
||||
@@ -91,16 +91,27 @@ namespace ReallifeGamemode.Server.Events
|
||||
|
||||
using (var userDeath = new DatabaseContext())
|
||||
{
|
||||
var dead = new Entities.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()};
|
||||
var dead = new Entities.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));
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
var user = player.GetUser(saveUser);
|
||||
Vector3 pos = player.Position;
|
||||
|
||||
if(!float.IsNaN(pos.X) && !float.IsNaN(pos.Y) && !float.IsNaN(pos.Z))
|
||||
if (!float.IsNaN(pos.X) && !float.IsNaN(pos.Y) && !float.IsNaN(pos.Z))
|
||||
{
|
||||
user.PositionX = pos.X;
|
||||
user.PositionY = pos.Y;
|
||||
@@ -47,7 +47,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
saveUser.SaveChanges();
|
||||
}
|
||||
|
||||
user.Dead = player.HasData("isDead") ? player.GetData("isDead") : false;
|
||||
user.Dead = player.HasData("isDead") ? player.GetData("isDead") : false;
|
||||
}
|
||||
player.SetData("isLoggedIn", false);
|
||||
}
|
||||
|
||||
@@ -23,12 +23,12 @@ namespace ReallifeGamemode.Server.Events
|
||||
|
||||
if (vehicle.GetServerVehicle() is FactionVehicle veh)
|
||||
{
|
||||
if(veh.FactionId != player.GetUser().FactionId)
|
||||
if (veh.FactionId != player.GetUser().FactionId)
|
||||
{
|
||||
player.StopAnimation();
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht benutzen!", true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
public void OnFactionRanksEdit(Client player, string jsonData)
|
||||
{
|
||||
FactionRankHelper helper = JsonConvert.DeserializeObject<FactionRankHelper>(jsonData);
|
||||
using(var context = new DatabaseContext())
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
Entities.Faction f = context.Factions.FirstOrDefault(x => x.Id == helper.FactionId);
|
||||
if (f == null)
|
||||
@@ -31,10 +31,10 @@ namespace ReallifeGamemode.Server.Events
|
||||
|
||||
List<int> found = new List<int>();
|
||||
|
||||
for(int i = 0; i < ranks.Count; i++)
|
||||
for (int i = 0; i < ranks.Count; i++)
|
||||
{
|
||||
Rank newRank = ranks[i];
|
||||
if(newRank.Id == 0)
|
||||
if (newRank.Id == 0)
|
||||
{
|
||||
context.FactionRanks.Add(new FactionRank
|
||||
{
|
||||
@@ -52,9 +52,9 @@ namespace ReallifeGamemode.Server.Events
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < factionRanks.Count; i++)
|
||||
for (int i = 0; i < factionRanks.Count; i++)
|
||||
{
|
||||
if(!found.Contains(factionRanks[i].Id))
|
||||
if (!found.Contains(factionRanks[i].Id))
|
||||
{
|
||||
context.FactionRanks.Remove(factionRanks[i]);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
GroundItem.PickUpGroundItem(player);
|
||||
@@ -84,15 +84,15 @@ namespace ReallifeGamemode.Server.Events
|
||||
if (!player.IsLoggedIn()) return;
|
||||
User user = player.GetUser();
|
||||
switch (user.FactionId)
|
||||
{
|
||||
{
|
||||
//LSFD
|
||||
case 2:
|
||||
player.TriggerEvent("showFactionInteraction", user.FactionId, player.GetData("duty"), user.Faction.Name, user.FactionLeader, Medic.ReviveTasks.Count.ToString(), Medic.HealTasks.Count.ToString(), Medic.FireTasks.Count.ToString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("keyPress:E")]
|
||||
|
||||
[RemoteEvent("keyPress:E")]
|
||||
public void KeyPressE(Client player)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
@@ -102,7 +102,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
DutyPoint nearest = PositionManager.DutyPoints.Find(d => d.Position.DistanceTo(player.Position) <= 1.5);
|
||||
if (nearest == null) return;
|
||||
if (player.Position.DistanceTo(nearest.Position) <= 1.5 && nearest.FactionId == user.FactionId)
|
||||
{
|
||||
{
|
||||
var nameTagColor = new Color(0, 0, 0);
|
||||
var factionId = user.FactionId;
|
||||
|
||||
@@ -113,9 +113,9 @@ namespace ReallifeGamemode.Server.Events
|
||||
if (player.GetUser().FactionId == 2) //Fire Department
|
||||
{
|
||||
int medicCount = 0;
|
||||
foreach(Client c in NAPI.Pools.GetAllPlayers())
|
||||
foreach (Client c in NAPI.Pools.GetAllPlayers())
|
||||
{
|
||||
if((c.GetUser()?.Faction.Id ?? 0) == 2)
|
||||
if ((c.GetUser()?.Faction.Id ?? 0) == 2)
|
||||
{
|
||||
medicCount++;
|
||||
}
|
||||
@@ -134,22 +134,22 @@ namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
List<CharacterCloth> clothes = context.CharacterClothes.Where(u => u.UserId == user.Id && u.Duty == true).ToList();
|
||||
|
||||
foreach(var cloth in clothes)
|
||||
foreach (var cloth in clothes)
|
||||
{
|
||||
if(cloth.SlotType == 0)
|
||||
if (cloth.SlotType == 0)
|
||||
{
|
||||
player.SetClothes(cloth.SlotId, cloth.ClothId, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(cloth.ClothId != -1)
|
||||
if (cloth.ClothId != -1)
|
||||
{
|
||||
player.SetAccessories(cloth.SlotId, cloth.ClothId, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.ClearAccessory(cloth.SlotId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -178,7 +178,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
List<Client> players = NAPI.Pools.GetAllPlayers();
|
||||
List<ListPlayer> ListPlayers = new List<ListPlayer>();
|
||||
|
||||
foreach(Client listPlayer in players)
|
||||
foreach (Client listPlayer in players)
|
||||
{
|
||||
var lPlayer = new ListPlayer
|
||||
{
|
||||
@@ -190,7 +190,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
ListPlayers.Add(lPlayer);
|
||||
}
|
||||
player.TriggerEvent("fetchPlayerList", JsonConvert.SerializeObject(ListPlayers));
|
||||
}
|
||||
}
|
||||
[RemoteEvent("keyPress:K")]
|
||||
public void KeyPressK(Client player)
|
||||
{
|
||||
@@ -210,9 +210,9 @@ namespace ReallifeGamemode.Server.Events
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
List<DutyCloth> clothes = context.DutyClothes.ToList().FindAll(c => c.FactionId == user.FactionId && c.Gender == user.GetCharacter().Gender);
|
||||
foreach(var cloth in clothes)
|
||||
foreach (var cloth in clothes)
|
||||
{
|
||||
if(cloth.SlotType == 1)
|
||||
if (cloth.SlotType == 1)
|
||||
{
|
||||
if (cloth.ClothId != -1)
|
||||
{
|
||||
@@ -242,7 +242,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
player.TriggerEvent("showDutyClothMenu", hats.ToArray(), tops.ToArray(), legs.ToArray(), shoes.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
[RemoteEvent("keyPress:L")]
|
||||
public void KeyPressL(Client player)
|
||||
@@ -263,19 +263,19 @@ namespace ReallifeGamemode.Server.Events
|
||||
if (player.IsInVehicle && player.VehicleSeat == -1)
|
||||
{
|
||||
ServerVehicle veh = player.Vehicle.GetServerVehicle();
|
||||
if(veh != null)
|
||||
if (veh != null)
|
||||
{
|
||||
if(veh is FactionVehicle fV && fV.FactionId != player.GetUser()?.FactionId && (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN3) ?? false))
|
||||
if (veh is FactionVehicle fV && fV.FactionId != player.GetUser()?.FactionId && (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN3) ?? false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if(veh is ShopVehicle)
|
||||
else if (veh is ShopVehicle)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
player.TriggerEvent("ToggleVehicleMenu");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,6 +96,6 @@ namespace ReallifeGamemode.Server.Events
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
dbContext.UserBankAccounts.Add(userBankAccount);
|
||||
dbContext.SaveChanges();
|
||||
|
||||
player.TriggerEvent("SERVER:Login_Success");
|
||||
player.TriggerEvent("SERVER:Login_Success");
|
||||
player.SetData("isLoggedIn", true);
|
||||
player.SetData("isDead", false);
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
//player.TriggerEvent("toggleCreator");
|
||||
|
||||
player.Position = new Vector3(user.PositionX, user.PositionY, user.PositionZ);
|
||||
|
||||
|
||||
}
|
||||
else if (dbContext.Users.Where(u => u.SocialClubName == player.SocialClubName).Count() >= 3)
|
||||
{
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
var users = NAPI.Pools.GetAllPlayers();
|
||||
|
||||
foreach(Client user in users)
|
||||
foreach (Client user in users)
|
||||
{
|
||||
using (var saveUsers = new DatabaseContext())
|
||||
{
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
[ServerEvent(Event.Update)]
|
||||
public void UpdateEvent()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
}
|
||||
CharacterCloth torso = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == 0 && u.SlotId == 3);
|
||||
CharacterCloth undershirt = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == 0 && u.SlotId == 8);
|
||||
|
||||
|
||||
torso.ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Torso;
|
||||
undershirt.ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Undershirt;
|
||||
}
|
||||
@@ -139,7 +139,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
|
||||
foreach (var cloth in charClothes)
|
||||
{
|
||||
if(cloth.SlotType == 1)
|
||||
if (cloth.SlotType == 1)
|
||||
{
|
||||
player.SetAccessories(cloth.SlotId, cloth.ClothId, 0);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
player.SendNotification("~r~Der Motor kann nur im Stand betätigt werden.", true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
bool state = VehicleStreaming.GetEngineState(v);
|
||||
ServerVehicle sV = v.GetServerVehicle();
|
||||
if (sV != null)
|
||||
@@ -74,9 +74,9 @@ namespace ReallifeGamemode.Server.Events
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if(sV is UserVehicle uV)
|
||||
else if (sV is UserVehicle uV)
|
||||
{
|
||||
if(uV.UserId != u.Id && !u.IsAdmin(AdminLevel.ADMIN3))
|
||||
if (uV.UserId != u.Id && !u.IsAdmin(AdminLevel.ADMIN3))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user