Exemplo n.º 1
0
        public void CreateVehicle(Client player, int characterId, int groupId, VehicleHash hash, int color1, int color2)
        {
            if (!AdminController.AdminRankCheck(player, "createvehicle"))
            {
                return;
            }

            var vehicleData = new Data.Vehicle
            {
                CharacterId = characterId == 0 ? (int?)null : characterId,
                GroupId     = groupId == 0 ? (int?)null : groupId,
                Model       = hash.GetHashCode(),
                PosX        = player.position.X,
                PosY        = player.position.Y,
                PosZ        = player.position.Z,
                Rot         = player.rotation.Z,
                Color1      = color1,
                Color2      = color2,
                Fuel        = 50,
                FuelTank    = 50,
                RentTime    = 999,
                Respawnable = true
            };

            var vehicleController = new VehicleController(vehicleData, API.createVehicle(hash, player.position, player.rotation, color1, color2, 0));

            ContextFactory.Instance.Vehicle.Add(vehicleData);
            ContextFactory.Instance.SaveChanges();
        }
Exemplo n.º 2
0
        public void RemoveOldVehicles()
        {
            try
            {
                int vehicleHashCode = VehicleHash.GetHashCode();

                foreach (Vehicle vehicle in World.GetAllVehicles())
                {
                    if (vehicle.GetHashCode() == vehicleHashCode && vehicle.Exists())
                    {
                        try { vehicle.Delete(); } catch { }
                    }
                }
            }
            catch { }
        }
Exemplo n.º 3
0
        public void createvehicle(Client player, string OwnerType, string Name, VehicleHash hash, int color1, int color2)
        {
            AccountController account = player.getData("ACCOUNT");

            if (account == null)
            {
                return;
            }
            if (!AdminController.AdminRankCheck("createvehicle", account))
            {
                return;
            }

            Data.Vehicle VehicleData = new Data.Vehicle();
            if (OwnerType == "player")
            {
                AccountController TargetAccountController = AccountController.GetAccountControllerFromName(Name);
                if (TargetAccountController == null)
                {
                    return;
                }
                VehicleData.Character = TargetAccountController.CharacterController.Character;
            }
            else if (OwnerType == "group")
            {
                Groups.GroupController GroupController = EntityManager.GetGroup(player, Name);
                VehicleData.Group = GroupController.Group;
            }
            else
            {
                API.sendChatMessageToPlayer(player, "~r~ERROR: ~w~You specified an invalid owner type (player/group");
                return;
            }

            Vehicles.VehicleController VehicleController = new Vehicles.VehicleController(VehicleData, API.createVehicle(hash, player.position, player.rotation, color1, color2, 0));

            VehicleData.Model  = hash.GetHashCode();
            VehicleData.PosX   = player.position.X;
            VehicleData.PosY   = player.position.Y;
            VehicleData.PosZ   = player.position.Z;
            VehicleData.Rot    = player.rotation.Z;
            VehicleData.Color1 = color1;
            VehicleData.Color2 = color2;

            ContextFactory.Instance.Vehicle.Add(VehicleData);
            ContextFactory.Instance.SaveChanges();
        }