renewed and improved busdriver job system, paaqo is not amused

This commit is contained in:
2019-09-12 18:20:18 +02:00
parent 146261bc03
commit 5ea2487b29
4 changed files with 74 additions and 14 deletions

View File

@@ -8,28 +8,68 @@ using ReallifeGamemode.Server.Models;
using ReallifeGamemode.Server.Services;
using ReallifeGamemode.Server.Util;
using GTANetworkAPI;
using System.Collections;
using System.Linq;
namespace ReallifeGamemode.Server.Util
{
class CheckPointHandle : Script
public class CheckPointHandle : Script
{
[Command("cp", "~m~Benutzung: ~s~/cp")]
public void CmdCp(Client player)
public static List<checkPointListForPlayer> listHandle = new List<checkPointListForPlayer>();
public static void startCheckPointRoute(Client player, List<Vector3> nListCps)
{
if (!player.IsLoggedIn()) return;
checkPointListForPlayer playerHandle = new checkPointListForPlayer(player, nListCps);
listHandle.Add(playerHandle);
Vector3 cp = player.Position;
cp.X += 10;
player.TriggerEvent("setCheckPoint", cp, player);
playerHandle.startRoute();
}
[RemoteEvent("playerInCheckpoint")]
public void enteredCheckpoints(Client user)
public void playerInCheckpoint(Client user)
{
ChatService.SendMessage(user, "ja");
Vector3 newCp = new Vector3(400, 680, 29);
user.TriggerEvent("setCheckpoint", newCp, user);
ChatService.Broadcast("neuer cp");
checkPointListForPlayer temp = null;
for (int a = 0; a < listHandle.Count; a++)
{
temp = listHandle[a];
if (temp.player == user)
{
break;
}
}
temp.nextCheckpoint();
}
}
public class checkPointListForPlayer
{
public List<Vector3> list = new List<Vector3>();
public Client player;
Vector3 checkPoint;
Boolean done;
int checkPointsDone = 0;
public checkPointListForPlayer(Client nPlayer, List<Vector3> 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);
}
}
}
}