[+] Add Gangwar System (bugs incl.)

This commit is contained in:
Lukas Moungos
2020-01-13 21:43:55 +01:00
parent 3b0189807e
commit e8321e3ec3
10 changed files with 246 additions and 85 deletions

View File

@@ -40,6 +40,14 @@ namespace ReallifeGamemode.Server.Gangwar
public static void loadTurfs_ToAllClients()
{
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(Client killer, Client victim)
@@ -108,7 +116,8 @@ namespace ReallifeGamemode.Server.Gangwar
Rotation = Rot,
Range = Range,
Owner = "Neutral",
Color = 0
Color = 0,
Vector = null
};
using (var dbContext = new DatabaseContext())
{
@@ -141,8 +150,30 @@ namespace ReallifeGamemode.Server.Gangwar
}
}
[Command("/gwstart")]
public void StartGangwar(Client client)
[RemoteEvent("SERVER:Turf_SetNewLeaderPoint")]
public void RmtEvent_SetNewLeaderPoint(Client 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_ToAllClients();
}
}
}
[RemoteEvent("SERVER:StartGangwar")]
public void RmtEvent_StartGangwar(Client client)
{
if (!client.GetUser().FactionLeader)
return;
@@ -151,7 +182,7 @@ namespace ReallifeGamemode.Server.Gangwar
{
if (turf.status == "attack")
{
client.SendChatMessage("Ein GW läuft grad bruder"); // DEBUG
client.SendChatMessage("Ein GW läuft grad bruder"); // DEBUG //change to smth more serious
return;
}
}