示例#1
0
 public void onPlayerRespawn(Client player)
 {
     if (IsRaceStarting)
     {
         SetUpPlayerForRace(player, CurrentRace, false, 0);
     }
     else if (IsRaceOngoing)
     {
         API.setPlayerToSpectator(player);
         Opponent curOp = Opponents.FirstOrDefault(op => op.Client == player);
         if (curOp == null)
         {
             return;
         }
         curOp.IsAlive = false;
     }
 }
示例#2
0
        private void SetUpPlayerForRace(Client client, Race race, bool freeze, int spawnpoint)
        {
            if (race == null)
            {
                return;
            }

            var selectedModel = unchecked ((int)(race.AvailableVehicles[randGen.Next(race.AvailableVehicles.Length)]));
            var position      = race.SpawnPoints[spawnpoint % race.SpawnPoints.Length].Position;
            var heading       = race.SpawnPoints[spawnpoint % race.SpawnPoints.Length].Heading;

            API.setEntityPosition(client.handle, position);

            var playerVehicle = API.createVehicle((VehicleHash)selectedModel, position, new Vector3(0, 0, heading), 0, 0);

            Thread.Sleep(500);
            API.setPlayerIntoVehicle(client, playerVehicle, -1);

            if (freeze)
            {
                API.setEntityPositionFrozen(client, playerVehicle, true);
            }

            Opponent inOp = Opponents.FirstOrDefault(op => op.Client == client);

            lock (Opponents)
            {
                if (inOp != null)
                {
                    inOp.Vehicle = playerVehicle;
                    inOp.IsAlive = true;
                }
                else
                {
                    Opponents.Add(new Opponent(client)
                    {
                        Vehicle = playerVehicle, IsAlive = true
                    });
                }
            }
        }