76 lines
2.0 KiB
C#
76 lines
2.0 KiB
C#
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<checkPointListForPlayer> listHandle = new List<checkPointListForPlayer>();
|
|
public static void startCheckPointRoute(Client player, List<Vector3> nListCps)
|
|
{
|
|
checkPointListForPlayer playerHandle = new checkPointListForPlayer(player, nListCps);
|
|
listHandle.Add(playerHandle);
|
|
|
|
playerHandle.startRoute();
|
|
}
|
|
|
|
[RemoteEvent("playerInCheckpoint")]
|
|
public void playerInCheckpoint(Client 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);
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|