Add RefuseCollector Job and other misc
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using System.Linq;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using GTANetworkAPI;
|
||||
using Newtonsoft.Json;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
|
||||
namespace ReallifeGamemode.Server.Gangwar
|
||||
{
|
||||
@@ -25,7 +24,7 @@ namespace ReallifeGamemode.Server.Gangwar
|
||||
List<Turf> turfing = new List<Turf>();
|
||||
foreach (var t in turfs)
|
||||
{
|
||||
Turf newTurf = new Turf(t.Id, t.Name, t.Color, t.Owner);
|
||||
Turf newTurf = new Turf(t.Id, t.Name, t.Color, t.Owner, t.Value, t.MaxValue, t.Surplus);
|
||||
turfing.Add(newTurf);
|
||||
}
|
||||
_loadedTurfs = turfing.ToArray();
|
||||
@@ -40,13 +39,12 @@ namespace ReallifeGamemode.Server.Gangwar
|
||||
public static void loadTurfs_ToAllPlayers()
|
||||
{
|
||||
NAPI.ClientEvent.TriggerClientEventForAll("GangAreas:Create", JsonConvert.SerializeObject(turfs.ToArray()));
|
||||
foreach(var l in NAPI.Pools.GetAllPlayers())
|
||||
foreach (var l in NAPI.Pools.GetAllPlayers())
|
||||
{
|
||||
if (!l.IsLoggedIn() && !l.GetUser().FactionLeader)
|
||||
return;
|
||||
|
||||
l.TriggerEvent("CLIENT:Turf_LoadLeaderBlip");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +97,7 @@ namespace ReallifeGamemode.Server.Gangwar
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[RemoteEvent("SERVER:SetTurf")]
|
||||
public void RmtEvent_SetTurf(Player client, string jsonX, string jsonY, string jsonRot, string jsonRange, string Name)
|
||||
{
|
||||
@@ -117,7 +115,7 @@ namespace ReallifeGamemode.Server.Gangwar
|
||||
Range = Range,
|
||||
Owner = "Neutral",
|
||||
Color = 0,
|
||||
Vector = null
|
||||
Vector = null
|
||||
};
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
@@ -151,7 +149,8 @@ namespace ReallifeGamemode.Server.Gangwar
|
||||
}
|
||||
|
||||
[RemoteEvent("SERVER:Turf_SetNewLeaderPoint")]
|
||||
public void RmtEvent_SetNewLeaderPoint(Player client, string vector, string jsonId) {
|
||||
public void RmtEvent_SetNewLeaderPoint(Player client, string vector, string jsonId)
|
||||
{
|
||||
int id = JsonConvert.DeserializeObject<int>(jsonId);
|
||||
if (id == -1)
|
||||
{
|
||||
@@ -171,7 +170,6 @@ namespace ReallifeGamemode.Server.Gangwar
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[RemoteEvent("SERVER:StartGangwar")]
|
||||
public void RmtEvent_StartGangwar(Player client)
|
||||
{
|
||||
@@ -182,7 +180,7 @@ namespace ReallifeGamemode.Server.Gangwar
|
||||
{
|
||||
if (turf.status == "attack")
|
||||
{
|
||||
ChatService.ErrorMessage(client,"Du kannst momentan kein Gangwar starten");
|
||||
ChatService.ErrorMessage(client, "Du kannst momentan kein Gangwar starten");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -200,8 +198,30 @@ namespace ReallifeGamemode.Server.Gangwar
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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.ClientEvent.TriggerClientEventForAll("CLIENT:UpdateTurfValue", JsonConvert.SerializeObject(values.ToArray()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,18 +24,24 @@ namespace ReallifeGamemode.Server.Gangwar
|
||||
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)
|
||||
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 = 50;
|
||||
this.Def_Score = 50;
|
||||
@@ -50,6 +56,36 @@ namespace ReallifeGamemode.Server.Gangwar
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user