Beispiel #1
0
        /// <summary>
        ///     Gets the value for the occurance of this parameter type at the start of the commandText. The processed text will be
        ///     removed from the commandText.
        /// </summary>
        /// <param name="commandText">The command text.</param>
        /// <param name="output">The output.</param>
        /// <returns>
        ///     true if parsed successfully; false otherwise.
        /// </returns>
        public bool Parse(ref string commandText, out object output)
        {
            var text = commandText.TrimStart();

            output = null;

            if (string.IsNullOrEmpty(text))
            {
                return(false);
            }

            var word = text.Split(' ').First();

            // find a vehicle with a matching id.
            int id;

            if (int.TryParse(word, NumberStyles.Integer, CultureInfo.InvariantCulture, out id))
            {
                var vehicle = BaseVehicle.Find(id);
                if (vehicle != null)
                {
                    output      = vehicle;
                    commandText = commandText.Substring(word.Length).TrimStart(' ');
                    return(true);
                }
            }
            return(false);
        }
Beispiel #2
0
        public static BaseVehicle GetPlayerLastSyncedVehicleID(BasePlayer player)
        {
            if (player == null)
            {
                throw new ArgumentNullException(nameof(player));
            }

            return(BaseVehicle.Find(Internal.GetPlayerLastSyncedVehicleID(player.Id)));
        }
Beispiel #3
0
        internal static void OnVehicleEntryComplete(int npcid, int vehicleid, int seatid)
        {
            var fcnpc = Find(npcid);
            var args  = new VehicleEntryEventArgs()
            {
                Vehicle = BaseVehicle.Find(vehicleid),
                Seat    = seatid
            };

            fcnpc?.VehicleEntryCompleted?.Invoke(fcnpc, args);
        }
Beispiel #4
0
        public static void SetStatusCommand(BasePlayer player, int vehicleid)
        {
            var vehicle = BaseVehicle.Find(vehicleid);

            vehicle.SetDoorsParameters(true, true, true, true);

            vehicle.GetDamageStatus(out var panels, out var doors, out var lights, out var tires);
            Console.WriteLine(panels.ToString());
            Console.WriteLine(doors.ToString());
            Console.WriteLine(lights.ToString());
            Console.WriteLine(tires.ToString());
        }
Beispiel #5
0
        internal static void OnVehicleTakeDamage(int npcid, int damagerid, int vehicleid, int weaponid, float x, float y, float z)
        {
            var fcnpc = Find(npcid);
            var args  = new VehicleTakeDamageEventArgs()
            {
                Damager  = BasePlayer.Find(damagerid),
                Vehicle  = BaseVehicle.Find(vehicleid),
                Weapon   = (Weapon)weaponid,
                Position = new Vector3(x, y, z)
            };

            fcnpc?.VehicleTakeDamage?.Invoke(fcnpc, args);
        }
Beispiel #6
0
        internal bool OnVehicleDeath(int vehicleid, int killerid)
        {
            var vehicle = BaseVehicle.Find(vehicleid);

            if (vehicle == null)
            {
                return(true);
            }

            OnVehicleDied(vehicle, new PlayerEventArgs(killerid == BasePlayer.InvalidId ? null : BasePlayer.FindOrCreate(killerid)));

            return(true);
        }
Beispiel #7
0
        internal bool OnVehicleSirenStateChange(int playerid, int vehicleid, bool newstate)
        {
            var vehicle = BaseVehicle.Find(vehicleid);

            if (vehicle == null)
            {
                return(true);
            }

            OnVehicleSirenStateChange(vehicle, new SirenStateEventArgs(BasePlayer.FindOrCreate(playerid), newstate));

            return(true);
        }
Beispiel #8
0
        internal bool OnVehicleSpawn(int vehicleid)
        {
            var vehicle = BaseVehicle.Find(vehicleid);

            if (vehicle == null)
            {
                return(true);
            }

            OnVehicleSpawned(vehicle, EventArgs.Empty);

            return(true);
        }
