fix GW
This commit is contained in:
@@ -16,6 +16,10 @@ export default function (globalData: GlobalData): void {
|
|||||||
var adutyMode = false;
|
var adutyMode = false;
|
||||||
var dutyMode = false;
|
var dutyMode = false;
|
||||||
let jailTime = 0;
|
let jailTime = 0;
|
||||||
|
let att_score = 0;
|
||||||
|
let def_score = 0;
|
||||||
|
let att = null;
|
||||||
|
let def = null;
|
||||||
let countdown = 0;
|
let countdown = 0;
|
||||||
var cdTimestamp;
|
var cdTimestamp;
|
||||||
var countdownText;
|
var countdownText;
|
||||||
@@ -73,6 +77,13 @@ export default function (globalData: GlobalData): void {
|
|||||||
jailTime = time;
|
jailTime = time;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
mp.events.add("GangwarScore", (attacker, defender, attscore, defscore) => {
|
||||||
|
att = attacker;
|
||||||
|
def = defender;
|
||||||
|
att_score = attscore;
|
||||||
|
def_score = defscore;
|
||||||
|
});
|
||||||
|
|
||||||
mp.events.add("countdown", (timer, text) => {
|
mp.events.add("countdown", (timer, text) => {
|
||||||
countdown = timer;
|
countdown = timer;
|
||||||
cdTimestamp = Date.now();
|
cdTimestamp = Date.now();
|
||||||
@@ -238,6 +249,18 @@ export default function (globalData: GlobalData): void {
|
|||||||
centre: false
|
centre: false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (att_score > 0 && def_score > 0) {
|
||||||
|
mp.game.graphics.drawText("~y~" + def + " " + def_score + " : " + att_score + " " + att, [0.92, 0.50],
|
||||||
|
{
|
||||||
|
font: 4,
|
||||||
|
color: [255, 255, 255, 255],
|
||||||
|
scale: [0.5, 0.5],
|
||||||
|
outline: true,
|
||||||
|
centre: false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (editMode === true) {
|
if (editMode === true) {
|
||||||
mp.game.graphics.drawText("~r~EDIT-MODE AKTIV", [0.5, 0],
|
mp.game.graphics.drawText("~r~EDIT-MODE AKTIV", [0.5, 0],
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace ReallifeGamemode.Server.Gangwar
|
|||||||
public int Att_Score { get; set; }
|
public int Att_Score { get; set; }
|
||||||
public int Def_Score { get; set; }
|
public int Def_Score { get; set; }
|
||||||
public string status { get; set; }
|
public string status { get; set; }
|
||||||
public Client[] playerInside { get; set; }
|
public List<Client> playerInside { get; set; }
|
||||||
public Timer timer { get; set; }
|
public Timer timer { get; set; }
|
||||||
public Client[] playerInGangwar { get; set; }
|
public Client[] playerInGangwar { get; set; }
|
||||||
|
|
||||||
@@ -39,6 +39,7 @@ namespace ReallifeGamemode.Server.Gangwar
|
|||||||
this.Def_Score = 5;
|
this.Def_Score = 5;
|
||||||
this.status = "normal";
|
this.status = "normal";
|
||||||
this.timer = null;
|
this.timer = null;
|
||||||
|
this.playerInside = new List<Client>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId()
|
public int getId()
|
||||||
@@ -107,10 +108,7 @@ namespace ReallifeGamemode.Server.Gangwar
|
|||||||
if(owners.Length < attackers.Length)
|
if(owners.Length < attackers.Length)
|
||||||
this.Def_Score -= attackers.Length - owners.Length;
|
this.Def_Score -= attackers.Length - owners.Length;
|
||||||
*/
|
*/
|
||||||
foreach (Client gangwarPlayer in this.playerInGangwar)
|
|
||||||
{
|
|
||||||
gangwarPlayer.TriggerEvent("CLIENT:ScoreUpdate", JsonConvert.SerializeObject(this.Att_Score), JsonConvert.SerializeObject(this.Def_Score), JsonConvert.SerializeObject(this.TurfID));
|
|
||||||
}
|
|
||||||
if (this.Def_Score <= 0)
|
if (this.Def_Score <= 0)
|
||||||
{
|
{
|
||||||
this.takeOver(this.Attacker);
|
this.takeOver(this.Attacker);
|
||||||
@@ -138,21 +136,19 @@ namespace ReallifeGamemode.Server.Gangwar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Array.IndexOf(this.playerInside, client) == -1) {
|
if(playerInside.Find(c => c == client) == null) {
|
||||||
Client[] refObj = this.playerInside;
|
playerInside.Add(client);
|
||||||
Array.Resize(ref refObj, this.playerInside.Length + 1);
|
client.SetData("GotInsideOfTurf", true);
|
||||||
this.playerInside = refObj;
|
|
||||||
this.playerInside[this.playerInside.GetUpperBound(0)] = client;
|
|
||||||
if (status == "attack")
|
|
||||||
client.SetData("GotInsideOfTurf", true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void leave(Client client)
|
public void leave(Client client)
|
||||||
{
|
{
|
||||||
if(Array.IndexOf(this.playerInside, client) > -1)
|
if(playerInside.Find(c => c == client) != null)
|
||||||
{
|
{
|
||||||
this.playerInside = this.playerInside.Where(c => c != client).ToArray();
|
this.playerInside = this.playerInside.Where(c => c != client).ToList();
|
||||||
|
if(this.status != "attack")
|
||||||
|
client.ResetData("GotInsideOfTurf");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,14 +165,14 @@ namespace ReallifeGamemode.Server.Gangwar
|
|||||||
}
|
}
|
||||||
else if (getOwner() != FactionName)
|
else if (getOwner() != FactionName)
|
||||||
{
|
{
|
||||||
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion konnte das Gebiet " + getName() + " nicht verteidigen.", dbContext.Factions.Where(f => f.Name == getAttacker()).FirstOrDefault());
|
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion konnte das Gebiet ~r~" + getName() + "~w~ nicht verteidigen.", dbContext.Factions.Where(f => f.Name == getAttacker()).FirstOrDefault());
|
||||||
this.Owner = FactionName;
|
this.Owner = FactionName;
|
||||||
Turfs turf = dbContext.Turfs.Where(t => t.Id == getId()).FirstOrDefault();
|
Turfs turf = dbContext.Turfs.Where(t => t.Id == getId()).FirstOrDefault();
|
||||||
turf.Owner = this.Owner;
|
turf.Owner = this.Owner;
|
||||||
turf.FactionId = dbContext.Factions.Where(f => f.Name == this.Owner).FirstOrDefault().Id;
|
turf.FactionId = dbContext.Factions.Where(f => f.Name == this.Owner).FirstOrDefault().Id;
|
||||||
dbContext.SaveChanges();
|
dbContext.SaveChanges();
|
||||||
}
|
}
|
||||||
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion hat erfolgreich das Gebiet " + getName() + " erobert.", dbContext.Factions.Where(f => f.Name == this.Owner).FirstOrDefault());
|
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion hat erfolgreich das Gebiet ~g~" + getName() + "~w~ erobert.", dbContext.Factions.Where(f => f.Name == this.Owner).FirstOrDefault());
|
||||||
}
|
}
|
||||||
this.Attacker = null;
|
this.Attacker = null;
|
||||||
foreach(var c in playerInGangwar)
|
foreach(var c in playerInGangwar)
|
||||||
@@ -207,6 +203,7 @@ namespace ReallifeGamemode.Server.Gangwar
|
|||||||
Client[] usersInGangwar = NAPI.Pools.GetAllPlayers().Where(c => c.GetUser().Faction.Name == getOwner() || c.GetUser().Faction.Name == getAttacker()).ToArray();
|
Client[] usersInGangwar = NAPI.Pools.GetAllPlayers().Where(c => c.GetUser().Faction.Name == getOwner() || c.GetUser().Faction.Name == getAttacker()).ToArray();
|
||||||
foreach (var u in usersInGangwar)
|
foreach (var u in usersInGangwar)
|
||||||
{
|
{
|
||||||
|
u.TriggerEvent("GangwarScore", this.Attacker, this.Owner, this.Att_Score, this.Def_Score);
|
||||||
u.SetData("inGangWar", getId());
|
u.SetData("inGangWar", getId());
|
||||||
clientsInGangwar.Add(u);
|
clientsInGangwar.Add(u);
|
||||||
}
|
}
|
||||||
@@ -231,7 +228,7 @@ namespace ReallifeGamemode.Server.Gangwar
|
|||||||
|
|
||||||
foreach (Client gangwarPlayer in this.playerInGangwar)
|
foreach (Client gangwarPlayer in this.playerInGangwar)
|
||||||
{
|
{
|
||||||
gangwarPlayer.TriggerEvent("CLIENT:ScoreUpdate1", JsonConvert.SerializeObject(this.Att_Score), JsonConvert.SerializeObject(this.Def_Score), JsonConvert.SerializeObject(this.TurfID));
|
gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, this.Att_Score, this.Def_Score);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user