Exemplo n.º 1
0
        public static async Task <Vector3> PositionOnGround(Vector3 inP)
        {
            int     startTime      = GetGameTimer();
            Vector3 groundPosition = Vector3.Zero;
            bool    searching      = true;

            while (searching)
            {
                RequestCollisionAtCoord(inP.X, inP.Y, 0.0f);

                float groundZ        = 0.0f;
                bool  hasFoundGround = GetGroundZFor_3dCoord(inP.X, inP.Y, 1000.0f, ref groundZ, false);

                if (!hasFoundGround)
                {
                    if ((GetGameTimer() - startTime) > 5000)
                    {
                        ChatHelper.Print(nameof(GroundHelper), $"Failed to find ground for position X: {inP.X}, Y: {inP.Y}, Z: {inP.Z}");
                        searching = false;
                    }
                }
                else
                {
                    groundPosition = new Vector3(inP.X, inP.Y, groundZ);
                    searching      = false;
                }

                await BaseScript.Delay(20);
            }

            return(groundPosition);
        }
Exemplo n.º 2
0
        public void CommandSaveRace()
        {
            if (CurrentRace == null)
            {
                ChatHelper.Print(nameof(RaceClient), "Cannot save track if race hasn't been created.", 255, 0, 0);
                return;
            }

            CurrentRace.Save();
        }
Exemplo n.º 3
0
        public void CommandAddCheckpoint()
        {
            if (CurrentRace == null)
            {
                ChatHelper.Print(nameof(RaceClient), "Cannot add checkpoint if race doesn't exist.", 255, 0, 0);
                return;
            }

            Player  localPlayer = LocalPlayer;
            Vector3 position    = localPlayer.Character.Position;

            CurrentRace.AddPoint(new RaceCheckpoint(position));
        }
Exemplo n.º 4
0
        public void CommandCreateRace(int source, List <object> args, string raw)
        {
            if (CurrentRace != null)
            {
                ChatHelper.Print(nameof(RaceClient), "Race is already created!", 255, 0, 0);
                return;
            }

            if (args.Count < 1)
            {
                ChatHelper.Print(nameof(RaceClient), "Please specify a track name.", 255, 0, 0);
                return;
            }

            string raceName = (string)args[0];

            CurrentRace = new Race(raceName, true);
            ChatHelper.Print(nameof(RaceClient), "A new race has been created!", 0, 255, 0);
        }