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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user