示例#1
0
        public static async Task SpawnVehicleCompanies(Data.Entities.Company company)
        {
            using (MySqlConnection connection = new MySqlConnection(Data.DatabaseHandler.connectionHandle))
            {
                await connection.OpenAsync().ConfigureAwait(false);

                MySqlCommand command = connection.CreateCommand();
                command.CommandText = "SELECT * FROM vehicles_companies WHERE company = @company";
                command.Parameters.AddWithValue("@company", company.id);

                DbDataReader reader = await command.ExecuteReaderAsync().ConfigureAwait(false);

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        int    id          = reader.GetInt32(reader.GetOrdinal("id"));
                        string type        = reader.GetString(reader.GetOrdinal("type"));
                        int    color1      = reader.GetInt32(reader.GetOrdinal("color1"));
                        int    color2      = reader.GetInt32(reader.GetOrdinal("color2"));
                        string numberplate = reader.GetString(reader.GetOrdinal("numberplate"));

                        double x   = reader.GetDouble(reader.GetOrdinal("x"));
                        double y   = reader.GetDouble(reader.GetOrdinal("y"));
                        double z   = reader.GetDouble(reader.GetOrdinal("z"));
                        double rot = reader.GetDouble(reader.GetOrdinal("rot"));

                        Vector3 position = new Vector3(x, y, z);

                        NAPI.Task.Run(() =>
                        {
                            uint hash           = NAPI.Util.GetHashKey(type);
                            Vehicle vehicle     = NAPI.Vehicle.CreateVehicle(hash, position, (float)rot, color1, color2, numberplate, 255, false, false);
                            vehicle.NumberPlate = numberplate;

                            Data.Entities.VehicleCompany veh = new Data.Entities.VehicleCompany()
                            {
                                id       = id,
                                model    = type,
                                vehicle  = vehicle,
                                company  = company,
                                spawn    = position,
                                spawnRot = (float)rot
                            };

                            vehicle.SetData("VEHICLE_COMPANY_DATA", veh);
                        });
                    }
                }
            }
        }
示例#2
0
        public async Task CMD_estacionarveh(Client player)
        {
            if (!player.HasData("USER_CLASS"))
            {
                return;
            }
            Data.Entities.User user = player.GetData("USER_CLASS");

            if (player.IsInVehicle)
            {
                if (user.companyProperty != null)
                {
                    Vehicle vehicle = player.Vehicle;

                    if (vehicle.HasData("VEHICLE_COMPANY_DATA"))
                    {
                        Data.Entities.VehicleCompany veh = vehicle.GetData("VEHICLE_COMPANY_DATA");
                        if (veh.company == user.companyProperty)
                        {
                            veh.spawn    = player.Position;
                            veh.spawnRot = player.Heading;

                            await World.Companies.DbFunctions.UpdateCompanyVehicleSpawn(veh.id, player.Position.X, player.Position.Y, player.Position.Z, player.Heading);

                            Utilities.Notifications.SendNotificationOK(player, "Has actualizado las coordenadas de spawn de tu vehículo");
                        }
                        else
                        {
                            Utilities.Notifications.SendNotificationERROR(player, "No estás en un vehículo de tu empresa");
                        }
                    }
                    else
                    {
                        Utilities.Notifications.SendNotificationERROR(player, "No estás en un vehículo de empresa");
                    }
                }
                else
                {
                    Utilities.Notifications.SendNotificationERROR(player, "No eres dueño de una empresa");
                }
            }
            else
            {
                Utilities.Notifications.SendNotificationERROR(player, "No estás en un vehículo");
            }
        }
示例#3
0
        public async Task RE_BuyCarCompany(Player player, string color1, string color2)
        {
            if (!player.HasData("USER_CLASS"))
            {
                return;
            }
            Data.Entities.User user = player.GetData <Data.Entities.User>("USER_CLASS");

            Vehicle vehicle;

            if (player.IsInVehicle)
            {
                vehicle = player.Vehicle;
            }
            else
            {
                return;
            }

            if (vehicle.HasData("VEHICLE_BUSINESS_DATA"))
            {
                Data.Entities.VehicleBusiness veh = vehicle.GetData <Data.Entities.VehicleBusiness>("VEHICLE_BUSINESS_DATA");

                if (veh.isCompanySelling)
                {
                    if (user.companyProperty != null)
                    {
                        if (await Game.Money.MoneyModel.SubMoney(player, (double)veh.price))
                        {
                            player.WarpOutOfVehicle();
                            await Task.Delay(1000);

                            NAPI.Task.Run(async() =>
                            {
                                Vehicle new_veh = NAPI.Vehicle.CreateVehicle(NAPI.Util.GetHashKey(veh.model), veh.business.spawn, veh.business.spawnRot, 1, 1);
                                player.SetIntoVehicle(new_veh, -1);

                                player.TriggerEvent("DestroyCarshopBrowser");

                                switch (color1)
                                {
                                case "black":
                                    new_veh.PrimaryColor = 0;
                                    break;

                                case "white":
                                    new_veh.PrimaryColor = 5;
                                    break;

                                case "yellow":
                                    new_veh.PrimaryColor = 42;
                                    break;

                                case "red":
                                    new_veh.PrimaryColor = 27;
                                    break;

                                case "blue":
                                    new_veh.PrimaryColor = 80;
                                    break;

                                case "green":
                                    new_veh.PrimaryColor = 55;
                                    break;
                                }

                                switch (color2)
                                {
                                case "black":
                                    new_veh.SecondaryColor = 0;
                                    break;

                                case "white":
                                    new_veh.SecondaryColor = 5;
                                    break;

                                case "yellow":
                                    new_veh.SecondaryColor = 42;
                                    break;

                                case "red":
                                    new_veh.SecondaryColor = 27;
                                    break;

                                case "blue":
                                    new_veh.SecondaryColor = 80;
                                    break;

                                case "green":
                                    new_veh.SecondaryColor = 55;
                                    break;
                                }

                                player.TriggerEvent("chat_goal", "¡Felicidades!", "Has comprado un nuevo vehículo para tu empresa");

                                new_veh.NumberPlate = "EMPRESA";
                                int vehid           = await Companies.DbFunctions.CreateCompanyVehicle(user.companyProperty.id, veh.model, new_veh.PrimaryColor, new_veh.SecondaryColor, "EMPRESA", veh.business.spawn.X, veh.business.spawn.Y, veh.business.spawn.Z, veh.business.spawnRot);

                                Data.Entities.VehicleCompany veh_company = new Data.Entities.VehicleCompany()
                                {
                                    id      = vehid,
                                    vehicle = new_veh,
                                    company = user.companyProperty,
                                    model   = veh.model
                                };

                                new_veh.SetData("VEHICLE_COMPANY_DATA", veh_company);
                                await Task.Delay(2000);
                                Utilities.Notifications.SendNotificationINFO(player, "Para estacionar el vehículo en el lugar deseado usa /estacionarveh");
                            });
                        }
                        else
                        {
                            Utilities.Notifications.SendNotificationERROR(player, "No tienes suficiente dinero");
                        }
                    }
                }
            }
        }