Beispiel #9
0
        internal bool OnVehicleStreamOut(int vehicleid, int forplayerid)
        {
            var vehicle = BaseVehicle.Find(vehicleid);

            if (vehicle == null)
            {
                return(true);
            }

            OnVehicleStreamOut(vehicle, new PlayerEventArgs(BasePlayer.FindOrCreate(forplayerid)));

            return(true);
        }
Beispiel #10
0
        internal bool OnVehicleDamageStatusUpdate(int vehicleid, int playerid)
        {
            var vehicle = BaseVehicle.Find(vehicleid);

            if (vehicle == null)
            {
                return(true);
            }

            OnVehicleDamageStatusUpdated(vehicle, new PlayerEventArgs(BasePlayer.FindOrCreate(playerid)));

            return(true);
        }
Beispiel #11
0
        internal bool OnVehicleRespray(int playerid, int vehicleid, int color1, int color2)
        {
            var vehicle = BaseVehicle.Find(vehicleid);

            if (vehicle == null)
            {
                return(true);
            }

            OnVehicleResprayed(vehicle, new VehicleResprayedEventArgs(BasePlayer.FindOrCreate(playerid), color1, color2));

            return(true);
        }
Beispiel #12
0
        public static void StatusCommand(BasePlayer player, int vehicleid)
        {
            var vehicle = BaseVehicle.Find(vehicleid);
            int panels  = 99;
            int doors   = 100;
            int lights  = 101;
            int tires   = 102;

            vehicle.GetDamageStatus(out panels, out doors, out lights, out tires);
            Console.WriteLine(panels.ToString());
            Console.WriteLine(doors.ToString());
            Console.WriteLine(lights.ToString());
            Console.WriteLine(tires.ToString());
        }
Beispiel #13
0
        internal bool OnVehiclePaintjob(int playerid, int vehicleid, int paintjobid)
        {
            var vehicle = BaseVehicle.Find(vehicleid);

            if (vehicle == null)
            {
                return(true);
            }

            OnVehiclePaintjobApplied(vehicle,
                                     new VehiclePaintjobEventArgs(BasePlayer.FindOrCreate(playerid), paintjobid));


            return(true);
        }
Beispiel #14
0
        internal bool OnTrailerUpdate(int playerId, int vehicleid)
        {
            var vehicle = BaseVehicle.Find(vehicleid);

            if (vehicle == null)
            {
                return(true);
            }

            var args = new TrailerEventArgs(BasePlayer.FindOrCreate(playerId));

            OnTrailerUpdate(vehicle, args);

            return(!args.PreventPropagation);
        }
Beispiel #15
0
        internal bool OnVehicleMod(int playerid, int vehicleid, int componentid)
        {
            var vehicle = BaseVehicle.Find(vehicleid);

            if (vehicle == null)
            {
                return(true);
            }

            var args = new VehicleModEventArgs(BasePlayer.FindOrCreate(playerid), componentid);

            OnVehicleMod(vehicle, args);

            return(!args.PreventPropagation);
        }
Beispiel #16
0
        internal bool OnPlayerExitVehicle(int playerid, int vehicleid)
        {
            var vehicle = BaseVehicle.Find(vehicleid);

            if (vehicle == null)
            {
                return(true);
            }

            var player = BasePlayer.FindOrCreate(playerid);

            OnPlayerExitVehicle(player, new PlayerVehicleEventArgs(player, vehicle));

            return(true);
        }
Beispiel #17
0
        internal bool OnUnoccupiedVehicleUpdate(int vehicleid, int playerid, int passengerSeat, float newX,
                                                float newY, float newZ, float velX, float velY, float velZ)
        {
            var vehicle = BaseVehicle.Find(vehicleid);

            if (vehicle == null)
            {
                return(true);
            }

            var args = new UnoccupiedVehicleEventArgs(BasePlayer.FindOrCreate(playerid), passengerSeat,
                                                      new Vector3(newX, newY, newZ), new Vector3(velX, velY, velZ));

            OnUnoccupiedVehicleUpdated(vehicle, args);

            return(!args.PreventPropagation);
        }
Beispiel #18
0
 public static void EnterCommand(BasePlayer player, int vehicle)
 {
     player.PutInVehicle(BaseVehicle.Find(vehicle));
 }