Fixed EF error, edit commands, fix faction broadcast

This commit is contained in:
Lennart Kampshoff
2018-09-23 15:59:40 +02:00
parent 22df6c6a2e
commit f91ef8960c
6 changed files with 82 additions and 27 deletions

View File

@@ -246,11 +246,11 @@ namespace reallife_gamemode.Server.Commands
return;
}
target.GetUser(dbContext).Faction = f;
target.GetUser(dbContext).FactionId = f.Id;
dbContext.SaveChanges();
player.SendChatMessage("~b~[ADMIN]~y~ " + player.Name + "~s~ hat den Spieler ~y~" + target.Name + "~s~ administrativ in die Fraktion ~o~" + f.Name + "~s~ eingeladen.");
target.SendChatMessage("~b~[ADMIN]~y~ Du wurdest von ~y~" + player.Name + "~s~ administrativ in die Fraktion ~o~" + f.Name + "~s~ eingeladen.");
player.SendChatMessage("~b~[ADMIN]~s~ Du hast hast den Spieler ~y~" + target.Name + "~s~ administrativ in die Fraktion ~o~" + f.Name + "~s~ eingeladen.");
target.SendChatMessage("~b~[ADMIN]~s~ Du wurdest von ~y~" + player.Name + "~s~ administrativ in die Fraktion ~o~" + f.Name + "~s~ eingeladen.");
}
}
}

View File

@@ -1,9 +1,11 @@
using GTANetworkAPI;
using reallife_gamemode.Model;
using reallife_gamemode.Server.Entities;
using reallife_gamemode.Server.Extensions;
using reallife_gamemode.Server.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
/**
@@ -19,16 +21,46 @@ namespace reallife_gamemode.Server.Commands
[Command("f", "~m~Benutzung: ~s~/f [Nachricht]", GreedyArg = true)]
public void CmdFactionF(Client player, string message)
{
User u = player.GetUser();
if(u.Faction == null)
Entities.Faction f = player.GetFaction();
if(f == null || f.StateOwned)
{
ChatService.NotAuthorized(player);
return;
}
string broadcastMessage = "** " + player.Name + ": " + message + " )) **";
string broadcastMessage = "!{02FCFF}** " + player.Name + ": " + message + " )) **";
ChatService.BroadcastFaction(broadcastMessage, f);
}
ChatService.BroadcastFaction(broadcastMessage, u.Faction);
[Command("r", "~m~Benutzung: ~s~/r [Nachricht]", GreedyArg = true)]
public void CmdFactionR(Client player, string message)
{
Entities.Faction f = player.GetFaction();
if (f == null || !f.StateOwned)
{
ChatService.NotAuthorized(player);
return;
}
string broadcastMessage = "!{33AA33}** " + player.Name + ": " + message + ", over **";
ChatService.BroadcastFaction(broadcastMessage, f);
}
[Command("d", "~m~Benutzung: ~s~/d [Nachricht]", GreedyArg = true)]
public void CmdFactionD(Client player, string message)
{
Entities.Faction f = player.GetFaction();
if (f == null || !f.StateOwned)
{
ChatService.NotAuthorized(player);
return;
}
string broadcastMessage = "!{CC3333}** " + player.Name + ": " + message + ", over **";
using(var context = new DatabaseContext())
{
ChatService.BroadcastFaction(broadcastMessage, context.Factions.ToList().FindAll(c => c.StateOwned));
}
}
}
}