add Blips and Sounds to Gangwar
This commit is contained in:
@@ -55,6 +55,7 @@
|
|||||||
_inColshape: boolean;
|
_inColshape: boolean;
|
||||||
_timerCheck;
|
_timerCheck;
|
||||||
edit: boolean;
|
edit: boolean;
|
||||||
|
attackBlip: BlipMp;
|
||||||
|
|
||||||
constructor(name, id, x, y, range, color, rot, owner, edit) {
|
constructor(name, id, x, y, range, color, rot, owner, edit) {
|
||||||
this._setup(name, id, x, y, range, color, rot, owner, edit);
|
this._setup(name, id, x, y, range, color, rot, owner, edit);
|
||||||
@@ -80,6 +81,7 @@
|
|||||||
self.attacker = null;
|
self.attacker = null;
|
||||||
self.edit = edit;
|
self.edit = edit;
|
||||||
self.loadArea();
|
self.loadArea();
|
||||||
|
self.attackBlip = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
setColor(owner) {
|
setColor(owner) {
|
||||||
@@ -213,6 +215,18 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setAttackBlip(bool) {
|
||||||
|
var self = this;
|
||||||
|
if (bool) {
|
||||||
|
self.attackBlip = mp.game.ui.addBlipForRadius(self.x, self.y, 1, 3);
|
||||||
|
mp.game.invoke(Natives.SET_BLIP_SPRITE, self.attackBlip, 378);
|
||||||
|
mp.game.invoke(Natives.SET_BLIP_FLASHES, self.attackBlip, true);
|
||||||
|
} else if (!bool) {
|
||||||
|
mp.game.invoke(Natives.SET_BLIP_ALPHA, self.blip, 0);
|
||||||
|
mp.game.invoke(Natives.SET_BLIP_FLASHES, self.attackBlip, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
isTurfArea(shape) {
|
isTurfArea(shape) {
|
||||||
return (shape == this._colshape)
|
return (shape == this._colshape)
|
||||||
}
|
}
|
||||||
@@ -237,11 +251,13 @@
|
|||||||
if ((!self._entered)) {
|
if ((!self._entered)) {
|
||||||
if (self.isInsideArea() && (self.isNearGround() == true)) {
|
if (self.isInsideArea() && (self.isNearGround() == true)) {
|
||||||
self._entered = true;
|
self._entered = true;
|
||||||
|
mp.game.audio.playSoundFrontend(1, "Enter_Capture_Zone", "DLC_Apartments_Drop_Zone_Sounds", true);
|
||||||
mp.events.callRemote("Gangarea:Enter", JSON.stringify(self.id));
|
mp.events.callRemote("Gangarea:Enter", JSON.stringify(self.id));
|
||||||
}
|
}
|
||||||
} else if (self._entered == true) {
|
} else if (self._entered == true) {
|
||||||
if (!self.isInsideArea() || (self.isNearGround() == false)) {
|
if (!self.isInsideArea() || (self.isNearGround() == false)) {
|
||||||
self._entered = false;
|
self._entered = false;
|
||||||
|
mp.game.audio.playSoundFrontend(1, "Exit_Capture_Zone", "DLC_Apartments_Drop_Zone_Sounds", true);
|
||||||
mp.events.callRemote("Gangarea:Leave", JSON.stringify(self.id));
|
mp.events.callRemote("Gangarea:Leave", JSON.stringify(self.id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -331,6 +347,13 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
mp.events.add('CLIENT:loose', () => {
|
||||||
|
mp.game.audio.playSoundFrontend(1, "Zone_Enemy_Capture", "DLC_Apartments_Drop_Zone_Sounds", true);
|
||||||
|
});
|
||||||
|
mp.events.add('CLIENT:win', () => {
|
||||||
|
mp.game.audio.playSoundFrontend(1, "Zone_Team_Capture", "DLC_Apartments_Drop_Zone_Sounds", true);
|
||||||
|
});
|
||||||
|
|
||||||
function clearBlips() {
|
function clearBlips() {
|
||||||
mp.game.gameplay.setThisScriptCanRemoveBlipsCreatedByAnyScript(true);
|
mp.game.gameplay.setThisScriptCanRemoveBlipsCreatedByAnyScript(true);
|
||||||
var x = 0;
|
var x = 0;
|
||||||
@@ -394,13 +417,10 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
mp.events.add('CLIENT:ScoreUpdate1', (JSONattackerScore, JSONdefenderScore, JSONid) => {
|
mp.events.add('CLIENT:setAttackBlip', (bool, id) => {
|
||||||
var attackerScore = JSON.parse(JSONattackerScore);
|
|
||||||
var defenderScore = JSON.parse(JSONdefenderScore);
|
|
||||||
var id = JSON.parse(JSONid);
|
|
||||||
gangturfs.forEach(function (turf) {
|
gangturfs.forEach(function (turf) {
|
||||||
if (turf.id == id) {
|
if (turf.id == id) {
|
||||||
turf.scoreUpdate(attackerScore, defenderScore);
|
turf.setAttackBlip(bool);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ namespace ReallifeGamemode.Server.Gangwar
|
|||||||
public List<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; }
|
||||||
|
public int timerCount;
|
||||||
|
|
||||||
|
|
||||||
public Turf(int TurfID, string TurfName, int color, string Owner)
|
public Turf(int TurfID, string TurfName, int color, string Owner)
|
||||||
@@ -40,6 +41,7 @@ namespace ReallifeGamemode.Server.Gangwar
|
|||||||
this.status = "normal";
|
this.status = "normal";
|
||||||
this.timer = null;
|
this.timer = null;
|
||||||
this.playerInside = new List<Client>();
|
this.playerInside = new List<Client>();
|
||||||
|
this.timerCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId()
|
public int getId()
|
||||||
@@ -74,6 +76,7 @@ namespace ReallifeGamemode.Server.Gangwar
|
|||||||
this.timer.Elapsed += Tick;
|
this.timer.Elapsed += Tick;
|
||||||
this.timer.AutoReset = true;
|
this.timer.AutoReset = true;
|
||||||
this.timer.Enabled = true;
|
this.timer.Enabled = true;
|
||||||
|
this.timerCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Tick(object sender, System.Timers.ElapsedEventArgs e)
|
private void Tick(object sender, System.Timers.ElapsedEventArgs e)
|
||||||
@@ -84,6 +87,8 @@ namespace ReallifeGamemode.Server.Gangwar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void update()
|
private void update()
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@@ -119,6 +124,12 @@ namespace ReallifeGamemode.Server.Gangwar
|
|||||||
{
|
{
|
||||||
this.takeOver(this.Owner);
|
this.takeOver(this.Owner);
|
||||||
}
|
}
|
||||||
|
timerCount += 1;
|
||||||
|
if(timerCount >= 69)
|
||||||
|
{
|
||||||
|
this.timer.Stop();
|
||||||
|
this.timer = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enter(Client client)
|
public void enter(Client client)
|
||||||
@@ -163,23 +174,49 @@ namespace ReallifeGamemode.Server.Gangwar
|
|||||||
{
|
{
|
||||||
if (getOwner() == FactionName)
|
if (getOwner() == FactionName)
|
||||||
{
|
{
|
||||||
|
Client[] owners = NAPI.Pools.GetAllPlayers().Where(c => c.GetUser().Faction.Name == this.Owner).ToArray();
|
||||||
|
Client[] attackers = NAPI.Pools.GetAllPlayers().Where(c => 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 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());
|
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)
|
else if (getOwner() != FactionName)
|
||||||
{
|
{
|
||||||
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion konnte das Gebiet ~r~" + getName() + "~w~ nicht erobern.", dbContext.Factions.Where(f => f.Name == getAttacker()).FirstOrDefault());
|
foreach (var c in playerInGangwar)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion konnte das Gebiet ~r~" + getName() + "~w~ nicht verteidigen.", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault());
|
||||||
|
Client[] owners = NAPI.Pools.GetAllPlayers().Where(c => c.GetUser().Faction.Name == this.Owner).ToArray();
|
||||||
|
Client[] attackers = NAPI.Pools.GetAllPlayers().Where(c => 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;
|
this.Owner = FactionName;
|
||||||
|
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion konnte erfolgreich das Gebiet ~g~" + getName() + "~w~ verteidigen.", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault());
|
||||||
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 konnte erfolgreich das Gebiet ~g~" + getName() + "~w~ verteidigen.", 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)
|
||||||
{
|
{
|
||||||
|
c.TriggerEvent("CLIENT:setAttackBlip", false, TurfID);
|
||||||
c.ResetData("inGangWar");
|
c.ResetData("inGangWar");
|
||||||
c.ResetData("GotInsideOfTurf");
|
c.ResetData("GotInsideOfTurf");
|
||||||
}
|
}
|
||||||
@@ -206,8 +243,10 @@ 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("CLIENT:setAttackBlip", true, TurfID);
|
||||||
u.TriggerEvent("GangwarScore", this.Attacker, this.Owner, this.Att_Score, this.Def_Score);
|
u.TriggerEvent("GangwarScore", this.Attacker, this.Owner, this.Att_Score, this.Def_Score);
|
||||||
u.SetData("inGangWar", getId());
|
u.SetData("inGangWar", getId());
|
||||||
|
ChatService.SendMessage(u, "~y~[GANGWAR]~w~ Die " + getAttacker() + " hat das Gebiet ~y~"+ TurfName +"~w~ der "+ getOwner() +" angegriffen.");
|
||||||
clientsInGangwar.Add(u);
|
clientsInGangwar.Add(u);
|
||||||
}
|
}
|
||||||
playerInGangwar = clientsInGangwar.ToArray();
|
playerInGangwar = clientsInGangwar.ToArray();
|
||||||
|
|||||||
Reference in New Issue
Block a user