using System; using System.Collections.Generic; using System.Text; using ReallifeGamemode.Server.Entities; using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Server.Finance; using ReallifeGamemode.Server.Models; using ReallifeGamemode.Server.Services; using ReallifeGamemode.Server.Util; using GTANetworkAPI; using System.Collections; using System.Linq; namespace ReallifeGamemode.Server.Util { public class CheckPointHandle : Script { public static List listHandle = new List(); public static void StartCheckPointRoute(Client player, IEnumerable nListCps) { CheckPointListForPlayer playerHandle = new CheckPointListForPlayer(player, nListCps); listHandle.Add(playerHandle); playerHandle.StartRoute(); } public static void RemovePlayerHandlerFromList(Client player) { CheckPointListForPlayer temp = null; for (int a = 0; a < listHandle.Count; a++) { temp = listHandle[a]; if (temp.player == player) { listHandle.Remove(temp); } } } [RemoteEvent("playerInCheckpoint")] public void PlayerInCheckpoint(Client user) { CheckPointListForPlayer temp = null; for (int a = 0; a < listHandle.Count; a++) { temp = listHandle[a]; if (temp.player == user) { break; } } temp.NextCheckpoint(); ChatService.Broadcast("neuer cp"); } } public class CheckPointListForPlayer { public IEnumerable list = new List(); public Client player; Vector3 checkPoint; bool done; int checkPointsDone = 0; public CheckPointListForPlayer(Client nPlayer, IEnumerable nList) { this.player = nPlayer; this.list = nList; } public void StartRoute() { player.TriggerEvent("setCheckPoint", this.list.ElementAt(0), player); } public void NextCheckpoint() { this.checkPointsDone++; if (this.list.Count() > checkPointsDone) { Vector3 nextCp = list.ElementAt(checkPointsDone); ChatService.SendMessage(this.player, "cp set at " + nextCp.ToString()); this.player.TriggerEvent("setCheckPoint", nextCp, player); } if (this.list.Count() == checkPointsDone) { ChatService.SendMessage(this.player, "Du hast alle Checkpoints abgefahren!"); CheckPointHandle.RemovePlayerHandlerFromList(this.player); } } } }