Miese Corona Zeiten push für Lenhardt
This commit is contained in:
@@ -1,20 +1,20 @@
|
||||
using GTANetworkAPI;
|
||||
using System.Text.RegularExpressions;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
public class Chat : Script
|
||||
{
|
||||
[ServerEvent(Event.ChatMessage)]
|
||||
public void ChatEvent(Player player, string message)
|
||||
{
|
||||
string serverMsg = Regex.Replace(message, "(~[a-zA-Z]~)|(!{(.*)})", "");
|
||||
if (serverMsg.Trim().Length == 0) return;
|
||||
NAPI.Player.GetPlayersInRadiusOfPlayer(10, player).ForEach(p =>
|
||||
{
|
||||
ChatService.SendMessage(p, $"{player.Name} sagt: {serverMsg}");//
|
||||
});
|
||||
[ServerEvent(Event.ChatMessage)]
|
||||
public void ChatEvent(Player player, string message)
|
||||
{
|
||||
string serverMsg = Regex.Replace(message, "(~[a-zA-Z]~)|(!{(.*)})", "");
|
||||
if (serverMsg.Trim().Length == 0) return;
|
||||
NAPI.Player.GetPlayersInRadiusOfPlayer(10, player).ForEach(p =>
|
||||
{
|
||||
ChatService.SendMessage(p, $"{player.Name} sagt: {serverMsg}");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,9 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Database;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
using ReallifeGamemode.Server.Types;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using ReallifeGamemode.Server.Wanted;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Event Login (Login.cs)
|
||||
@@ -16,7 +13,7 @@ using ReallifeGamemode.Server.Wanted;
|
||||
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
class Connect : Script
|
||||
internal class Connect : Script
|
||||
{
|
||||
[ServerEvent(Event.PlayerConnected)]
|
||||
public void OnPlayerConnected(Player player)
|
||||
@@ -24,7 +21,6 @@ namespace ReallifeGamemode.Server.Events
|
||||
player.SetData("isLoggedIn", false);
|
||||
player.Position = new Vector3(-1883.736, -781.4911, -10);
|
||||
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
if (!dbContext.WhitelistEntries.Any(w => w.SocialClubName.ToLower() == player.SocialClubName.ToLower()))
|
||||
@@ -41,12 +37,10 @@ namespace ReallifeGamemode.Server.Events
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (IsPlayerBanned(player)) return;
|
||||
player.TriggerEvent("SERVER:Login_ShowBrowser");
|
||||
string msg = "~m~*** " + player.Name + " [" + player.SocialClubName + "] [ID: " + player.Handle.Value + "] (" + player.Address + ")";
|
||||
ChatService.BroadcastAdmin(msg, AdminLevel.ADMIN);
|
||||
|
||||
}
|
||||
|
||||
private bool IsPlayerBanned(Player player)
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Database;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Factions.Medic;
|
||||
using ReallifeGamemode.Server.Inventory;
|
||||
using ReallifeGamemode.Server.Inventory.Interfaces;
|
||||
using ReallifeGamemode.Server.Managers;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
using ReallifeGamemode.Server.Types;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using ReallifeGamemode.Server.Wanted;
|
||||
|
||||
/**
|
||||
@@ -19,54 +22,53 @@ using ReallifeGamemode.Server.Wanted;
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
public class Death : Script
|
||||
{
|
||||
[ServerEvent(Event.PlayerDeath)]
|
||||
public void OnPlayerDeath(Player player, Player killer, uint reason)
|
||||
{
|
||||
if (!player.IsLoggedIn()) player.Kick();
|
||||
player.SetData("isDead", true);
|
||||
|
||||
//TODO: Zum Full Release entfernen
|
||||
ChatService.SendMessage(player, "Du bist durch " + (killer?.Name ?? "Niemanden") + " gestorben: " + reason.ToString());
|
||||
|
||||
int? killerId;
|
||||
float killerPosX;
|
||||
float killerPosY;
|
||||
float killerPosZ;
|
||||
float killerHeading;
|
||||
|
||||
if (killer == null || 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.HasData("inGangWar") && killer.HasData("inGangWar"))
|
||||
[ServerEvent(Event.PlayerDeath)]
|
||||
public void OnPlayerDeath(Player player, Player killer, uint reason)
|
||||
{
|
||||
Gangwar.Gangwar.GangwarKill(killer, player);
|
||||
}
|
||||
if (!player.IsLoggedIn()) player.Kick();
|
||||
player.SetData("isDead", true);
|
||||
|
||||
if (player != killer)
|
||||
{
|
||||
Autowanted.Check_AutoWanted(killer, player);
|
||||
string message = "~y~[HINWEIS]: " + killer.Name + " hat " + player.Name + " getötet (" + Managers.WeaponManager.GetCauseOfDeathByHash(reason) + ")";
|
||||
ChatService.BroadcastAdmin(message, AdminLevel.ADMIN);
|
||||
}
|
||||
}
|
||||
//TODO: Zum Full Release entfernen
|
||||
ChatService.SendMessage(player, "Du bist durch " + (killer?.Name ?? "Niemanden") + " gestorben: " + reason.ToString());
|
||||
|
||||
int? killerId;
|
||||
float killerPosX;
|
||||
float killerPosY;
|
||||
float killerPosZ;
|
||||
float killerHeading;
|
||||
|
||||
if (killer == null || 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.HasData("inGangWar") && killer.HasData("inGangWar"))
|
||||
{
|
||||
Gangwar.Gangwar.GangwarKill(killer, player);
|
||||
}
|
||||
|
||||
if (player != killer)
|
||||
{
|
||||
Autowanted.Check_AutoWanted(killer, player);
|
||||
string message = "~y~[HINWEIS]: " + killer.Name + " hat " + player.Name + " getötet (" + Managers.WeaponManager.GetCauseOfDeathByHash(reason) + ")";
|
||||
ChatService.BroadcastAdmin(message, AdminLevel.ADMIN);
|
||||
}
|
||||
}
|
||||
|
||||
User user = player.GetUser();
|
||||
if (user.JailTime <= 0)
|
||||
{
|
||||
|
||||
//MEDIC AUFTRAG
|
||||
MedicTask reviveTask = new MedicTask()
|
||||
{
|
||||
@@ -81,49 +83,75 @@ namespace ReallifeGamemode.Server.Events
|
||||
};
|
||||
Medic.AddTaskToList(reviveTask);
|
||||
|
||||
if (player.GetUser().IsAdmin(AdminLevel.ADMIN) == true)
|
||||
{
|
||||
player.TriggerEvent("startDeathTimer", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.TriggerEvent("startDeathTimer", false);
|
||||
if (player.GetUser().IsAdmin(AdminLevel.ADMIN) == true)
|
||||
{
|
||||
player.TriggerEvent("startDeathTimer", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.TriggerEvent("startDeathTimer", false);
|
||||
}
|
||||
|
||||
//TODO PICTURE NOTIFICATION + SOUND für Medics
|
||||
|
||||
player.ClearAttachments();
|
||||
|
||||
using (var userDeath = new DatabaseContext())
|
||||
{
|
||||
List<UserItem> fItem = userDeath.UserItems.Where(u => u.UserId == user.Id).ToList();
|
||||
foreach (var item in fItem)
|
||||
{
|
||||
IItem iItem = InventoryManager.GetItemById(item.ItemId);
|
||||
if (iItem is IWeaponDealItem obj)
|
||||
{
|
||||
int amount = item.Amount;
|
||||
|
||||
Vector3 dropPosition = PlayerExtension.GetPositionFromPlayer(player, 0.6f, 0);
|
||||
//new Vector3(player.Position.X, player.Position.Y, player.Position.Z - 0.8f);
|
||||
Random r = new Random();
|
||||
GTANetworkAPI.Object grndObject;
|
||||
Vector3 textPos = dropPosition;
|
||||
|
||||
dropPosition.Z -= 1.05f;
|
||||
grndObject = NAPI.Object.CreateObject(3666746839, dropPosition, new Vector3(0, 0, r.Next(0, 360)), 255, 0);
|
||||
|
||||
GroundItem grndItem = new GroundItem { ItemId = iItem.Id, Amount = amount, Position = dropPosition };
|
||||
TextLabel grndTxtLbl = NAPI.TextLabel.CreateTextLabel(iItem.Name + " ~s~(~y~" + amount + "~s~)", textPos, 5, 0.5f, 4, new Color(255, 255, 255), false, 0);
|
||||
GroundItem.AddGroundItem(grndItem, grndObject, grndTxtLbl);
|
||||
|
||||
userDeath.Remove(item);
|
||||
}
|
||||
}
|
||||
|
||||
var dead = new Database.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();
|
||||
}
|
||||
}
|
||||
|
||||
//JailTime.cs
|
||||
Jail.Check_PutBehindBars(player);
|
||||
}
|
||||
|
||||
//TODO PICTURE NOTIFICATION + SOUND für Medics
|
||||
|
||||
using (var userDeath = new DatabaseContext())
|
||||
[RemoteEvent("RespawnPlayerAtHospital")]
|
||||
public void RespawnPlayerAtHospital(Player player)
|
||||
{
|
||||
var dead = new Database.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();
|
||||
player.SetData("isDead", false);
|
||||
player.RemoveAllWeapons();
|
||||
NAPI.Player.SpawnPlayer(player, new Vector3(-495.45, -336.33, 34.5));
|
||||
}
|
||||
}
|
||||
|
||||
//JailTime.cs
|
||||
Jail.Check_PutBehindBars(player);
|
||||
}
|
||||
|
||||
|
||||
[RemoteEvent("RespawnPlayerAtHospital")]
|
||||
public void RespawnPlayerAtHospital(Player player)
|
||||
{
|
||||
player.SetData("isDead", false);
|
||||
player.RemoveAllWeapons();
|
||||
NAPI.Player.SpawnPlayer(player, new Vector3(-495.45, -336.33, 34.5));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Job;
|
||||
using ReallifeGamemode.Server.Managers;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
using ReallifeGamemode.Database;
|
||||
using ReallifeGamemode.Server.Types;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Event Login (Login.cs)
|
||||
@@ -21,50 +16,50 @@ using ReallifeGamemode.Server.Types;
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
public class Disconnect : Script
|
||||
{
|
||||
[ServerEvent(Event.PlayerDisconnected)]
|
||||
public void OnPlayerDisconnected(Player player, DisconnectionType type, string reason)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
[ServerEvent(Event.PlayerDisconnected)]
|
||||
public void OnPlayerDisconnected(Player player, DisconnectionType type, string reason)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
|
||||
if (type == DisconnectionType.Left)
|
||||
{
|
||||
NAPI.Util.ConsoleOutput(player.Name + " left");
|
||||
}
|
||||
if (type == DisconnectionType.Kicked)
|
||||
{
|
||||
NAPI.Util.ConsoleOutput(player.Name + " kicked");
|
||||
}
|
||||
if (type == DisconnectionType.Timeout)
|
||||
{
|
||||
NAPI.Util.ConsoleOutput(player.Name + " Timeoutet");
|
||||
}
|
||||
if (type == DisconnectionType.Left)
|
||||
{
|
||||
NAPI.Util.ConsoleOutput(player.Name + " left");
|
||||
}
|
||||
if (type == DisconnectionType.Kicked)
|
||||
{
|
||||
NAPI.Util.ConsoleOutput(player.Name + " kicked");
|
||||
}
|
||||
if (type == DisconnectionType.Timeout)
|
||||
{
|
||||
NAPI.Util.ConsoleOutput(player.Name + " Timeoutet");
|
||||
}
|
||||
|
||||
if (GlobalHelper.DutyAdmins.Contains(player))
|
||||
{
|
||||
GlobalHelper.DutyAdmins.Remove(player);
|
||||
}
|
||||
if (GlobalHelper.DutyAdmins.Contains(player))
|
||||
{
|
||||
GlobalHelper.DutyAdmins.Remove(player);
|
||||
}
|
||||
|
||||
if (player.GetUser().IsAdmin(AdminLevel.MAPPING))
|
||||
{
|
||||
ChatService.BroadcastAdmin("!{#FFFF00}*** " + player.Name + " hat den Server verlassen", AdminLevel.MAPPING);
|
||||
}
|
||||
if (player.GetUser().IsAdmin(AdminLevel.MAPPING))
|
||||
{
|
||||
ChatService.BroadcastAdmin("!{#FFFF00}*** " + player.Name + " hat den Server verlassen", AdminLevel.MAPPING);
|
||||
}
|
||||
|
||||
JobBase job = JobManager.GetJob(player.GetUser().JobId ?? -1);
|
||||
if (job != null) job.StopJob(player, true);
|
||||
JobBase job = JobManager.GetJob(player.GetUser().JobId ?? -1);
|
||||
if (job != null) job.StopJob(player, true);
|
||||
|
||||
using (var saveUser = new DatabaseContext())
|
||||
{
|
||||
var user = player.GetUser(saveUser);
|
||||
Vector3 pos = player.Position;
|
||||
using (var saveUser = new DatabaseContext())
|
||||
{
|
||||
var user = player.GetUser(saveUser);
|
||||
Vector3 pos = player.Position;
|
||||
|
||||
user.PositionX = pos.X;
|
||||
user.PositionY = pos.Y;
|
||||
user.PositionZ = pos.Z;
|
||||
saveUser.SaveChanges();
|
||||
user.Dead = player.HasData("isDead") ? (bool)player.GetData<bool>("isDead") : false;
|
||||
}
|
||||
player.SetData("isLoggedIn", false);
|
||||
user.PositionX = pos.X;
|
||||
user.PositionY = pos.Y;
|
||||
user.PositionZ = pos.Z;
|
||||
saveUser.SaveChanges();
|
||||
user.Dead = player.HasData("isDead") ? (bool)player.GetData<bool>("isDead") : false;
|
||||
}
|
||||
player.SetData("isLoggedIn", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
@@ -19,16 +17,16 @@ namespace ReallifeGamemode.Server.Events
|
||||
return;
|
||||
}
|
||||
|
||||
if (vehicle.HasMarkerBehind())
|
||||
vehicle.RemoveMarkerBehind();
|
||||
|
||||
if (vehicle.GetServerVehicle() is FactionVehicle veh)
|
||||
{
|
||||
User u = client.GetUser();
|
||||
if (u.FactionId != null && (!veh.GetOwners().Contains(u.FactionId.Value)) && (veh.Model == VehicleHash.Burrito3) && vehicle.HasData("weaponDeal") && vehicle.GetData<bool>("weaponDeal") == true)
|
||||
if (u.FactionId != null && (veh.GetOwners().Contains(u.FactionId.Value)) && (veh.Model == VehicleHash.Burrito3) && vehicle.HasData("weaponDeal") && vehicle.GetData<bool>("weaponDeal") == true)
|
||||
{
|
||||
Vector3 vector = WeaponDealPoints.getRndWD_Route(client.GetUser().FactionId.Value);
|
||||
if (vector == new Vector3())
|
||||
return;
|
||||
List<Vector3> dealPoint = new List<Vector3>();
|
||||
dealPoint.Add(vector);
|
||||
dealPoint.Add(vehicle.GetData<Vector3>("weaponDealPoint"));
|
||||
CheckPointHandle.StartCheckPointRoute(client, dealPoint, 5000, 1, 7, "loadWeaponTransport");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Types;
|
||||
@@ -10,51 +7,50 @@ using ReallifeGamemode.Server.WeaponDeal;
|
||||
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
|
||||
public class EnterVehicleAttempt : Script
|
||||
{
|
||||
[ServerEvent(Event.PlayerEnterVehicleAttempt)]
|
||||
public void OnPlayerEnterVehicleAttempt(Player player, GTANetworkAPI.Vehicle vehicle, sbyte seat)
|
||||
{
|
||||
if ((VehicleHash)vehicle.Model == VehicleHash.Dune3)
|
||||
{
|
||||
if (seat == 1) seat = 0;
|
||||
else if (seat == 0) seat = 1;
|
||||
}
|
||||
|
||||
if (seat != 0) return;
|
||||
|
||||
User u = player.GetUser();
|
||||
|
||||
if (vehicle.GetServerVehicle() is FactionVehicle veh)
|
||||
{
|
||||
if (!veh.GetOwners().Contains(player.GetUser().FactionId ?? 0) && !(u.IsAdmin(AdminLevel.HEADADMIN) && GlobalHelper.DutyAdmins.Contains(player)))
|
||||
[ServerEvent(Event.PlayerEnterVehicleAttempt)]
|
||||
public void OnPlayerEnterVehicleAttempt(Player player, GTANetworkAPI.Vehicle vehicle, sbyte seat)
|
||||
{
|
||||
if ((VehicleHash)vehicle.Model == VehicleHash.Burrito3)
|
||||
{
|
||||
if (WeaponDealManager.checkWeaponDbyVehicle(vehicle))
|
||||
return;
|
||||
}
|
||||
player.StopAnimation();
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht benutzen!", true);
|
||||
return;
|
||||
if ((VehicleHash)vehicle.Model == VehicleHash.Dune3)
|
||||
{
|
||||
if (seat == 1) seat = 0;
|
||||
else if (seat == 0) seat = 1;
|
||||
}
|
||||
|
||||
if (seat != 0) return;
|
||||
|
||||
User u = player.GetUser();
|
||||
|
||||
if (vehicle.GetServerVehicle() is FactionVehicle veh)
|
||||
{
|
||||
if (!veh.GetOwners().Contains(player.GetUser().FactionId ?? 0) && !(u.IsAdmin(AdminLevel.HEADADMIN) && GlobalHelper.DutyAdmins.Contains(player)))
|
||||
{
|
||||
if ((VehicleHash)vehicle.Model == VehicleHash.Burrito3)
|
||||
{
|
||||
if (WeaponDealManager.checkWeaponDbyVehicle(vehicle))
|
||||
return;
|
||||
}
|
||||
player.StopAnimation();
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht benutzen!", true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (vehicle.GetServerVehicle() is SchoolVehicle sVeh)
|
||||
{
|
||||
if (!player.HasData("ActiveSchool"))
|
||||
{
|
||||
player.StopAnimation();
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht benutzen!", true);
|
||||
return;
|
||||
}
|
||||
if (sVeh.SchoolId != player.GetData<int>("ActiveSchool"))
|
||||
{
|
||||
player.StopAnimation();
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht benutzen!", true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (vehicle.GetServerVehicle() is SchoolVehicle sVeh)
|
||||
{
|
||||
if (!player.HasData("ActiveSchool"))
|
||||
{
|
||||
player.StopAnimation();
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht benutzen!", true);
|
||||
return;
|
||||
}
|
||||
if (sVeh.SchoolId != player.GetData<int>("ActiveSchool"))
|
||||
{
|
||||
player.StopAnimation();
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht benutzen!", true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Managers;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using ReallifeGamemode.Server.WeaponDeal;
|
||||
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
@@ -15,8 +11,11 @@ namespace ReallifeGamemode.Server.Events
|
||||
[ServerEvent(Event.PlayerExitVehicleAttempt)]
|
||||
public void OnPlayerExitVehicle(Player client, GTANetworkAPI.Vehicle vehicle)
|
||||
{
|
||||
if (client.VehicleSeat != -1)
|
||||
if (client.VehicleSeat != 0)
|
||||
return;
|
||||
|
||||
client.TriggerEvent("SERVER:setMarkerBehindVehicle", vehicle);
|
||||
|
||||
if (vehicle.GetServerVehicle() is FactionVehicle veh)
|
||||
{
|
||||
User u = client.GetUser();
|
||||
@@ -25,6 +24,10 @@ namespace ReallifeGamemode.Server.Events
|
||||
CheckPointHandle.RemovePlayerHandlerFromList(client);
|
||||
client.TriggerEvent("destroyCP");
|
||||
}
|
||||
else if ((u.FactionId != null) && (veh.GetOwners().Contains(u.FactionId ?? 0)) && ((VehicleHash)vehicle.Model == VehicleHash.Burrito3) && vehicle.HasData("WeaponDealLoad") && vehicle.GetData<bool>("WeaponDealLoad") == true)
|
||||
{
|
||||
client.TriggerEvent("SERVER:setMarkerBehindVehicle", vehicle);
|
||||
}
|
||||
}
|
||||
if (vehicle.GetServerVehicle() is SchoolVehicle vehS)
|
||||
{
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
using GTANetworkAPI;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using GTANetworkAPI;
|
||||
using Newtonsoft.Json;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
class Faction : Script
|
||||
internal class Faction : Script
|
||||
{
|
||||
[RemoteEvent("OnFactionRanksEdit")]
|
||||
public void OnFactionRanksEdit(Player player, string jsonData)
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
@@ -9,72 +7,69 @@ using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Inventory.Interfaces;
|
||||
using ReallifeGamemode.Server.Managers;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
public class Inventory : Script
|
||||
{
|
||||
[RemoteEvent("getNearVehicles")]
|
||||
public void SrvEvent_GetNearVehicles(Player client)
|
||||
{
|
||||
var user = client.GetUser();
|
||||
if (!client.IsInVehicle)
|
||||
{
|
||||
using (var context = new DatabaseContext())
|
||||
[RemoteEvent("getNearVehicles")]
|
||||
public void SrvEvent_GetNearVehicles(Player client)
|
||||
{
|
||||
foreach (GTANetworkAPI.Vehicle veh in NAPI.Pools.GetAllVehicles())
|
||||
{
|
||||
List<VehicleInventory> vehicleInventory = new List<VehicleInventory>();
|
||||
if (veh.Position.DistanceTo(client.Position) < 5f)
|
||||
var user = client.GetUser();
|
||||
if (!client.IsInVehicle)
|
||||
{
|
||||
if (VehicleStreaming.GetDoorState(veh, DoorID.DoorTrunk) == DoorState.DoorOpen || VehicleStreaming.GetDoorState(veh, DoorID.DoorRearLeft) == DoorState.DoorOpen || VehicleStreaming.GetDoorState(veh, DoorID.DoorRearRight) == DoorState.DoorOpen)
|
||||
{
|
||||
vehicleInventory = getVehItem(veh);
|
||||
}
|
||||
client.TriggerEvent("setVehiclesInventory", vehicleInventory.ToArray());
|
||||
return;
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
foreach (GTANetworkAPI.Vehicle veh in NAPI.Pools.GetAllVehicles())
|
||||
{
|
||||
List<VehicleInventory> vehicleInventory = new List<VehicleInventory>();
|
||||
if (veh.Position.DistanceTo(client.Position) < 5f)
|
||||
{
|
||||
if (VehicleStreaming.GetDoorState(veh, DoorID.DoorTrunk) == DoorState.DoorOpen || VehicleStreaming.GetDoorState(veh, DoorID.DoorRearLeft) == DoorState.DoorOpen || VehicleStreaming.GetDoorState(veh, DoorID.DoorRearRight) == DoorState.DoorOpen)
|
||||
{
|
||||
vehicleInventory = getVehItem(veh);
|
||||
}
|
||||
client.TriggerEvent("setVehiclesInventory", vehicleInventory.ToArray());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<VehicleInventory> getVehItem(GTANetworkAPI.Vehicle veh)
|
||||
{
|
||||
List<string> iName = new List<string>();
|
||||
List<int> iAmount = new List<int>();
|
||||
List<int> iId = new List<int>();
|
||||
List<VehicleInventory> vehicleInventory = new List<VehicleInventory>();
|
||||
var inventoryWeight = 0;
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
ServerVehicle serverVehicle = VehicleManager.GetServerVehicleFromVehicle(veh, context);
|
||||
List<VehicleItem> vehicleItems = context.VehicleItems.ToList().FindAll(i => i.VehicleId == serverVehicle.Id);
|
||||
foreach (var vehItem in vehicleItems)
|
||||
public List<VehicleInventory> getVehItem(GTANetworkAPI.Vehicle veh)
|
||||
{
|
||||
IItem iItem = InventoryManager.GetItemById(vehItem.ItemId);
|
||||
var currentItemWeight = iItem.Gewicht * vehItem.Amount;
|
||||
inventoryWeight += currentItemWeight;
|
||||
|
||||
iName.Add(iItem.Name);
|
||||
iAmount.Add(vehItem.Amount);
|
||||
iId.Add(iItem.Id);
|
||||
List<string> iName = new List<string>();
|
||||
List<int> iAmount = new List<int>();
|
||||
List<int> iId = new List<int>();
|
||||
List<VehicleInventory> vehicleInventory = new List<VehicleInventory>();
|
||||
var inventoryWeight = 0;
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
ServerVehicle serverVehicle = VehicleManager.GetServerVehicleFromVehicle(veh, context);
|
||||
List<VehicleItem> vehicleItems = context.VehicleItems.ToList().FindAll(i => i.VehicleId == serverVehicle.Id);
|
||||
foreach (var vehItem in vehicleItems)
|
||||
{
|
||||
IItem iItem = InventoryManager.GetItemById(vehItem.ItemId);
|
||||
var currentItemWeight = iItem.Gewicht * vehItem.Amount;
|
||||
inventoryWeight += currentItemWeight;
|
||||
|
||||
iName.Add(iItem.Name);
|
||||
iAmount.Add(vehItem.Amount);
|
||||
iId.Add(iItem.Id);
|
||||
}
|
||||
var vehInv = new VehicleInventory
|
||||
{
|
||||
ID = serverVehicle.Id,
|
||||
currentWeight = inventoryWeight,
|
||||
totalWeight = 250,
|
||||
ivehName = iName.ToArray(),
|
||||
ivehAmount = iAmount.ToArray(),
|
||||
ivehId = iId.ToArray()
|
||||
};
|
||||
vehicleInventory.Add(vehInv);
|
||||
}
|
||||
return vehicleInventory;
|
||||
}
|
||||
var vehInv = new VehicleInventory
|
||||
{
|
||||
ID = serverVehicle.Id,
|
||||
currentWeight = inventoryWeight,
|
||||
totalWeight = 250,
|
||||
ivehName = iName.ToArray(),
|
||||
ivehAmount = iAmount.ToArray(),
|
||||
ivehId = iId.ToArray()
|
||||
};
|
||||
vehicleInventory.Add(vehInv);
|
||||
}
|
||||
return vehicleInventory;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,21 +2,21 @@
|
||||
using System.Linq;
|
||||
using GTANetworkAPI;
|
||||
using Newtonsoft.Json;
|
||||
using ReallifeGamemode.Server.Classes;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Classes;
|
||||
using ReallifeGamemode.Server.DrivingSchool;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Factions.Medic;
|
||||
using ReallifeGamemode.Server.Finance;
|
||||
using ReallifeGamemode.Server.Inventory;
|
||||
using ReallifeGamemode.Server.Inventory.Interfaces;
|
||||
using ReallifeGamemode.Server.Managers;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
using ReallifeGamemode.Database;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using ReallifeGamemode.Server.Inventory.Interfaces;
|
||||
using ReallifeGamemode.Server.DrivingSchool;
|
||||
using ReallifeGamemode.Server.Types;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using ReallifeGamemode.Server.WeaponDeal;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Event Key (Key.cs)
|
||||
* @author VegaZ
|
||||
@@ -46,6 +46,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
tempBlip.Transparency.ToString(), 200.ToString(), tempBlip.ShortRange.ToString(), 0.ToString(), 0.ToString());
|
||||
player.SendNotification("~y~Blip~s~ erstellt!", false);
|
||||
break;
|
||||
|
||||
case "atm":
|
||||
SaveManager.OnSaveBlipData(player, "500", "Geldautomat", 0.7.ToString(), "11",
|
||||
"0", "200", true.ToString(), 0.ToString(), 0.ToString());
|
||||
@@ -170,7 +171,6 @@ namespace ReallifeGamemode.Server.Events
|
||||
if (!player.IsLoggedIn()) return;
|
||||
var user = player.GetUser();
|
||||
|
||||
|
||||
if (user?.FactionId != null)
|
||||
{
|
||||
DutyPoint nearestDuty = PositionManager.DutyPoints.Find(d => d.Position.DistanceTo(player.Position) <= 1.5 && d.FactionId == user.FactionId);
|
||||
@@ -179,7 +179,63 @@ namespace ReallifeGamemode.Server.Events
|
||||
ElevatorPoint nearestElevatorPoint = PositionManager.ElevatorPoints.Find(e => e.Position.DistanceTo(player.Position) <= 1.5 && (user.FactionId == 1 || user.FactionId == 3));
|
||||
ClotheshopPoint nearestClotheShopPoint = PositionManager.clotheshopPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.5 && (!user.GetData<bool>("duty")));
|
||||
ItemshopPoint nearestItemShopPoint = PositionManager.itemshopPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.5);
|
||||
BehindVehiclePoint nearestBehindVehiclePoint = MarkerBehinVehicle.behindVehiclePoints.Find(s => s.marker.Position.DistanceTo(player.Position) <= 3 && (user.FactionId == 8 || user.FactionId == 7 || user.FactionId == 1 || user.FactionId == 3));
|
||||
|
||||
if (nearestBehindVehiclePoint != null)
|
||||
{
|
||||
if (player.HasAttachment("ammobox")) return;
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
List<VehicleItem> vehicleItems = dbContext.VehicleItems.Where(f => f.GetVehicle().GetVehicle() == nearestBehindVehiclePoint.vehicle && InventoryManager.GetItemById(f.ItemId) is IWeaponDealItem).ToList();
|
||||
if (vehicleItems.Count == 0)
|
||||
{
|
||||
GTANetworkAPI.Vehicle vehicle = nearestBehindVehiclePoint.vehicle;
|
||||
|
||||
if (WeaponDealManager.checkWeaponDbyVehicle(vehicle))
|
||||
{
|
||||
vehicle.ResetData("WeaponDealLoad");
|
||||
}
|
||||
|
||||
nearestBehindVehiclePoint.vehicle.RemoveMarkerBehind();
|
||||
|
||||
return;
|
||||
}
|
||||
foreach (var v in vehicleItems)
|
||||
{
|
||||
int itemToAdd = 0;
|
||||
for (int i = 1; i <= v.Amount; i++)
|
||||
{
|
||||
if (InventoryManager.GetUserInventoryWeight(player) + (i * InventoryManager.GetItemById(v.ItemId).Gewicht) > 40000)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
itemToAdd = i;
|
||||
}
|
||||
}
|
||||
if (itemToAdd == 0)
|
||||
break;
|
||||
|
||||
v.Amount -= itemToAdd;
|
||||
if (v.Amount <= 0)
|
||||
dbContext.VehicleItems.Remove(v);
|
||||
|
||||
var newItem = new UserItem()
|
||||
{
|
||||
ItemId = v.ItemId,
|
||||
Slot = v.Slot,
|
||||
Amount = itemToAdd,
|
||||
UserId = user.Id,
|
||||
};
|
||||
|
||||
InventoryManager.AddItemToInventory(player, newItem.Id, newItem.Amount);
|
||||
nearestBehindVehiclePoint.usePoint(player);
|
||||
dbContext.SaveChanges();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (nearestDuty != null)// Duty Point
|
||||
{
|
||||
var nameTagColor = new Color(0, 0, 0);
|
||||
@@ -259,7 +315,6 @@ namespace ReallifeGamemode.Server.Events
|
||||
}
|
||||
if (nearestWeapon != null) // Weapon Point
|
||||
{
|
||||
|
||||
List<string> primarys = new List<string>();
|
||||
List<string> secondarys = new List<string>();
|
||||
List<string> melees = new List<string>();
|
||||
@@ -271,11 +326,13 @@ namespace ReallifeGamemode.Server.Events
|
||||
melees.Add("Keine");
|
||||
specials.Add("Keine");
|
||||
|
||||
|
||||
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
|
||||
if (player.HasAttachment("ammobox"))
|
||||
{
|
||||
player.AddAttachment("ammobox", true);
|
||||
player.StopAnimation();
|
||||
}
|
||||
|
||||
List<UserItem> fItem = context.UserItems.Where(u => u.UserId == user.Id).ToList();
|
||||
foreach (var item in fItem)
|
||||
@@ -285,7 +342,11 @@ namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
FactionWeapon weapon = context.FactionWeapons.Where(w => w.FactionId == user.FactionId && w.WeaponModel == iItem.Name).FirstOrDefault();
|
||||
if (weapon == null)
|
||||
{
|
||||
context.Remove(item);
|
||||
continue;
|
||||
}
|
||||
|
||||
weapon.Ammount += item.Amount;
|
||||
ChatService.SendMessage(player, item.Amount + " " + iItem.Name + " wurden im Waffenlager hinzugefürgt.");
|
||||
context.Remove(item);
|
||||
@@ -311,14 +372,17 @@ namespace ReallifeGamemode.Server.Events
|
||||
if (user.FactionRank.Order >= weapon.Rank)
|
||||
primarys.Add(weapon.WeaponModel.ToString());
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if (user.FactionRank.Order >= weapon.Rank)
|
||||
secondarys.Add(weapon.WeaponModel.ToString());
|
||||
break;
|
||||
|
||||
case 3:
|
||||
if (user.FactionRank.Order >= weapon.Rank)
|
||||
melees.Add(weapon.WeaponModel.ToString());
|
||||
break;
|
||||
|
||||
case 4:
|
||||
if (user.FactionRank.Order >= weapon.Rank)
|
||||
specials.Add(weapon.WeaponModel.ToString());
|
||||
@@ -374,7 +438,8 @@ namespace ReallifeGamemode.Server.Events
|
||||
public void KeyPressI(Player player)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
InventoryManager.GetUserItems(player);
|
||||
player.TriggerEvent("inventoryShow");
|
||||
InventoryManager.SetBackpackItems(player);
|
||||
}
|
||||
|
||||
[RemoteEvent("keyPress:O")]
|
||||
@@ -429,9 +494,11 @@ namespace ReallifeGamemode.Server.Events
|
||||
case 11:
|
||||
tops.Add(cloth.ClothId.ToString());
|
||||
break;
|
||||
|
||||
case 4:
|
||||
legs.Add(cloth.ClothId.ToString());
|
||||
break;
|
||||
|
||||
case 6:
|
||||
shoes.Add(cloth.ClothId.ToString());
|
||||
break;
|
||||
@@ -441,7 +508,6 @@ namespace ReallifeGamemode.Server.Events
|
||||
player.TriggerEvent("showDutyClothMenu", hats.ToArray(), tops.ToArray(), legs.ToArray(), shoes.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[RemoteEvent("keyPress:L")]
|
||||
@@ -526,7 +592,6 @@ namespace ReallifeGamemode.Server.Events
|
||||
|
||||
if (!player.IsInVehicle)
|
||||
{
|
||||
|
||||
Vehicle.VehicleMenuLockCarEvent(player);
|
||||
|
||||
GroundItem.PickUpGroundItem(player);
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
using System.Linq;
|
||||
using GTANetworkAPI;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Newtonsoft.Json;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Managers;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
using ReallifeGamemode.Server.Types;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using ReallifeGamemode.Server.Wanted;
|
||||
using ReallifeGamemode.Database;
|
||||
using ReallifeGamemode.Server.Types;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Event Login (Login.cs)
|
||||
@@ -21,138 +19,141 @@ using Newtonsoft.Json;
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
public class Login : Script
|
||||
{
|
||||
[RemoteEvent("CLIENT:Login_LoginRequest")]
|
||||
public void OnPlayerLogin(Player player, string username, string password)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
var user = dbContext.Users
|
||||
.Include(u => u.Group)
|
||||
.Include(u => u.BankAccount)
|
||||
.SingleOrDefault(b => b.Name == username);
|
||||
|
||||
if (user == null)
|
||||
[RemoteEvent("CLIENT:Login_LoginRequest")]
|
||||
public void OnPlayerLogin(Player player, string username, string password)
|
||||
{
|
||||
player.TriggerEvent("SERVER:Login_Error", "Benutzer existiert nicht! Registriere dich zuerst!");
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
var user = dbContext.Users
|
||||
.Include(u => u.Group)
|
||||
.Include(u => u.BankAccount)
|
||||
.SingleOrDefault(b => b.Name == username);
|
||||
|
||||
if (user == null)
|
||||
{
|
||||
player.TriggerEvent("SERVER:Login_Error", "Benutzer existiert nicht! Registriere dich zuerst!");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (user.SocialClubName != player.SocialClubName && user.Password == NAPI.Util.GetHashSha256(password))
|
||||
{
|
||||
player.TriggerEvent("SERVER:Login_Error", "Dieser Benutzer gehört dir nicht!");
|
||||
//TODO ?? Log einbauen für den bösen Bub.
|
||||
player.Kick();
|
||||
}
|
||||
if (user.Password != NAPI.Util.GetHashSha256(password))
|
||||
{
|
||||
player.TriggerEvent("SERVER:Login_Error", "Passwort inkorrekt!");
|
||||
}
|
||||
else
|
||||
{
|
||||
player.Name = username;
|
||||
player.TriggerEvent("SERVER:Login_Success");
|
||||
player.SetData("isLoggedIn", true);
|
||||
player.SetSharedData("isLoggedIn", JsonConvert.SerializeObject(true));
|
||||
player.SetData("spec", true);
|
||||
player.SetData("duty", false);
|
||||
player.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney, 0);
|
||||
Gangwar.Gangwar.loadPlayer(player);
|
||||
if (user.FactionLeader)
|
||||
{
|
||||
player.TriggerEvent("CLIENT:Turf_LoadLeaderBlip");
|
||||
}
|
||||
if (user.IsAdmin(AdminLevel.HEADADMIN))
|
||||
{
|
||||
player.SetData("editmode", false);
|
||||
player.SetData("quicksavemode", "none");
|
||||
}
|
||||
|
||||
var userBankAccount = user.BankAccount;
|
||||
userBankAccount.Balance = userBankAccount.Balance;
|
||||
|
||||
user.Wanteds = user.Wanteds;
|
||||
|
||||
if (user.Group != null)
|
||||
{
|
||||
string msg = $"{player.Name} ist wieder online.";
|
||||
ChatService.BroadcastGroup(msg, user.Group);
|
||||
}
|
||||
|
||||
if (GlobalHelper.CustomJoinMessages.ContainsKey(player.SocialClubName))
|
||||
{
|
||||
ChatService.BroadcastAdmin("!{#FFFF00}*** " + GlobalHelper.CustomJoinMessages[player.SocialClubName] + " [ID: " + player.Handle.Value + "] (" + user.AdminLevel.GetName() + ")", AdminLevel.MAPPING);
|
||||
}
|
||||
else if (user.IsAdmin(AdminLevel.MAPPING))
|
||||
{
|
||||
ChatService.BroadcastAdmin("!{#FFFF00}*** " + user.Name + " [ID: " + player.Handle.Value + "]" + " hat sich als " + user.AdminLevel.GetName() + " eingeloggt!", AdminLevel.MAPPING);
|
||||
}
|
||||
|
||||
var userItems = dbContext.UserItems.Where(u => u.UserId == user.Id).ToList();
|
||||
player.SetData("items", userItems);
|
||||
|
||||
switch (user.FactionId)
|
||||
{
|
||||
case null:
|
||||
player.SetSharedData("blipColor", 0);
|
||||
break;
|
||||
|
||||
case 8:
|
||||
player.SetSharedData("blipColor", 83);
|
||||
break;
|
||||
|
||||
case 7:
|
||||
player.SetSharedData("blipColor", 52);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
player.SetSharedData("blipColor", 5);
|
||||
break;
|
||||
}
|
||||
|
||||
if (user.CharacterId == null)
|
||||
{
|
||||
var currentPlayerCreatorDimension = (uint)NAPI.Data.GetWorldData("playerCreatorDimension");
|
||||
currentPlayerCreatorDimension++;
|
||||
NAPI.Data.SetWorldData("playerCreatorDimension", currentPlayerCreatorDimension);
|
||||
player.Dimension = NAPI.Data.GetWorldData("playerCreatorDimension");
|
||||
player.Position = new Vector3(402.8664, -996.4108, -99.00027);
|
||||
player.Rotation = new Vector3(0, 0, 180);
|
||||
player.TriggerEvent("toggleCreator");
|
||||
}
|
||||
else
|
||||
{
|
||||
CharacterCreator.ApplyCharacter(player);
|
||||
UpdateCharacterCloth.LoadCharacterDefaults(player);
|
||||
if (user.JailTime <= 0)
|
||||
{
|
||||
NAPI.Player.SpawnPlayer(player, new Vector3(user.PositionX, user.PositionY, user.PositionZ), 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
Jail.Check_PutBehindBars(player);
|
||||
}
|
||||
}
|
||||
|
||||
player.TriggerEvent("draw", player.Name, player.Handle.Value);
|
||||
if (user.Dead == true)
|
||||
{
|
||||
if (user.IsAdmin(AdminLevel.ADMIN) == true)
|
||||
{
|
||||
player.TriggerEvent("startDeathTimer", true);
|
||||
player.Health = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
player.TriggerEvent("startDeathTimer", false);
|
||||
player.Health = 0;
|
||||
}
|
||||
player.SetData("isDead", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.SetData("isDead", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (user.SocialClubName != player.SocialClubName && user.Password == NAPI.Util.GetHashSha256(password))
|
||||
{
|
||||
player.TriggerEvent("SERVER:Login_Error", "Dieser Benutzer gehört dir nicht!");
|
||||
//TODO ?? Log einbauen für den bösen Bub.
|
||||
player.Kick();
|
||||
}
|
||||
if (user.Password != NAPI.Util.GetHashSha256(password))
|
||||
{
|
||||
player.TriggerEvent("SERVER:Login_Error", "Passwort inkorrekt!");
|
||||
}
|
||||
else
|
||||
{
|
||||
player.Name = username;
|
||||
player.TriggerEvent("SERVER:Login_Success");
|
||||
player.SetData("isLoggedIn", true);
|
||||
player.SetSharedData("isLoggedIn", JsonConvert.SerializeObject(true));
|
||||
player.SetData("spec", true);
|
||||
player.SetData("duty", false);
|
||||
player.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney, 0);
|
||||
Gangwar.Gangwar.loadPlayer(player);
|
||||
if (user.FactionLeader)
|
||||
{
|
||||
player.TriggerEvent("CLIENT:Turf_LoadLeaderBlip");
|
||||
}
|
||||
if (user.IsAdmin(AdminLevel.HEADADMIN))
|
||||
{
|
||||
player.SetData("editmode", false);
|
||||
player.SetData("quicksavemode", "none");
|
||||
}
|
||||
|
||||
var userBankAccount = user.BankAccount;
|
||||
userBankAccount.Balance = userBankAccount.Balance;
|
||||
|
||||
user.Wanteds = user.Wanteds;
|
||||
|
||||
if (user.Group != null)
|
||||
{
|
||||
string msg = $"{player.Name} ist wieder online.";
|
||||
ChatService.BroadcastGroup(msg, user.Group);
|
||||
}
|
||||
|
||||
if (GlobalHelper.CustomJoinMessages.ContainsKey(player.SocialClubName))
|
||||
{
|
||||
ChatService.BroadcastAdmin("!{#FFFF00}*** " + GlobalHelper.CustomJoinMessages[player.SocialClubName] + " [ID: " + player.Handle.Value + "] (" + user.AdminLevel.GetName() + ")", AdminLevel.MAPPING);
|
||||
}
|
||||
else if (user.IsAdmin(AdminLevel.MAPPING))
|
||||
{
|
||||
ChatService.BroadcastAdmin("!{#FFFF00}*** " + user.Name + " [ID: " + player.Handle.Value + "]" + " hat sich als " + user.AdminLevel.GetName() + " eingeloggt!", AdminLevel.MAPPING);
|
||||
}
|
||||
|
||||
var userItems = dbContext.UserItems.Where(u => u.UserId == user.Id).ToList();
|
||||
player.SetData("items", userItems);
|
||||
|
||||
switch (user.FactionId)
|
||||
{
|
||||
case null:
|
||||
player.SetSharedData("blipColor", 0);
|
||||
break;
|
||||
case 8:
|
||||
player.SetSharedData("blipColor", 83);
|
||||
break;
|
||||
case 7:
|
||||
player.SetSharedData("blipColor", 52);
|
||||
break;
|
||||
case 4:
|
||||
player.SetSharedData("blipColor", 5);
|
||||
break;
|
||||
}
|
||||
|
||||
if (user.CharacterId == null)
|
||||
{
|
||||
var currentPlayerCreatorDimension = (uint)NAPI.Data.GetWorldData("playerCreatorDimension");
|
||||
currentPlayerCreatorDimension++;
|
||||
NAPI.Data.SetWorldData("playerCreatorDimension", currentPlayerCreatorDimension);
|
||||
player.Dimension = NAPI.Data.GetWorldData("playerCreatorDimension");
|
||||
player.Position = new Vector3(402.8664, -996.4108, -99.00027);
|
||||
player.Rotation = new Vector3(0, 0, 180);
|
||||
player.TriggerEvent("toggleCreator");
|
||||
}
|
||||
else
|
||||
{
|
||||
CharacterCreator.ApplyCharacter(player);
|
||||
UpdateCharacterCloth.LoadCharacterDefaults(player);
|
||||
if (user.JailTime <= 0)
|
||||
{
|
||||
NAPI.Player.SpawnPlayer(player, new Vector3(user.PositionX, user.PositionY, user.PositionZ), 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
Jail.Check_PutBehindBars(player);
|
||||
}
|
||||
}
|
||||
|
||||
player.TriggerEvent("draw", player.Name, player.Handle.Value);
|
||||
if (user.Dead == true)
|
||||
{
|
||||
if (user.IsAdmin(AdminLevel.ADMIN) == true)
|
||||
{
|
||||
player.TriggerEvent("startDeathTimer", true);
|
||||
player.Health = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
player.TriggerEvent("startDeathTimer", false);
|
||||
player.Health = 0;
|
||||
}
|
||||
player.SetData("isDead", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.SetData("isDead", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Linq;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Event Register (Register.cs)
|
||||
@@ -11,7 +11,7 @@ using ReallifeGamemode.Database.Entities;
|
||||
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
class Register : Script
|
||||
internal class Register : Script
|
||||
{
|
||||
[RemoteEvent("CLIENT:Login_RegisterRequest")]
|
||||
public void OnPlayerRegister(Player player, string username, string password, string passwordRepeat)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using GTANetworkAPI;
|
||||
using System.Linq;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using System.Linq;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Event ResourceStop (ResourceStop.cs)
|
||||
@@ -11,24 +11,24 @@ using System.Linq;
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
public class ResourceStop : Script
|
||||
{
|
||||
[ServerEvent(Event.ResourceStop)]
|
||||
public void OnResourceStop()
|
||||
{
|
||||
var users = NAPI.Pools.GetAllPlayers();
|
||||
|
||||
foreach (Player user in users)
|
||||
{
|
||||
using (var saveUsers = new DatabaseContext())
|
||||
[ServerEvent(Event.ResourceStop)]
|
||||
public void OnResourceStop()
|
||||
{
|
||||
var saveUser = saveUsers.Users.SingleOrDefault(u => u.Name == user.Name);
|
||||
var users = NAPI.Pools.GetAllPlayers();
|
||||
|
||||
saveUser.PositionX = user.Position.X;
|
||||
saveUser.PositionY = user.Position.Y;
|
||||
saveUser.PositionZ = user.Position.Z;
|
||||
saveUsers.SaveChanges();
|
||||
foreach (Player user in users)
|
||||
{
|
||||
using (var saveUsers = new DatabaseContext())
|
||||
{
|
||||
var saveUser = saveUsers.Users.SingleOrDefault(u => u.Name == user.Name);
|
||||
|
||||
saveUser.PositionX = user.Position.X;
|
||||
saveUser.PositionY = user.Position.Y;
|
||||
saveUser.PositionZ = user.Position.Z;
|
||||
saveUsers.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
using GTANetworkAPI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using GTANetworkAPI;
|
||||
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
class Siren : Script
|
||||
internal class Siren : Script
|
||||
{
|
||||
private readonly Dictionary<NetHandle, bool> _sirenStates = new Dictionary<NetHandle, bool>();
|
||||
|
||||
@@ -21,7 +19,6 @@ namespace ReallifeGamemode.Server.Events
|
||||
pV.SetSharedData("sirenSound", newValue);
|
||||
|
||||
NAPI.ClientEvent.TriggerClientEventForAll("toggleVehicleSiren", pV, newValue);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,255 +9,253 @@ using ReallifeGamemode.Server.Extensions;
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
public class UpdateCharacterCloth : Script
|
||||
{
|
||||
[RemoteEvent("updateDutyProp")]
|
||||
public void UpdateDutyProp(Player player, int componentId, int componentVariation)
|
||||
{
|
||||
if (componentId != -1)
|
||||
{
|
||||
player.SetAccessories(componentId, componentVariation, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.ClearAccessory(0);
|
||||
player.ClearAccessory(1);
|
||||
player.ClearAccessory(2);
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("updateDutyCloth")]
|
||||
public void UpdateDutyCloth(Player player, int componentId, int componentVariation)
|
||||
{
|
||||
if (componentId == 11)
|
||||
{
|
||||
//TODO Spezielle Duty Kleidung in Datenbank einpflegen (Ergibt bei Cop-Kleidung NULL)
|
||||
using (var context = new DatabaseContext())
|
||||
[RemoteEvent("updateDutyProp")]
|
||||
public void UpdateDutyProp(Player player, int componentId, int componentVariation)
|
||||
{
|
||||
var character = player.GetUser().GetCharacter();
|
||||
|
||||
var combination = context.ClothCombinations.FirstOrDefault(c => c.Top == componentVariation && c.Gender == character.Gender);
|
||||
player.SetClothes(11, componentVariation, 0);
|
||||
if (combination != null)
|
||||
{
|
||||
player.SetClothes(3, combination.Torso, 0);
|
||||
player.SetClothes(8, combination.Undershirt, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.SetClothes(componentId, componentVariation, 0);
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("saveCharacterCloth")]
|
||||
public void SaveDutyCloth(Player client, string JSlotType, string JSlotId, string JClothId)
|
||||
{
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
int[] slotType = JsonConvert.DeserializeObject<int[]>(JSlotType);
|
||||
int[] slotId = JsonConvert.DeserializeObject<int[]>(JSlotId);
|
||||
int[] clothId = JsonConvert.DeserializeObject<int[]>(JClothId);
|
||||
|
||||
User user = client.GetUser();
|
||||
user = context.Users.FirstOrDefault(u => u.Id == user.Id);
|
||||
|
||||
var character = client.GetUser().GetCharacter();
|
||||
|
||||
var charClothes = context.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id);
|
||||
if (charClothes == null)
|
||||
{
|
||||
for (var x = 0; x < slotType.Length; x++)
|
||||
{
|
||||
CharacterCloth newCloth = new CharacterCloth
|
||||
if (componentId != -1)
|
||||
{
|
||||
UserId = user.Id,
|
||||
|
||||
Duty = true,
|
||||
|
||||
SlotType = (byte)slotType[x],
|
||||
SlotId = slotId[x],
|
||||
ClothId = clothId[x]
|
||||
};
|
||||
context.CharacterClothes.Add(newCloth);
|
||||
}
|
||||
if (user.GetCharacter().Gender == false)
|
||||
{
|
||||
CharacterCloth newTorso = new CharacterCloth
|
||||
{
|
||||
UserId = user.Id,
|
||||
|
||||
Duty = true,
|
||||
|
||||
SlotType = 0,
|
||||
SlotId = 3,
|
||||
ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Torso
|
||||
};
|
||||
CharacterCloth newUndershirt = new CharacterCloth
|
||||
{
|
||||
UserId = user.Id,
|
||||
|
||||
Duty = true,
|
||||
|
||||
SlotType = 0,
|
||||
SlotId = 8,
|
||||
ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Undershirt
|
||||
};
|
||||
context.CharacterClothes.Add(newTorso);
|
||||
context.CharacterClothes.Add(newUndershirt);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (var x = 0; x < slotType.Length; x++)
|
||||
{
|
||||
var loopCloth = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == slotType[x] && u.SlotId == slotId[x]);
|
||||
loopCloth.ClothId = clothId[x];
|
||||
}
|
||||
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;
|
||||
}
|
||||
context.SaveChanges();
|
||||
}
|
||||
LoadCharacterDefaults(client);
|
||||
}
|
||||
|
||||
[RemoteEvent("defaultCharacterCloth")]
|
||||
public static void LoadCharacterDefaults(Player player)
|
||||
{
|
||||
User user = player.GetUser();
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
List<CharacterCloth> charClothes = context.CharacterClothes.ToList().FindAll(c => c.UserId == user.Id && c.Duty == false);
|
||||
player.ClearAccessory(0);
|
||||
player.ClearAccessory(1);
|
||||
player.ClearAccessory(2);
|
||||
player.ClearAccessory(6);
|
||||
player.ClearAccessory(7);
|
||||
|
||||
foreach (var cloth in charClothes)
|
||||
{
|
||||
if (cloth.SlotType == 1)
|
||||
{
|
||||
player.SetAccessories(cloth.SlotId, cloth.ClothId, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.SetClothes(cloth.SlotId, cloth.ClothId, cloth.Texture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("SERVER:BuyCharacterClothes")]
|
||||
public void RmtEvent_BuyClothes(Player client, string type, string jsonData)
|
||||
{
|
||||
/*
|
||||
* [0] ComponentID
|
||||
* [1] TextureID
|
||||
* [2] ClotheID
|
||||
* [3] TorsoID
|
||||
* [4] UndershirtID
|
||||
* [5] UndershirtTextureID
|
||||
* [6] Price
|
||||
*/
|
||||
|
||||
int[] data = JsonConvert.DeserializeObject<int[]>(jsonData);
|
||||
User user = client.GetUser();
|
||||
if (user.Handmoney < data[6])
|
||||
{
|
||||
client.TriggerEvent("clothesMenu:Error");
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == "clothe")
|
||||
{
|
||||
if (data[0] == 11)//for tops
|
||||
{
|
||||
client.SetClothes(11, data[2], data[1]); //set Top
|
||||
client.SetClothes(8, data[4], data[5]); //set undershirt
|
||||
client.SetClothes(3, data[3], 0); //set Torso
|
||||
}
|
||||
else
|
||||
{
|
||||
client.SetClothes(data[0], data[2], data[1]);
|
||||
}
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
|
||||
var clothes = dbContext.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id && c.SlotId == data[0] && c.Duty == false);
|
||||
|
||||
if(clothes == null)
|
||||
{
|
||||
CharacterCloth newCloth = new CharacterCloth
|
||||
{
|
||||
UserId = user.Id,
|
||||
|
||||
Duty = false,
|
||||
|
||||
SlotType = 0,
|
||||
SlotId = data[0],
|
||||
ClothId = data[2],
|
||||
Texture = data[1]
|
||||
};
|
||||
dbContext.CharacterClothes.Add(newCloth);
|
||||
}
|
||||
else
|
||||
{
|
||||
clothes.ClothId = data[2];
|
||||
clothes.Texture = data[1];
|
||||
}
|
||||
if(data[0] == 11)
|
||||
{
|
||||
var torso = dbContext.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id && c.SlotId == 3 && c.Duty == false);
|
||||
var undershirt = dbContext.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id && c.SlotId == 8 && c.Duty == false);
|
||||
if(torso == null)
|
||||
{
|
||||
CharacterCloth newTorso = new CharacterCloth
|
||||
{
|
||||
UserId = user.Id,
|
||||
|
||||
Duty = false,
|
||||
|
||||
SlotType = 0,
|
||||
SlotId = 3,
|
||||
ClothId = data[3]
|
||||
};
|
||||
dbContext.CharacterClothes.Add(newTorso);
|
||||
player.SetAccessories(componentId, componentVariation, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
torso.ClothId = data[3];
|
||||
player.ClearAccessory(0);
|
||||
player.ClearAccessory(1);
|
||||
player.ClearAccessory(2);
|
||||
}
|
||||
if(undershirt == null)
|
||||
}
|
||||
|
||||
[RemoteEvent("updateDutyCloth")]
|
||||
public void UpdateDutyCloth(Player player, int componentId, int componentVariation)
|
||||
{
|
||||
if (componentId == 11)
|
||||
{
|
||||
CharacterCloth newUndershirt = new CharacterCloth
|
||||
{
|
||||
UserId = user.Id,
|
||||
Duty = false,
|
||||
SlotType = 0,
|
||||
SlotId = 8,
|
||||
ClothId = data[4],
|
||||
Texture = data[5]
|
||||
};
|
||||
dbContext.CharacterClothes.Add(newUndershirt);
|
||||
//TODO Spezielle Duty Kleidung in Datenbank einpflegen (Ergibt bei Cop-Kleidung NULL)
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
var character = player.GetUser().GetCharacter();
|
||||
|
||||
var combination = context.ClothCombinations.FirstOrDefault(c => c.Top == componentVariation && c.Gender == character.Gender);
|
||||
player.SetClothes(11, componentVariation, 0);
|
||||
if (combination != null)
|
||||
{
|
||||
player.SetClothes(3, combination.Torso, 0);
|
||||
player.SetClothes(8, combination.Undershirt, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
undershirt.ClothId = data[4];
|
||||
undershirt.Texture = data[5];
|
||||
player.SetClothes(componentId, componentVariation, 0);
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("saveCharacterCloth")]
|
||||
public void SaveDutyCloth(Player client, string JSlotType, string JSlotId, string JClothId)
|
||||
{
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
int[] slotType = JsonConvert.DeserializeObject<int[]>(JSlotType);
|
||||
int[] slotId = JsonConvert.DeserializeObject<int[]>(JSlotId);
|
||||
int[] clothId = JsonConvert.DeserializeObject<int[]>(JClothId);
|
||||
|
||||
User user = client.GetUser();
|
||||
user = context.Users.FirstOrDefault(u => u.Id == user.Id);
|
||||
|
||||
var character = client.GetUser().GetCharacter();
|
||||
|
||||
var charClothes = context.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id);
|
||||
if (charClothes == null)
|
||||
{
|
||||
for (var x = 0; x < slotType.Length; x++)
|
||||
{
|
||||
CharacterCloth newCloth = new CharacterCloth
|
||||
{
|
||||
UserId = user.Id,
|
||||
|
||||
Duty = true,
|
||||
|
||||
SlotType = (byte)slotType[x],
|
||||
SlotId = slotId[x],
|
||||
ClothId = clothId[x]
|
||||
};
|
||||
context.CharacterClothes.Add(newCloth);
|
||||
}
|
||||
if (user.GetCharacter().Gender == false)
|
||||
{
|
||||
CharacterCloth newTorso = new CharacterCloth
|
||||
{
|
||||
UserId = user.Id,
|
||||
|
||||
Duty = true,
|
||||
|
||||
SlotType = 0,
|
||||
SlotId = 3,
|
||||
ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Torso
|
||||
};
|
||||
CharacterCloth newUndershirt = new CharacterCloth
|
||||
{
|
||||
UserId = user.Id,
|
||||
|
||||
Duty = true,
|
||||
|
||||
SlotType = 0,
|
||||
SlotId = 8,
|
||||
ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Undershirt
|
||||
};
|
||||
context.CharacterClothes.Add(newTorso);
|
||||
context.CharacterClothes.Add(newUndershirt);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (var x = 0; x < slotType.Length; x++)
|
||||
{
|
||||
var loopCloth = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == slotType[x] && u.SlotId == slotId[x]);
|
||||
loopCloth.ClothId = clothId[x];
|
||||
}
|
||||
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;
|
||||
}
|
||||
context.SaveChanges();
|
||||
}
|
||||
LoadCharacterDefaults(client);
|
||||
}
|
||||
|
||||
[RemoteEvent("defaultCharacterCloth")]
|
||||
public static void LoadCharacterDefaults(Player player)
|
||||
{
|
||||
User user = player.GetUser();
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
List<CharacterCloth> charClothes = context.CharacterClothes.ToList().FindAll(c => c.UserId == user.Id && c.Duty == false);
|
||||
player.ClearAccessory(0);
|
||||
player.ClearAccessory(1);
|
||||
player.ClearAccessory(2);
|
||||
player.ClearAccessory(6);
|
||||
player.ClearAccessory(7);
|
||||
|
||||
foreach (var cloth in charClothes)
|
||||
{
|
||||
if (cloth.SlotType == 1)
|
||||
{
|
||||
player.SetAccessories(cloth.SlotId, cloth.ClothId, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.SetClothes(cloth.SlotId, cloth.ClothId, cloth.Texture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("SERVER:BuyCharacterClothes")]
|
||||
public void RmtEvent_BuyClothes(Player client, string type, string jsonData)
|
||||
{
|
||||
/*
|
||||
* [0] ComponentID
|
||||
* [1] TextureID
|
||||
* [2] ClotheID
|
||||
* [3] TorsoID
|
||||
* [4] UndershirtID
|
||||
* [5] UndershirtTextureID
|
||||
* [6] Price
|
||||
*/
|
||||
|
||||
int[] data = JsonConvert.DeserializeObject<int[]>(jsonData);
|
||||
User user = client.GetUser();
|
||||
if (user.Handmoney < data[6])
|
||||
{
|
||||
client.TriggerEvent("clothesMenu:Error");
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == "clothe")
|
||||
{
|
||||
if (data[0] == 11)//for tops
|
||||
{
|
||||
client.SetClothes(11, data[2], data[1]); //set Top
|
||||
client.SetClothes(8, data[4], data[5]); //set undershirt
|
||||
client.SetClothes(3, data[3], 0); //set Torso
|
||||
}
|
||||
else
|
||||
{
|
||||
client.SetClothes(data[0], data[2], data[1]);
|
||||
}
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
var clothes = dbContext.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id && c.SlotId == data[0] && c.Duty == false);
|
||||
|
||||
if (clothes == null)
|
||||
{
|
||||
CharacterCloth newCloth = new CharacterCloth
|
||||
{
|
||||
UserId = user.Id,
|
||||
|
||||
Duty = false,
|
||||
|
||||
SlotType = 0,
|
||||
SlotId = data[0],
|
||||
ClothId = data[2],
|
||||
Texture = data[1]
|
||||
};
|
||||
dbContext.CharacterClothes.Add(newCloth);
|
||||
}
|
||||
else
|
||||
{
|
||||
clothes.ClothId = data[2];
|
||||
clothes.Texture = data[1];
|
||||
}
|
||||
if (data[0] == 11)
|
||||
{
|
||||
var torso = dbContext.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id && c.SlotId == 3 && c.Duty == false);
|
||||
var undershirt = dbContext.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id && c.SlotId == 8 && c.Duty == false);
|
||||
if (torso == null)
|
||||
{
|
||||
CharacterCloth newTorso = new CharacterCloth
|
||||
{
|
||||
UserId = user.Id,
|
||||
|
||||
Duty = false,
|
||||
|
||||
SlotType = 0,
|
||||
SlotId = 3,
|
||||
ClothId = data[3]
|
||||
};
|
||||
dbContext.CharacterClothes.Add(newTorso);
|
||||
}
|
||||
else
|
||||
{
|
||||
torso.ClothId = data[3];
|
||||
}
|
||||
if (undershirt == null)
|
||||
{
|
||||
CharacterCloth newUndershirt = new CharacterCloth
|
||||
{
|
||||
UserId = user.Id,
|
||||
Duty = false,
|
||||
SlotType = 0,
|
||||
SlotId = 8,
|
||||
ClothId = data[4],
|
||||
Texture = data[5]
|
||||
};
|
||||
dbContext.CharacterClothes.Add(newUndershirt);
|
||||
}
|
||||
else
|
||||
{
|
||||
undershirt.ClothId = data[4];
|
||||
undershirt.Texture = data[5];
|
||||
}
|
||||
}
|
||||
client.GetUser(dbContext).Handmoney -= data[6];
|
||||
dbContext.SaveChanges();
|
||||
client.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney);
|
||||
}
|
||||
client.TriggerEvent("clothesMenu:updateLast", data[2], data[1], data[4], data[5], data[3]);
|
||||
}
|
||||
}
|
||||
client.GetUser(dbContext).Handmoney -= data[6];
|
||||
dbContext.SaveChanges();
|
||||
client.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney);
|
||||
|
||||
}
|
||||
client.TriggerEvent("clothesMenu:updateLast", data[2], data[1], data[4], data[5], data[3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Server.Managers;
|
||||
|
||||
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
public class UpdateCharacterElevator : Script
|
||||
{
|
||||
[RemoteEvent("sendPlayerToStage")]
|
||||
public void SaveWeaponSelection(Player client, string stage)
|
||||
{
|
||||
ElevatorPoint elevator = PositionManager.ElevatorPoints.Find(e => e.Stage == stage);
|
||||
if (elevator != null)
|
||||
{
|
||||
client.Position = elevator.Position;
|
||||
}
|
||||
[RemoteEvent("sendPlayerToStage")]
|
||||
public void SaveWeaponSelection(Player client, string stage)
|
||||
{
|
||||
ElevatorPoint elevator = PositionManager.ElevatorPoints.Find(e => e.Stage == stage);
|
||||
if (elevator != null)
|
||||
{
|
||||
client.Position = elevator.Position;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
@@ -8,103 +7,101 @@ using ReallifeGamemode.Server.Extensions;
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
public class UpdateCharacterWeapon : Script
|
||||
{
|
||||
[RemoteEvent("updateWeaponSelection")]
|
||||
public void UpdateWeaponSelection(Player client, string weaponModel, int slot)
|
||||
{
|
||||
if (weaponModel == "Keine")
|
||||
{
|
||||
client.RemoveAllWeapons();
|
||||
return;
|
||||
}
|
||||
|
||||
WeaponHash weaponHash = NAPI.Util.WeaponNameToModel(weaponModel);
|
||||
|
||||
if (slot == 1)
|
||||
{
|
||||
client.RemoveAllWeapons();
|
||||
client.GiveWeapon(weaponHash, 0);
|
||||
}
|
||||
if (slot == 2)
|
||||
{
|
||||
client.RemoveAllWeapons();
|
||||
client.GiveWeapon(weaponHash, 0);
|
||||
}
|
||||
if (slot == 3)
|
||||
{
|
||||
client.RemoveAllWeapons();
|
||||
client.GiveWeapon(weaponHash, 0);
|
||||
}
|
||||
if (slot == 4)
|
||||
{
|
||||
client.RemoveAllWeapons();
|
||||
client.GiveWeapon(weaponHash, 0);
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("cancelWeaponSelection")]
|
||||
public void CancelWeaponSelection(Player client)
|
||||
{
|
||||
client.RemoveAllWeapons();
|
||||
}
|
||||
|
||||
|
||||
[RemoteEvent("saveWeaponSelection")]
|
||||
public void SaveWeaponSelection(Player client, string primaryModel, string secondaryModel, string meleeModel, string specialModel)
|
||||
{
|
||||
client.RemoveAllWeapons();
|
||||
if (!uint.TryParse(primaryModel, out uint primary))
|
||||
{
|
||||
if (primaryModel.Contains("mk2") && !primaryModel.Contains("_mk2")) primaryModel = primaryModel.Replace("mk2", "_mk2");
|
||||
primary = NAPI.Util.GetHashKey($"weapon_{primaryModel}");
|
||||
}
|
||||
if (!uint.TryParse(secondaryModel, out uint secondary))
|
||||
{
|
||||
if (secondaryModel.Contains("mk2") && !secondaryModel.Contains("_mk2")) secondaryModel = secondaryModel.Replace("mk2", "_mk2");
|
||||
secondary = NAPI.Util.GetHashKey($"weapon_{secondaryModel}");
|
||||
}
|
||||
if (!uint.TryParse(meleeModel, out uint melee))
|
||||
{
|
||||
if (meleeModel.Contains("mk2") && !meleeModel.Contains("_mk2")) meleeModel = meleeModel.Replace("mk2", "_mk2");
|
||||
melee = NAPI.Util.GetHashKey($"weapon_{meleeModel}");
|
||||
}
|
||||
|
||||
|
||||
client.GiveWeapon((WeaponHash)primary, 50);
|
||||
client.GiveWeapon((WeaponHash)secondary, 150);
|
||||
client.GiveWeapon((WeaponHash)melee, 1);
|
||||
if (specialModel != "Schutzweste")
|
||||
{
|
||||
client.Armor = 0;
|
||||
if (!uint.TryParse(specialModel, out uint special))
|
||||
[RemoteEvent("updateWeaponSelection")]
|
||||
public void UpdateWeaponSelection(Player client, string weaponModel, int slot)
|
||||
{
|
||||
if (specialModel.Contains("mk2") && !specialModel.Contains("_mk2")) specialModel = specialModel.Replace("mk2", "_mk2");
|
||||
special = NAPI.Util.GetHashKey($"weapon_{specialModel}");
|
||||
}
|
||||
client.GiveWeapon((WeaponHash)special, 50);
|
||||
}
|
||||
else
|
||||
{
|
||||
client.Armor = 50;
|
||||
}
|
||||
if (weaponModel == "Keine")
|
||||
{
|
||||
client.RemoveAllWeapons();
|
||||
return;
|
||||
}
|
||||
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
User user = client.GetUser();
|
||||
FactionWeapon slot1 = context.FactionWeapons.Where(w => w.FactionId == user.FactionId && w.WeaponModel == primaryModel).FirstOrDefault();
|
||||
if (slot1 != null)
|
||||
slot1.Ammount -= 1;
|
||||
FactionWeapon slot2 = context.FactionWeapons.Where(w => w.FactionId == user.FactionId && w.WeaponModel == secondaryModel).FirstOrDefault();
|
||||
if (slot2 != null)
|
||||
slot2.Ammount -= 1;
|
||||
FactionWeapon slot3 = context.FactionWeapons.Where(w => w.FactionId == user.FactionId && w.WeaponModel == meleeModel).FirstOrDefault();
|
||||
if (slot3 != null)
|
||||
slot3.Ammount -= 1;
|
||||
FactionWeapon slot4 = context.FactionWeapons.Where(w => w.FactionId == user.FactionId && w.WeaponModel == specialModel).FirstOrDefault();
|
||||
if (slot4 != null)
|
||||
slot4.Ammount -= 1;
|
||||
context.SaveChanges();
|
||||
}
|
||||
WeaponHash weaponHash = NAPI.Util.WeaponNameToModel(weaponModel);
|
||||
|
||||
if (slot == 1)
|
||||
{
|
||||
client.RemoveAllWeapons();
|
||||
client.GiveWeapon(weaponHash, 0);
|
||||
}
|
||||
if (slot == 2)
|
||||
{
|
||||
client.RemoveAllWeapons();
|
||||
client.GiveWeapon(weaponHash, 0);
|
||||
}
|
||||
if (slot == 3)
|
||||
{
|
||||
client.RemoveAllWeapons();
|
||||
client.GiveWeapon(weaponHash, 0);
|
||||
}
|
||||
if (slot == 4)
|
||||
{
|
||||
client.RemoveAllWeapons();
|
||||
client.GiveWeapon(weaponHash, 0);
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("cancelWeaponSelection")]
|
||||
public void CancelWeaponSelection(Player client)
|
||||
{
|
||||
client.RemoveAllWeapons();
|
||||
}
|
||||
|
||||
[RemoteEvent("saveWeaponSelection")]
|
||||
public void SaveWeaponSelection(Player client, string primaryModel, string secondaryModel, string meleeModel, string specialModel)
|
||||
{
|
||||
client.RemoveAllWeapons();
|
||||
if (!uint.TryParse(primaryModel, out uint primary))
|
||||
{
|
||||
if (primaryModel.Contains("mk2") && !primaryModel.Contains("_mk2")) primaryModel = primaryModel.Replace("mk2", "_mk2");
|
||||
primary = NAPI.Util.GetHashKey($"weapon_{primaryModel}");
|
||||
}
|
||||
if (!uint.TryParse(secondaryModel, out uint secondary))
|
||||
{
|
||||
if (secondaryModel.Contains("mk2") && !secondaryModel.Contains("_mk2")) secondaryModel = secondaryModel.Replace("mk2", "_mk2");
|
||||
secondary = NAPI.Util.GetHashKey($"weapon_{secondaryModel}");
|
||||
}
|
||||
if (!uint.TryParse(meleeModel, out uint melee))
|
||||
{
|
||||
if (meleeModel.Contains("mk2") && !meleeModel.Contains("_mk2")) meleeModel = meleeModel.Replace("mk2", "_mk2");
|
||||
melee = NAPI.Util.GetHashKey($"weapon_{meleeModel}");
|
||||
}
|
||||
|
||||
client.GiveWeapon((WeaponHash)primary, 50);
|
||||
client.GiveWeapon((WeaponHash)secondary, 150);
|
||||
client.GiveWeapon((WeaponHash)melee, 1);
|
||||
if (specialModel != "Schutzweste")
|
||||
{
|
||||
client.Armor = 0;
|
||||
if (!uint.TryParse(specialModel, out uint special))
|
||||
{
|
||||
if (specialModel.Contains("mk2") && !specialModel.Contains("_mk2")) specialModel = specialModel.Replace("mk2", "_mk2");
|
||||
special = NAPI.Util.GetHashKey($"weapon_{specialModel}");
|
||||
}
|
||||
client.GiveWeapon((WeaponHash)special, 50);
|
||||
}
|
||||
else
|
||||
{
|
||||
client.Armor = 50;
|
||||
}
|
||||
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
User user = client.GetUser();
|
||||
FactionWeapon slot1 = context.FactionWeapons.Where(w => w.FactionId == user.FactionId && w.WeaponModel == primaryModel).FirstOrDefault();
|
||||
if (slot1 != null)
|
||||
slot1.Ammount -= 1;
|
||||
FactionWeapon slot2 = context.FactionWeapons.Where(w => w.FactionId == user.FactionId && w.WeaponModel == secondaryModel).FirstOrDefault();
|
||||
if (slot2 != null)
|
||||
slot2.Ammount -= 1;
|
||||
FactionWeapon slot3 = context.FactionWeapons.Where(w => w.FactionId == user.FactionId && w.WeaponModel == meleeModel).FirstOrDefault();
|
||||
if (slot3 != null)
|
||||
slot3.Ammount -= 1;
|
||||
FactionWeapon slot4 = context.FactionWeapons.Where(w => w.FactionId == user.FactionId && w.WeaponModel == specialModel).FirstOrDefault();
|
||||
if (slot4 != null)
|
||||
slot4.Ammount -= 1;
|
||||
context.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,286 +1,282 @@
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Database;
|
||||
using System;
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Types;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using System;
|
||||
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
public class Vehicle : Script
|
||||
{
|
||||
[RemoteEvent("VehicleMenu_ToggleEngine")]
|
||||
public void VehicleMenuToggleEngineEvent(Player player)
|
||||
{
|
||||
if (player.IsInVehicle && player.VehicleSeat == 0)
|
||||
{
|
||||
GTANetworkAPI.Vehicle v = player.Vehicle;
|
||||
|
||||
User u = player.GetUser();
|
||||
if (u == null) return;
|
||||
|
||||
if (NAPI.Entity.GetEntityVelocity(v).Length() > 1 && v.Class != 16)
|
||||
[RemoteEvent("VehicleMenu_ToggleEngine")]
|
||||
public void VehicleMenuToggleEngineEvent(Player player)
|
||||
{
|
||||
player.SendNotification("~r~Der Motor kann nur im Stand betätigt werden.", true);
|
||||
return;
|
||||
if (player.IsInVehicle && player.VehicleSeat == 0)
|
||||
{
|
||||
GTANetworkAPI.Vehicle v = player.Vehicle;
|
||||
|
||||
User u = player.GetUser();
|
||||
if (u == null) return;
|
||||
|
||||
if (NAPI.Entity.GetEntityVelocity(v).Length() > 1 && v.Class != 16)
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (sV is ShopVehicle)
|
||||
{
|
||||
VehicleStreaming.SetEngineState(v, false);
|
||||
return;
|
||||
}
|
||||
else if (sV is FactionVehicle fV)
|
||||
{
|
||||
if (!fV.GetOwners().Contains(u.FactionId ?? 0) && !state && !(u.IsAdmin(AdminLevel.HEADADMIN) && GlobalHelper.DutyAdmins.Contains(player)))
|
||||
{
|
||||
player.SendNotification("~r~Du hast keinen Schlüssel.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (sV is GroupVehicle gV)
|
||||
{
|
||||
if (gV.GroupId != u.Group.Id && !state && !u.IsAdmin(AdminLevel.ADMIN3))
|
||||
{
|
||||
player.SendNotification("~r~Du hast keinen Schlüssel.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (sV is JobVehicle jV)
|
||||
{
|
||||
if (!jV.GetJob().GetUsersInJob().Contains(player) && !u.IsAdmin(AdminLevel.ADMIN3))
|
||||
{
|
||||
player.SendNotification("~r~Du hast keinen Schlüssel.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (sV is UserVehicle uV)
|
||||
{
|
||||
if (uV.UserId != u.Id)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
VehicleStreaming.SetEngineState(v, !state);
|
||||
}
|
||||
}
|
||||
|
||||
bool state = VehicleStreaming.GetEngineState(v);
|
||||
ServerVehicle sV = v.GetServerVehicle();
|
||||
if (sV != null)
|
||||
[RemoteEvent("VehicleMenu_LockCar")]
|
||||
public static void VehicleMenuLockCarEvent(Player player)
|
||||
{
|
||||
if (sV is ShopVehicle)
|
||||
{
|
||||
VehicleStreaming.SetEngineState(v, false);
|
||||
return;
|
||||
}
|
||||
else if (sV is FactionVehicle fV)
|
||||
{
|
||||
if (!fV.GetOwners().Contains(u.FactionId ?? 0) && !state && !(u.IsAdmin(AdminLevel.HEADADMIN) && GlobalHelper.DutyAdmins.Contains(player)))
|
||||
if (player.IsInVehicle && player.VehicleSeat == 0)
|
||||
{
|
||||
player.SendNotification("~r~Du hast keinen Schlüssel.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (sV is GroupVehicle gV)
|
||||
{
|
||||
if (gV.GroupId != u.Group.Id && !state && !u.IsAdmin(AdminLevel.ADMIN3))
|
||||
{
|
||||
player.SendNotification("~r~Du hast keinen Schlüssel.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (sV is JobVehicle jV)
|
||||
{
|
||||
if (!jV.GetJob().GetUsersInJob().Contains(player) && !u.IsAdmin(AdminLevel.ADMIN3))
|
||||
{
|
||||
player.SendNotification("~r~Du hast keinen Schlüssel.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (sV is UserVehicle uV)
|
||||
{
|
||||
if (uV.UserId != u.Id)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
VehicleStreaming.SetEngineState(v, !state);
|
||||
}
|
||||
}
|
||||
GTANetworkAPI.Vehicle v = player.Vehicle;
|
||||
|
||||
[RemoteEvent("VehicleMenu_LockCar")]
|
||||
public static void VehicleMenuLockCarEvent(Player player)
|
||||
{
|
||||
if (player.IsInVehicle && player.VehicleSeat == 0)
|
||||
{
|
||||
GTANetworkAPI.Vehicle v = player.Vehicle;
|
||||
User u = player.GetUser();
|
||||
if (u == null) return;
|
||||
|
||||
User u = player.GetUser();
|
||||
if (u == null) return;
|
||||
bool state = VehicleStreaming.GetLockState(v);
|
||||
ServerVehicle sV = v.GetServerVehicle();
|
||||
|
||||
bool state = VehicleStreaming.GetLockState(v);
|
||||
ServerVehicle sV = v.GetServerVehicle();
|
||||
|
||||
if (sV != null)
|
||||
{
|
||||
if (sV is ShopVehicle)
|
||||
{
|
||||
VehicleStreaming.SetEngineState(v, false);
|
||||
return;
|
||||
}
|
||||
else if (sV is FactionVehicle fV)
|
||||
{
|
||||
if (!fV.GetOwners().Contains(u.FactionId ?? 0))
|
||||
{
|
||||
return;
|
||||
if (sV != null)
|
||||
{
|
||||
if (sV is ShopVehicle)
|
||||
{
|
||||
VehicleStreaming.SetEngineState(v, false);
|
||||
return;
|
||||
}
|
||||
else if (sV is FactionVehicle fV)
|
||||
{
|
||||
if (!fV.GetOwners().Contains(u.FactionId ?? 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (sV is UserVehicle uV)
|
||||
{
|
||||
if (uV.UserId != u.Id)
|
||||
{
|
||||
player.SendNotification("~r~Du hast keinen Schlüssel.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (sV is JobVehicle)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (sV is SchoolVehicle)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
state = !state;
|
||||
VehicleStreaming.SetLockStatus(v, state);
|
||||
string msg = "Fahrzeug ";
|
||||
msg += state ? "~g~abgeschlossen" : "~r~aufgeschlossen";
|
||||
player.TriggerEvent("vehsync:OpenCar", state);
|
||||
player.SendNotification(msg);
|
||||
}
|
||||
}
|
||||
else if (sV is UserVehicle uV)
|
||||
{
|
||||
if (uV.UserId != u.Id)
|
||||
else if (!player.IsInVehicle)
|
||||
{
|
||||
player.SendNotification("~r~Du hast keinen Schlüssel.");
|
||||
return;
|
||||
GTANetworkAPI.Vehicle vehicle = null;
|
||||
foreach (var veh in NAPI.Pools.GetAllVehicles())
|
||||
{
|
||||
if (player.Position.DistanceTo(veh.Position) <= 3f)
|
||||
{
|
||||
vehicle = veh;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (vehicle == null)
|
||||
return;
|
||||
User u = player.GetUser();
|
||||
if (u == null) return;
|
||||
|
||||
bool state = VehicleStreaming.GetLockState(vehicle);
|
||||
ServerVehicle sV = vehicle.GetServerVehicle();
|
||||
|
||||
if (sV != null)
|
||||
{
|
||||
if (sV is ShopVehicle)
|
||||
{
|
||||
VehicleStreaming.SetEngineState(vehicle, false);
|
||||
return;
|
||||
}
|
||||
else if (sV is FactionVehicle fV)
|
||||
{
|
||||
if (!fV.GetOwners().Contains(u.FactionId ?? 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (sV is UserVehicle uV)
|
||||
{
|
||||
if (uV.UserId != u.Id)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (sV is JobVehicle)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
state = !state;
|
||||
VehicleStreaming.SetLockStatus(vehicle, state);
|
||||
string msg = "Fahrzeug ";
|
||||
msg += state ? "~g~abgeschlossen" : "~r~aufgeschlossen";
|
||||
player.TriggerEvent("vehsync:OpenCar", state);
|
||||
player.SendNotification(msg);
|
||||
}
|
||||
}
|
||||
else if (sV is JobVehicle)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (sV is SchoolVehicle)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
state = !state;
|
||||
VehicleStreaming.SetLockStatus(v, state);
|
||||
string msg = "Fahrzeug ";
|
||||
msg += state ? "~g~abgeschlossen" : "~r~aufgeschlossen";
|
||||
player.TriggerEvent("vehsync:OpenCar", state);
|
||||
player.SendNotification(msg);
|
||||
}
|
||||
else if (!player.IsInVehicle)
|
||||
{
|
||||
GTANetworkAPI.Vehicle vehicle = null;
|
||||
foreach (var veh in NAPI.Pools.GetAllVehicles())
|
||||
{
|
||||
if (player.Position.DistanceTo(veh.Position) <= 3f)
|
||||
{
|
||||
vehicle = veh;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (vehicle == null)
|
||||
return;
|
||||
User u = player.GetUser();
|
||||
if (u == null) return;
|
||||
|
||||
bool state = VehicleStreaming.GetLockState(vehicle);
|
||||
ServerVehicle sV = vehicle.GetServerVehicle();
|
||||
|
||||
if (sV != null)
|
||||
[RemoteEvent("CLIENT:VehicleMenu_ParkCar")]
|
||||
public void VehicleMenuParkCarEvent(Player player)
|
||||
{
|
||||
if (sV is ShopVehicle)
|
||||
{
|
||||
VehicleStreaming.SetEngineState(vehicle, false);
|
||||
return;
|
||||
}
|
||||
else if (sV is FactionVehicle fV)
|
||||
{
|
||||
if (!fV.GetOwners().Contains(u.FactionId ?? 0))
|
||||
if (player.IsInVehicle && player.VehicleSeat == 0)
|
||||
{
|
||||
return;
|
||||
GTANetworkAPI.Vehicle v = player.Vehicle;
|
||||
|
||||
User u = player.GetUser();
|
||||
if (u == null) return;
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
ServerVehicle sV = v.GetServerVehicle(dbContext);
|
||||
|
||||
if (sV == null) return;
|
||||
|
||||
if (sV is UserVehicle uV)
|
||||
{
|
||||
if (uV.UserId != u.Id)
|
||||
{
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (sV is FactionVehicle fV)
|
||||
{
|
||||
if (!fV.GetOwners().Contains(u.FactionId ?? 0) || !u.FactionLeader)
|
||||
{
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (sV is GroupVehicle gV)
|
||||
{
|
||||
if (gV.GroupId != u.Group.Id || u.GroupRank < GroupRank.MANAGER)
|
||||
{
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (sV is JobVehicle)
|
||||
{
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken.");
|
||||
return;
|
||||
}
|
||||
else if (sV is SchoolVehicle)
|
||||
{
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken.");
|
||||
return;
|
||||
}
|
||||
|
||||
Vector3 pos = v.Position;
|
||||
|
||||
sV.PositionX = pos.X;
|
||||
sV.PositionY = pos.Y;
|
||||
sV.PositionZ = pos.Z;
|
||||
sV.Heading = v.Heading;
|
||||
|
||||
player.SendNotification("~g~Das Fahrzeug wurde geparkt.");
|
||||
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (sV is UserVehicle uV)
|
||||
{
|
||||
if (uV.UserId != u.Id)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (sV is JobVehicle)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
state = !state;
|
||||
VehicleStreaming.SetLockStatus(vehicle, state);
|
||||
string msg = "Fahrzeug ";
|
||||
msg += state ? "~g~abgeschlossen" : "~r~aufgeschlossen";
|
||||
player.TriggerEvent("vehsync:OpenCar", state);
|
||||
player.SendNotification(msg);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:VehicleMenu_ParkCar")]
|
||||
public void VehicleMenuParkCarEvent(Player player)
|
||||
{
|
||||
if (player.IsInVehicle && player.VehicleSeat == 0)
|
||||
{
|
||||
GTANetworkAPI.Vehicle v = player.Vehicle;
|
||||
|
||||
User u = player.GetUser();
|
||||
if (u == null) return;
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
[RemoteEvent("VehicleMenu_ToggleSingleDoor")]
|
||||
public void VehicleMenuToggleSingleDoorEvent(Player player, int door)
|
||||
{
|
||||
ServerVehicle sV = v.GetServerVehicle(dbContext);
|
||||
if (!player.IsInVehicle) return;
|
||||
GTANetworkAPI.Vehicle veh = player.Vehicle;
|
||||
|
||||
if (sV == null) return;
|
||||
DoorID doorId = (DoorID)door;
|
||||
|
||||
if (sV is UserVehicle uV)
|
||||
{
|
||||
if (uV.UserId != u.Id)
|
||||
{
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (sV is FactionVehicle fV)
|
||||
{
|
||||
if (!fV.GetOwners().Contains(u.FactionId ?? 0) || !u.FactionLeader)
|
||||
{
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (sV is GroupVehicle gV)
|
||||
{
|
||||
if (gV.GroupId != u.Group.Id || u.GroupRank < GroupRank.MANAGER)
|
||||
{
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (sV is JobVehicle)
|
||||
{
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken.");
|
||||
return;
|
||||
}
|
||||
else if (sV is SchoolVehicle)
|
||||
{
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken.");
|
||||
return;
|
||||
}
|
||||
DoorState state = VehicleStreaming.GetDoorState(veh, doorId);
|
||||
|
||||
Vector3 pos = v.Position;
|
||||
|
||||
sV.PositionX = pos.X;
|
||||
sV.PositionY = pos.Y;
|
||||
sV.PositionZ = pos.Z;
|
||||
sV.Heading = v.Heading;
|
||||
|
||||
player.SendNotification("~g~Das Fahrzeug wurde geparkt.");
|
||||
|
||||
dbContext.SaveChanges();
|
||||
VehicleStreaming.SetDoorState(veh, doorId, state == DoorState.DoorOpen ? DoorState.DoorClosed : DoorState.DoorOpen);
|
||||
}
|
||||
|
||||
[RemoteEvent("VehicleMenu_OpenAllDoors")]
|
||||
public void VehicleMenuOpenAllDoorsEvent(Player player)
|
||||
{
|
||||
if (!player.IsInVehicle) return;
|
||||
GTANetworkAPI.Vehicle veh = player.Vehicle;
|
||||
|
||||
foreach (DoorID doorId in Enum.GetValues(typeof(DoorID)))
|
||||
{
|
||||
VehicleStreaming.SetDoorState(veh, doorId, DoorState.DoorOpen);
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("VehicleMenu_CloseAllDoors")]
|
||||
public void VehicleMenuCloseAllDoorsEvent(Player player)
|
||||
{
|
||||
if (!player.IsInVehicle) return;
|
||||
GTANetworkAPI.Vehicle veh = player.Vehicle;
|
||||
|
||||
foreach (DoorID doorId in Enum.GetValues(typeof(DoorID)))
|
||||
{
|
||||
VehicleStreaming.SetDoorState(veh, doorId, DoorState.DoorClosed);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("VehicleMenu_ToggleSingleDoor")]
|
||||
public void VehicleMenuToggleSingleDoorEvent(Player player, int door)
|
||||
{
|
||||
if (!player.IsInVehicle) return;
|
||||
GTANetworkAPI.Vehicle veh = player.Vehicle;
|
||||
|
||||
DoorID doorId = (DoorID)door;
|
||||
|
||||
DoorState state = VehicleStreaming.GetDoorState(veh, doorId);
|
||||
|
||||
VehicleStreaming.SetDoorState(veh, doorId, state == DoorState.DoorOpen ? DoorState.DoorClosed : DoorState.DoorOpen);
|
||||
}
|
||||
|
||||
[RemoteEvent("VehicleMenu_OpenAllDoors")]
|
||||
public void VehicleMenuOpenAllDoorsEvent(Player player)
|
||||
{
|
||||
if (!player.IsInVehicle) return;
|
||||
GTANetworkAPI.Vehicle veh = player.Vehicle;
|
||||
|
||||
foreach (DoorID doorId in Enum.GetValues(typeof(DoorID)))
|
||||
{
|
||||
VehicleStreaming.SetDoorState(veh, doorId, DoorState.DoorOpen);
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("VehicleMenu_CloseAllDoors")]
|
||||
public void VehicleMenuCloseAllDoorsEvent(Player player)
|
||||
{
|
||||
if (!player.IsInVehicle) return;
|
||||
GTANetworkAPI.Vehicle veh = player.Vehicle;
|
||||
|
||||
foreach (DoorID doorId in Enum.GetValues(typeof(DoorID)))
|
||||
{
|
||||
VehicleStreaming.SetDoorState(veh, doorId, DoorState.DoorClosed);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
class Voice : Script
|
||||
internal class Voice : Script
|
||||
{
|
||||
[RemoteEvent("CLIENT:AddVoiceListener")]
|
||||
public void AddPlayerVoiceListenerEvent(Player player, Player target)
|
||||
|
||||
Reference in New Issue
Block a user