*MedicFix, +New Gangzone Editor
This commit is contained in:
@@ -3413,73 +3413,23 @@ namespace ReallifeGamemode.Server.Commands
|
||||
player.SendChatMessage("~m~Benutzung:~s~ /business [price] [Option]");
|
||||
}
|
||||
|
||||
[Command("createturf", "~m~Benutzung:~s~ /createturf [radius]")]
|
||||
public void CmdAdmCreateTurf(Player player, float option)
|
||||
[Command("creategangzone", "~m~Benutzung:~s~ /creategangzone")]
|
||||
public void CmdAdminCreateGangZone(Player player)
|
||||
{
|
||||
if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
player.TriggerEvent("ADMIN:CreateTurf", JsonConvert.SerializeObject(option));
|
||||
}
|
||||
|
||||
[Command("setturf", "~m~Benutzung:~s~ /setturf (Name)")]
|
||||
public void CmdAdmSetTurf(Player player, string name)
|
||||
{
|
||||
if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
|
||||
if (player.GetData<bool>("editmode") == false)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
ChatService.SendMessage(player, "Bitte vorher den Edit-Mode aktivieren");
|
||||
return;
|
||||
}
|
||||
player.TriggerEvent("ADMIN:SetTurf", name);
|
||||
player.SendNotification("Gangzone-Editor aktiviert");
|
||||
player.TriggerEvent("SERVER:Load_Gangzone_Editor");
|
||||
}
|
||||
|
||||
[Command("cancleturf", "~m~Benutzung:~s~ /cancleturf")]
|
||||
public void CmdAdmCancleTurf(Player player)
|
||||
{
|
||||
if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
Gangwar.Gangwar.loadPlayer(player);
|
||||
}
|
||||
|
||||
[Command("reloadturfs", "~m~Benutzung:~s~ /ReloadTurfs")]
|
||||
public void CmdAdmReloadTurf(Player player)
|
||||
{
|
||||
if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
Gangwar.Gangwar.loadTurfs();
|
||||
Gangwar.Gangwar.loadTurfs_ToAllPlayers();
|
||||
}
|
||||
|
||||
[Command("deleteturf", "~m~Benutzung:~s~ /DeleteTurfs")]
|
||||
public void CmdAdmDeleteTurf(Player player)
|
||||
{
|
||||
if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
player.TriggerEvent("ADMIN:DeleteTurf");
|
||||
}
|
||||
|
||||
[Command("setturfpoint", "~m~Benutzung:~s~ /setturfpoint")]
|
||||
public void CmdAdmSetTurfPoint(Player player)
|
||||
{
|
||||
if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
player.TriggerEvent("ADMIN:Turf_CreateLeaderBlip");
|
||||
}
|
||||
|
||||
#endregion ALevel1337
|
||||
|
||||
#region ALevel1338
|
||||
|
||||
@@ -369,7 +369,7 @@ namespace ReallifeGamemode.Server.Commands
|
||||
target.Health = 100;
|
||||
target.SendNotification($"Du wurdest von ~g~{player.Name} ~s~ für ~g~{price.ToMoneyString()} geheilt.", false);
|
||||
player.SendNotification($"Du hast ~g~{target.Name} ~s~ für {price.ToMoneyString()} geheilt.", false);
|
||||
player.TriggerEvent("delHealTask");
|
||||
Medic.delHealTask(target);
|
||||
}
|
||||
|
||||
#endregion Sanitäter Commands
|
||||
|
||||
@@ -74,10 +74,10 @@ namespace ReallifeGamemode.Server.Events
|
||||
killerPosY = killer.Position.Y;
|
||||
killerPosZ = killer.Position.Z;
|
||||
killerHeading = killer.Heading;
|
||||
if (player.HasData("inGangWar") && killer.HasData("inGangWar"))
|
||||
/*if (player.HasData("inGangWar") && killer.HasData("inGangWar"))
|
||||
{
|
||||
Gangwar.Gangwar.GangwarKill(killer, player);
|
||||
}
|
||||
}*/
|
||||
|
||||
if (player != killer)
|
||||
{
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
player.SetData("duty", false);
|
||||
player.SetData("Adminduty", false);
|
||||
player.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney, 0);
|
||||
Gangwar.Gangwar.loadPlayer(player);
|
||||
//Gangwar.Gangwar.loadPlayer(player);
|
||||
if (user.FactionLeader)
|
||||
{
|
||||
player.TriggerEvent("CLIENT:Turf_LoadLeaderBlip");
|
||||
|
||||
@@ -125,7 +125,7 @@ namespace ReallifeGamemode.Server.Factions.Medic
|
||||
[RemoteEvent("delHealTask")]
|
||||
public static void delHealTask(Player player)
|
||||
{
|
||||
MedicTask task = HealTasks.FirstOrDefault(t => t.Victim == player.Name);
|
||||
MedicTask task = HealTasks.FirstOrDefault(t => t.Victim == player.Name || t.MedicName == player.Name);
|
||||
RemoveTaskFromList(task);
|
||||
player.SetData("healauftrag", false);
|
||||
}
|
||||
|
||||
@@ -11,219 +11,6 @@ namespace ReallifeGamemode.Server.Gangwar
|
||||
{
|
||||
public class Gangwar : Script
|
||||
{
|
||||
public static Turf[] _loadedTurfs;
|
||||
private static List<Turfs> turfs;
|
||||
|
||||
public static void loadTurfs()
|
||||
{
|
||||
_loadedTurfs = null;
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
turfs = context.Turfs.Select(t => t).ToList();
|
||||
List<Turf> turfing = new List<Turf>();
|
||||
foreach (var t in turfs)
|
||||
{
|
||||
Turf newTurf = new Turf(t.Id, t.Name, t.Color, t.Owner, t.Value, t.MaxValue, t.Surplus);
|
||||
turfing.Add(newTurf);
|
||||
}
|
||||
_loadedTurfs = turfing.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public static void loadPlayer(Player client)
|
||||
{
|
||||
client.TriggerEvent("GangAreas:Create", JsonConvert.SerializeObject(turfs.ToArray()));
|
||||
}
|
||||
|
||||
public static void loadTurfs_ToAllPlayers()
|
||||
{
|
||||
NAPI.ClientEvent.TriggerClientEventForAll("GangAreas:Create", JsonConvert.SerializeObject(turfs.ToArray()));
|
||||
foreach (var l in NAPI.Pools.GetAllPlayers())
|
||||
{
|
||||
if (!l.IsLoggedIn() && !l.GetUser().FactionLeader)
|
||||
return;
|
||||
|
||||
l.TriggerEvent("CLIENT:Turf_LoadLeaderBlip");
|
||||
}
|
||||
}
|
||||
|
||||
public static void GangwarKill(Player killer, Player victim)
|
||||
{
|
||||
if (killer.HasData("GotInsideOfTurf") && victim.HasData("GotInsideOfTurf"))
|
||||
{
|
||||
foreach (var turf in getTurfs())
|
||||
{
|
||||
if (turf.getId() == victim.GetData<int>("inGangWar"))
|
||||
{
|
||||
turf.setKill(victim.GetUser().Faction.Name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Turf[] getTurfs()
|
||||
{
|
||||
return _loadedTurfs;
|
||||
}
|
||||
|
||||
[RemoteEvent("Gangarea:Enter")]
|
||||
public void RmtEvent_TurfEnter(Player client, string jsonId)
|
||||
{
|
||||
int id = JsonConvert.DeserializeObject<int>(jsonId);
|
||||
|
||||
foreach (var turf in getTurfs())
|
||||
{
|
||||
if (turf.getId() == id)
|
||||
{
|
||||
turf.enter(client);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("Gangarea:Leave")]
|
||||
public void RmtEvent_TurfLeave(Player client, string jsonId)
|
||||
{
|
||||
int id = JsonConvert.DeserializeObject<int>(jsonId);
|
||||
|
||||
foreach (var turf in getTurfs())
|
||||
{
|
||||
if (turf.getId() == id)
|
||||
{
|
||||
turf.leave(client);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("SERVER:SetTurf")]
|
||||
public void RmtEvent_SetTurf(Player client, string jsonX, string jsonY, string jsonRot, string jsonRange, string Name)
|
||||
{
|
||||
float pX = JsonConvert.DeserializeObject<float>(jsonX);
|
||||
float pY = (float)JsonConvert.DeserializeObject<float>(jsonY);
|
||||
float Rot = (float)JsonConvert.DeserializeObject<float>(jsonRot);
|
||||
float Range = (float)JsonConvert.DeserializeObject<float>(jsonRange);
|
||||
|
||||
var newTurf = new Turfs
|
||||
{
|
||||
Name = Name,
|
||||
X = pX,
|
||||
Y = pY,
|
||||
Rotation = Rot,
|
||||
Range = Range,
|
||||
Owner = "Neutral",
|
||||
Color = 0,
|
||||
Vector = null
|
||||
};
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
dbContext.Turfs.Add(newTurf);
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
loadTurfs();
|
||||
loadTurfs_ToAllPlayers();
|
||||
}
|
||||
|
||||
[RemoteEvent("SERVER:DeleteTurf")]
|
||||
public void RmtEvent_DeleteTurf(Player client, string jsonId)
|
||||
{
|
||||
int id = JsonConvert.DeserializeObject<int>(jsonId);
|
||||
if (id == -1)
|
||||
{
|
||||
ChatService.ErrorMessage(client, "Du befindest dich in keinem Gebiet!");
|
||||
return;
|
||||
}
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
Turfs dturf = dbContext.Turfs.Where(t => t.Id == id).FirstOrDefault();
|
||||
if (dturf != null)
|
||||
{
|
||||
dbContext.Turfs.Remove(dturf);
|
||||
dbContext.SaveChanges();
|
||||
loadTurfs();
|
||||
loadTurfs_ToAllPlayers();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("SERVER:Turf_SetNewLeaderPoint")]
|
||||
public void RmtEvent_SetNewLeaderPoint(Player client, string vector, string jsonId)
|
||||
{
|
||||
int id = JsonConvert.DeserializeObject<int>(jsonId);
|
||||
if (id == -1)
|
||||
{
|
||||
ChatService.ErrorMessage(client, "Du befindest dich in keinem Gebiet");
|
||||
return;
|
||||
}
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
Turfs dturf = dbContext.Turfs.Where(t => t.Id == id).FirstOrDefault();
|
||||
if (dturf != null)
|
||||
{
|
||||
dturf.Vector = vector;
|
||||
dbContext.SaveChanges();
|
||||
loadTurfs();
|
||||
loadTurfs_ToAllPlayers();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("SERVER:StartGangwar")]
|
||||
public void RmtEvent_StartGangwar(Player client)
|
||||
{
|
||||
if (!client.GetUser().FactionLeader)
|
||||
return;
|
||||
|
||||
foreach (var turf in getTurfs())
|
||||
{
|
||||
if (turf.status == "attack")
|
||||
{
|
||||
ChatService.ErrorMessage(client, "Du kannst momentan kein Gangwar starten");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (client.GetUser().Faction.Name == "Ballas" || client.GetUser().Faction.Name == "Grove")
|
||||
{
|
||||
foreach (var turf in getTurfs())
|
||||
{
|
||||
foreach (var u in turf.playerInside)
|
||||
{
|
||||
if (u == client)
|
||||
{
|
||||
if (turf.Owner != client.GetUser().Faction.Name)
|
||||
turf.attack(client.GetUser().Faction.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void Value_TimerElapsed()
|
||||
{
|
||||
List<int> values = new List<int>();
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
foreach (var turf in getTurfs())
|
||||
{
|
||||
if ((turf.getValue() + 5) >= turf.getMaxValue())
|
||||
{
|
||||
turf.setValue(turf.getMaxValue());
|
||||
}
|
||||
else
|
||||
{
|
||||
turf.addValue(5);
|
||||
}
|
||||
values.Add(turf.getValue());
|
||||
Turfs _turf = dbContext.Turfs.Where(t => t.Id == turf.getId()).FirstOrDefault();
|
||||
_turf.Value = turf.getValue();
|
||||
}
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
NAPI.Task.Run(() =>
|
||||
{
|
||||
NAPI.ClientEvent.TriggerClientEventForAll("CLIENT:UpdateTurfValue", JsonConvert.SerializeObject(values.ToArray()));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,339 +14,6 @@ namespace ReallifeGamemode.Server.Gangwar
|
||||
{
|
||||
public class Turf
|
||||
{
|
||||
public int TurfID { get; set; }
|
||||
public string TurfName { get; set; }
|
||||
public int Color { get; set; }
|
||||
public string Owner { get; set; }
|
||||
public string Attacker { get; set; }
|
||||
public int Att_Score { get; set; }
|
||||
public int Def_Score { get; set; }
|
||||
public string status { get; set; }
|
||||
public int value { get; set; }
|
||||
public int maxValue { get; set; }
|
||||
public bool surplus { get; set; }
|
||||
public List<Player> playerInside { get; set; }
|
||||
public Timer timer { get; set; }
|
||||
public Player[] playerInGangwar { get; set; }
|
||||
public int timerCount;
|
||||
|
||||
public Turf(int TurfID, string TurfName, int color, string Owner, int value, int maxValue, bool surplus)
|
||||
{
|
||||
this.TurfID = TurfID;
|
||||
this.TurfName = TurfName;
|
||||
this.Color = color;
|
||||
this.Owner = Owner;
|
||||
this.value = value;
|
||||
this.maxValue = maxValue;
|
||||
this.surplus = surplus;
|
||||
this.Attacker = null;
|
||||
this.Att_Score = 1;
|
||||
this.Def_Score = 0;
|
||||
this.status = "normal";
|
||||
this.timer = null;
|
||||
this.playerInside = new List<Player>();
|
||||
this.timerCount = 0;
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return this.TurfID;
|
||||
}
|
||||
|
||||
public int getValue()
|
||||
{
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public void setValue(int value)
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public void addValue(int addedValue)
|
||||
{
|
||||
this.value += addedValue;
|
||||
}
|
||||
|
||||
public int getMaxValue()
|
||||
{
|
||||
return maxValue;
|
||||
}
|
||||
|
||||
public bool getSurplus()
|
||||
{
|
||||
return surplus;
|
||||
}
|
||||
|
||||
public void setSurplus(bool surplus)
|
||||
{
|
||||
this.surplus = surplus;
|
||||
}
|
||||
|
||||
public string getName()
|
||||
{
|
||||
return this.TurfName;
|
||||
}
|
||||
|
||||
public int getColor()
|
||||
{
|
||||
return this.Color;
|
||||
}
|
||||
|
||||
public string getOwner()
|
||||
{
|
||||
return this.Owner;
|
||||
}
|
||||
|
||||
public string getAttacker()
|
||||
{
|
||||
return this.Attacker;
|
||||
}
|
||||
|
||||
private void TurfTick()
|
||||
{
|
||||
this.timer = new System.Timers.Timer(1000);
|
||||
|
||||
this.timer.Elapsed += Tick;
|
||||
this.timer.AutoReset = true;
|
||||
this.timer.Enabled = true;
|
||||
this.timerCount = 0;
|
||||
}
|
||||
|
||||
private void Tick(object sender, System.Timers.ElapsedEventArgs e)
|
||||
{
|
||||
if (this.status == "attack")
|
||||
{
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
private void update()
|
||||
{
|
||||
#region Ticket system
|
||||
|
||||
/*
|
||||
try
|
||||
{
|
||||
Player[] owners = NAPI.Pools.GetAllPlayers().Where(c => c.GetUser().Faction.Name == this.Owner).ToArray();
|
||||
Player[] attackers = NAPI.Pools.GetAllPlayers().Where(c => c.GetUser().Faction.Name == this.Attacker).ToArray();
|
||||
}catch(NullReferenceException ex)
|
||||
{
|
||||
int i = 0;
|
||||
foreach(var c in playerInGangwar)
|
||||
{
|
||||
if (!NAPI.Entity.DoesEntityExist(c.Handle))
|
||||
{
|
||||
this.playerInside = this.playerInside.Where(gp => gp != c).ToArray();
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (owners.Length > attackers.Length)
|
||||
this.Att_Score -= owners.Length - attackers.Length;
|
||||
if(owners.Length < attackers.Length)
|
||||
this.Def_Score -= attackers.Length - owners.Length;
|
||||
*/
|
||||
|
||||
#endregion Ticket system
|
||||
|
||||
foreach (Player gangwarPlayer in this.playerInGangwar)
|
||||
{
|
||||
gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, this.Att_Score, this.Def_Score, 900 - timerCount);
|
||||
}
|
||||
if (this.Att_Score >= 200)
|
||||
{
|
||||
this.takeOver(this.Attacker);
|
||||
}
|
||||
else if (this.Def_Score >= 200)
|
||||
{
|
||||
this.takeOver(this.Owner);
|
||||
}
|
||||
timerCount += 1;
|
||||
if (timerCount >= 900) //change to 900 (seconds) before release for testing reasons change to whatever you like
|
||||
{
|
||||
if (this.Att_Score > this.Def_Score)
|
||||
{
|
||||
foreach (Player gangwarPlayer in this.playerInGangwar)
|
||||
{
|
||||
gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, 0, 0, 0);
|
||||
}
|
||||
this.takeOver(this.Attacker);
|
||||
this.Def_Score = 0;
|
||||
return;
|
||||
}
|
||||
else if (this.Att_Score < this.Def_Score)
|
||||
{
|
||||
foreach (Player gangwarPlayer in this.playerInGangwar)
|
||||
{
|
||||
gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, 0, 0, 0);
|
||||
}
|
||||
this.takeOver(this.Owner);
|
||||
this.Att_Score = 0;
|
||||
return;
|
||||
}
|
||||
else if (this.Def_Score == this.Att_Score)
|
||||
{
|
||||
foreach (Player gangwarPlayer in this.playerInGangwar)
|
||||
{
|
||||
gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, 0, 0, 0);
|
||||
}
|
||||
this.takeOver(this.Owner);
|
||||
this.Def_Score = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void enter(Player client)
|
||||
{
|
||||
if (this.status == "attack")
|
||||
{
|
||||
if (client.GetUser().Faction.Name != getOwner() && client.GetUser().Faction.Name != getAttacker())
|
||||
return;
|
||||
Player gPlayer = playerInGangwar.Where(c => c.GetUser().Id == client.GetUser().Id).FirstOrDefault();
|
||||
if (gPlayer == null)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
ChatService.BroadcastFaction("~y~[GANGWAR] ~r~" + client.Name + "~w~ ist nicht im Gangwar beteiligt !", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault());
|
||||
ChatService.BroadcastFaction("~y~[GANGWAR] ~r~" + client.Name + "~w~ ist nicht im Gangwar beteiligt !", dbContext.Factions.Where(f => f.Name == getAttacker()).FirstOrDefault());
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (playerInside.Find(c => c == client) == null)
|
||||
{
|
||||
playerInside.Add(client);
|
||||
client.SetData("GotInsideOfTurf", true);
|
||||
}
|
||||
}
|
||||
|
||||
public void leave(Player client)
|
||||
{
|
||||
if (playerInside.Find(c => c == client) != null)
|
||||
{
|
||||
this.playerInside = this.playerInside.Where(c => c != client).ToList();
|
||||
if (this.status != "attack")
|
||||
client.ResetData("GotInsideOfTurf");
|
||||
}
|
||||
}
|
||||
|
||||
public void takeOver(string FactionName)
|
||||
{
|
||||
this.timer.Stop();
|
||||
this.timer = null;
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
if (getOwner() == FactionName)
|
||||
{
|
||||
Player[] owners = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && c.GetUser().Faction.Name == this.Owner).ToArray();
|
||||
Player[] attackers = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && c.GetUser().Faction.Name == this.Attacker).ToArray();
|
||||
foreach (var o in owners)
|
||||
{
|
||||
o.TriggerEvent("CLIENT:win");
|
||||
}
|
||||
foreach (var a in attackers)
|
||||
{
|
||||
a.TriggerEvent("CLIENT:loose");
|
||||
}
|
||||
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion hat erfolgreich das Gebiet ~g~" + getName() + "~w~ verteidigt.", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault());
|
||||
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion hat den Angrif auf das Gebiet ~r~" + getName() + "~w~ verloren.", dbContext.Factions.Where(f => f.Name == getAttacker()).FirstOrDefault());
|
||||
}
|
||||
else if (getOwner() != FactionName)
|
||||
{
|
||||
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion konnte das Gebiet ~r~" + getName() + "~w~ nicht verteidigen.", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault());
|
||||
Player[] owners = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && c.GetUser().Faction.Name == this.Owner).ToArray();
|
||||
Player[] attackers = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && c.GetUser().Faction.Name == this.Attacker).ToArray();
|
||||
foreach (var o in owners)
|
||||
{
|
||||
o.TriggerEvent("CLIENT:loose");
|
||||
}
|
||||
foreach (var a in attackers)
|
||||
{
|
||||
a.TriggerEvent("CLIENT:win");
|
||||
}
|
||||
this.Owner = FactionName;
|
||||
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion konnte erfolgreich das Gebiet ~g~" + getName() + "~w~ erobern.", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault());
|
||||
Turfs turf = dbContext.Turfs.Where(t => t.Id == getId()).FirstOrDefault();
|
||||
turf.Owner = this.Owner;
|
||||
turf.FactionId = dbContext.Factions.Where(f => f.Name == this.Owner).FirstOrDefault().Id;
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
this.Attacker = null;
|
||||
foreach (var c in playerInGangwar)
|
||||
{
|
||||
c.TriggerEvent("CLIENT:setAttackBlip", false, TurfID);
|
||||
c.ResetData("inGangWar");
|
||||
c.ResetData("GotInsideOfTurf");
|
||||
}
|
||||
this.playerInGangwar = null;
|
||||
Gangwar.loadTurfs();
|
||||
Gangwar.loadTurfs_ToAllPlayers();
|
||||
}
|
||||
|
||||
public void attack(string attacker)
|
||||
{
|
||||
Player[] usersInGangwar;
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
var onlinePlayers = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn()).Select(c => c.Name);
|
||||
|
||||
List<Player> ownersInGangwar = context.Users.Include(u => u.Faction).Where(u => onlinePlayers.Contains(u.Name) && u.Faction.Name == getOwner()).Select(u => u.Player).ToList();
|
||||
List<Player> attackersInGangwar = context.Users.Include(u => u.Faction).Where(u => onlinePlayers.Contains(u.Name) && u.Faction.Name == attacker).Select(u => u.Player).ToList();
|
||||
|
||||
if (ownersInGangwar.Count < 0 && attackersInGangwar.Count < 0)
|
||||
{
|
||||
List<Player> leaders = context.Users.Include(u => u.Faction).Where(u => onlinePlayers.Contains(u.Name) && u.Faction.Name == attacker && u.FactionLeader).Select(u => u.Player).ToList();
|
||||
foreach (var l in leaders)
|
||||
{
|
||||
ChatService.ErrorMessage(l, "Gangwarstart ist nicht möglich, da die beteiligten Fraktionen nicht genügend Mitglieder aufweisen.");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
List<Player> inGangwar = new List<Player>(ownersInGangwar.Concat(attackersInGangwar));
|
||||
|
||||
usersInGangwar = inGangwar.ToArray();
|
||||
}
|
||||
if (this.status == "normal")
|
||||
{
|
||||
if (this.timer != null)
|
||||
{
|
||||
this.timer.Stop();
|
||||
this.timer = null;
|
||||
}
|
||||
this.Attacker = attacker;
|
||||
this.status = "attack";
|
||||
|
||||
List<Player> clientsInGangwar = new List<Player>();
|
||||
|
||||
foreach (var u in usersInGangwar)
|
||||
{
|
||||
u.TriggerEvent("CLIENT:setAttackBlip", true, TurfID);
|
||||
u.TriggerEvent("GangwarScore", this.Attacker, this.Owner, this.Att_Score, this.Def_Score);
|
||||
u.SetData("inGangWar", getId());
|
||||
ChatService.SendMessage(u, "~y~[GANGWAR]~w~ Die " + getAttacker() + " haben das Gebiet ~y~" + TurfName + "~w~ der " + getOwner() + " angegriffen.");
|
||||
clientsInGangwar.Add(u);
|
||||
}
|
||||
playerInGangwar = clientsInGangwar.ToArray();
|
||||
NAPI.ClientEvent.TriggerClientEventForAll("CLIENT:Turf_Update", JsonConvert.SerializeObject(this.TurfID), JsonConvert.SerializeObject(this.status), JsonConvert.SerializeObject(this.Owner), JsonConvert.SerializeObject(this.Attacker));
|
||||
this.TurfTick();
|
||||
}
|
||||
}
|
||||
|
||||
public void setKill(string FactionName)
|
||||
{
|
||||
if (getOwner() == FactionName)
|
||||
{
|
||||
Att_Score += 1;
|
||||
}
|
||||
else if (getAttacker() == FactionName)
|
||||
{
|
||||
Def_Score += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ namespace ReallifeGamemode.Server
|
||||
//HouseManager.LoadHouses();
|
||||
DrivingSchool.DrivingSchool.Setup();
|
||||
PlaneSchool.Setup();
|
||||
Gangwar.Gangwar.loadTurfs();
|
||||
//Gangwar.Gangwar.loadTurfs();
|
||||
Bank.bank.Setup();
|
||||
Introduction.Setup();
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace ReallifeGamemode.Server.Util
|
||||
{
|
||||
WantedEscapeTimer.Timer_Elapsed();
|
||||
Jail.JailIn_Elapsed();
|
||||
Gangwar.Gangwar.Value_TimerElapsed();
|
||||
//Gangwar.Gangwar.Value_TimerElapsed();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user