Fixed EF error, edit commands, fix faction broadcast

This commit is contained in:
hydrant
2018-09-23 15:59:40 +02:00
parent 4631f4bb75
commit bba0f7206c
6 changed files with 82 additions and 27 deletions

View File

@@ -1,8 +1,10 @@
using GTANetworkAPI;
using reallife_gamemode.Model;
using reallife_gamemode.Server.Entities;
using reallife_gamemode.Server.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
/**
@@ -27,12 +29,22 @@ namespace reallife_gamemode.Server.Services
public static void BroadcastFaction(string message, List<Faction> factions)
{
using(var dbCon = new DatabaseContext())
using (var dbCon = new DatabaseContext())
{
foreach(User u in dbCon.Users)
foreach (User u in dbCon.Users)
{
Client c = ClientService.GetClientByName(u.Name);
if (c != null && factions.Contains(u.Faction)) c.SendChatMessage(message);
if (c != null)
{
Faction f = c.GetFaction();
if (f != null)
{
if (factions.Find(fT => fT.Id == f.Id) != null)
{
c.SendChatMessage(message);
}
}
}
}
}
}