Merge branch 'develop' of ssh://development.life-of-german.org:451/log-gtav/reallife-gamemode into develop
This commit is contained in:
@@ -10,6 +10,7 @@ using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Factions.Medic;
|
||||
using ReallifeGamemode.Server.Managers;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
using ReallifeGamemode.Server.Types;
|
||||
using ReallifeGamemode.Services;
|
||||
|
||||
/**
|
||||
@@ -43,20 +44,21 @@ namespace ReallifeGamemode.Server.Commands
|
||||
[Command("ga", "~m~Benutzung: ~s~/ga [Nachricht]", GreedyArg = true)]
|
||||
public void CmdFactionGA(Player player, string message)
|
||||
{
|
||||
Faction f = player.GetUser()?.Faction;
|
||||
User user = player.GetUser();
|
||||
Faction f = user?.Faction;
|
||||
if (f == null || f.StateOwned)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
if (player.GetUser().Faction.Name == "Ballas" || player.GetUser().Faction.Name == "Grove")
|
||||
if (f.Name == "Ballas" || f.Name == "Grove" || user.IsAdmin(AdminLevel.ADMIN))
|
||||
{
|
||||
message = Regex.Replace(message, "(~[a-zA-Z]~)|(!{(.*)})", "");
|
||||
|
||||
string broadcastMessage = "!{FF0000}** " + player.GetUser().GetFactionRank().RankName + " " + player.Name + ": " + message + " **";
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
ChatService.BroadcastFaction(broadcastMessage, context.Factions.ToList().FindAll(c => c.GangOwned));
|
||||
ChatService.BroadcastFaction(broadcastMessage, context.Factions.ToList().FindAll(c => c.GangOwned), true);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -177,7 +179,8 @@ namespace ReallifeGamemode.Server.Commands
|
||||
[Command("lc", "~m~Benutzung: ~s~/lc [Nachricht]", GreedyArg = true)]
|
||||
public void CmdFactionLc(Player player, string message)
|
||||
{
|
||||
if (player.GetUser()?.FactionId == null || player.GetUser().FactionLeader == false)
|
||||
User user = player.GetUser();
|
||||
if (user?.FactionId == null || user.FactionLeader == false || !user.IsAdmin(AdminLevel.ADMIN))
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
@@ -189,7 +192,8 @@ namespace ReallifeGamemode.Server.Commands
|
||||
|
||||
NAPI.Pools.GetAllPlayers().ForEach(p =>
|
||||
{
|
||||
if (p.GetUser()?.FactionLeader ?? false) ChatService.SendMessage(p, broadcastMsg);
|
||||
User pUser = p.GetUser();
|
||||
if (pUser?.FactionLeader ?? false || pUser.IsAdmin(AdminLevel.ADMIN)) ChatService.SendMessage(p, broadcastMsg);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -612,14 +612,14 @@ namespace ReallifeGamemode.Server.Events
|
||||
public void KeyPressO(Player player)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
List<Player> players = NAPI.Pools.GetAllPlayers().Where(p => p.IsLoggedIn() == true).ToList();
|
||||
List<Player> players = NAPI.Pools.GetAllPlayers().Where(p => p.IsLoggedIn() == true).OrderBy(o => o.Handle.Value).ToList();
|
||||
|
||||
var listPlayers = players.Select(p => new
|
||||
{
|
||||
Id = p.Handle.Value,
|
||||
p.Name,
|
||||
p.Ping,
|
||||
FactionName = p.GetUser().Faction?.Name ?? "Zivilist",
|
||||
FactionName = p.GetUser()?.Faction?.Name ?? "Zivilist",
|
||||
});
|
||||
player.TriggerEvent("showPlayerlist", JsonConvert.SerializeObject(listPlayers));
|
||||
}
|
||||
|
||||
@@ -93,6 +93,11 @@ namespace ReallifeGamemode.Server.Extensions
|
||||
|
||||
internal static T GetData<T>(this User user, string key, T nullValue)
|
||||
{
|
||||
if(user == null)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
key += "data_";
|
||||
if (!user.Player.HasData(key)) return nullValue;
|
||||
return JsonConvert.DeserializeObject<T>(user.Player.GetData<dynamic>(key));
|
||||
@@ -102,6 +107,11 @@ namespace ReallifeGamemode.Server.Extensions
|
||||
|
||||
internal static void SetData(this User user, string key, object value)
|
||||
{
|
||||
if(user == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
key += "data_";
|
||||
user.Player.SetData(key, JsonConvert.SerializeObject(value));
|
||||
}
|
||||
|
||||
@@ -443,6 +443,12 @@ namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
var taxiJob = JobManager.GetJob<TaxiDriverJob>();
|
||||
|
||||
if(taxiJob == null)
|
||||
{
|
||||
player.SendChatMessage("Aktuell kann kein Taxi gerufen werden.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (taxiJob.TaxiContracts.Where(t => t.Name == player.Name).Count() != 0)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Du kannst nur einmal ein Taxi rufen");
|
||||
|
||||
@@ -52,11 +52,12 @@ namespace ReallifeGamemode.Server.Services
|
||||
/// </summary>
|
||||
/// <param name="message">Die Nachricht, die gesendet werden soll</param>
|
||||
/// <param name="factions">Die Liste an Fraktionen, die diese Nachricht bekommen sollen</param>
|
||||
public static void BroadcastFaction(string message, List<Faction> factions)
|
||||
public static void BroadcastFaction(string message, List<Faction> factions, bool toAdmins = false)
|
||||
{
|
||||
foreach (Player c in NAPI.Pools.GetAllPlayers())
|
||||
{
|
||||
Faction f = c.GetUser()?.Faction;
|
||||
User user = c.GetUser();
|
||||
Faction f = user.Faction;
|
||||
if (f != null)
|
||||
{
|
||||
if (factions.Find(fT => fT.Id == f.Id) != null)
|
||||
@@ -64,6 +65,10 @@ namespace ReallifeGamemode.Server.Services
|
||||
ChatService.SendMessage(c, message);
|
||||
}
|
||||
}
|
||||
else if(user.IsAdmin(AdminLevel.ADMIN) && toAdmins)
|
||||
{
|
||||
ChatService.SendMessage(c, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user