Пример #1
0
        public void MyVehiclesAbandonCar(Player sender, params object[] arguments)
        {
            Character   character = sender.GetCharacter();
            GameVehicle acVeh     =
                VehicleManager.Vehicles.Single(
                    x => x.Id == Convert.ToInt32(arguments[0]) && x.OwnerId == character.Id);

            VehicleManager.despawn_vehicle(acVeh);
            VehicleManager.delete_vehicle(acVeh);
            acVeh.Delete();
            NAPI.Chat.SendChatMessageToPlayer(sender,
                                              $"You have sucessfully abandoned your ~r~{returnCorrDisplayName(acVeh.VehModel)}~w~");
        }
Пример #2
0
        private void API_onClientEventTrigger(Client sender, string eventName, params object[] arguments)
        {
            Character character = sender.GetCharacter();

            switch (eventName)
            {
            case "myvehicles_locatecar":
                vehicle_manager.Vehicle lcVeh =
                    VehicleManager.Vehicles.Single(
                        x => x.NetHandle.Value == Convert.ToInt32(arguments[0]) && x.OwnerId == character.Id);
                Vector3 loc = API.GetEntityPosition(lcVeh.NetHandle);
                API.TriggerClientEvent(sender, "myvehicles_setCheckpointToCar", loc.X, loc.Y, loc.Z);
                API.SendChatMessageToPlayer(sender, "A checkpoint has been set to the vehicle.");
                break;

            case "myvehicles_abandoncar":
                vehicle_manager.Vehicle acVeh =
                    VehicleManager.Vehicles.Single(
                        x => x.Id == Convert.ToInt32(arguments[0]) && x.OwnerId == character.Id);
                VehicleManager.despawn_vehicle(acVeh);
                VehicleManager.delete_vehicle(acVeh);
                acVeh.Delete();
                API.SendChatMessageToPlayer(sender,
                                            $"You have sucessfully abandoned your ~r~{VehicleOwnership.returnCorrDisplayName(acVeh.VehModel)}~w~");
                break;

            case "myvehicles_sellcar":
                vehicle_manager.Vehicle scVeh =
                    VehicleManager.Vehicles.Single(
                        x => x.Id == Convert.ToInt32(arguments[0]) && x.OwnerId == character.Id);
                var tid    = (string)arguments[1];
                var target = PlayerManager.ParseClient(tid);
                if (target == null)
                {
                    API.SendChatMessageToPlayer(sender, "That player isn't online or doesn't exist.");
                    return;
                }
                var targetChar    = target.GetCharacter();
                var targetAccount = target.GetAccount();

                var price = 0;
                if (!int.TryParse((string)arguments[2], out price))
                {
                    API.SendChatMessageToPlayer(sender, "Invalid price entered.");
                    return;
                }
                if (price < 0)
                {
                    API.SendChatMessageToPlayer(sender, "Price cannot be negative.");
                    return;
                }

                if (targetChar.OwnedVehicles.Count >= VehicleManager.GetMaxOwnedVehicles(targetChar.Client))
                {
                    API.SendChatMessageToPlayer(sender, "This player cannot own any more vehicles.");
                    return;
                }

                API.SendChatMessageToPlayer(sender,
                                            $"Are you sure you would like to sell the ~r~{VehicleOwnership.returnCorrDisplayName(scVeh.VehModel)}~w~ for ~r~${price}~w~ to the player ~r~{targetChar.rp_name()}~w~?");
                API.SendChatMessageToPlayer(sender, "Use /confirmsellvehicle to sell.");
                API.SetEntityData(sender, "sellcar_selling", new dynamic[] { scVeh, targetChar, price });
                break;

            case "groupvehicles_locatecar":
                vehicle_manager.Vehicle gVeh =
                    VehicleManager.Vehicles.Single(
                        x => x.NetHandle.Value == Convert.ToInt32(arguments[0]) && x.GroupId == character.GroupId);
                Vector3 location = API.GetEntityPosition(gVeh.NetHandle);
                API.TriggerClientEvent(sender, "myvehicles_setCheckpointToCar", location.X, location.Y, location.Z);
                API.SendChatMessageToPlayer(sender, "A checkpoint has been set to the vehicle.");
                break;
            }
        }