コード例 #1
0
        public void OnPlayerEnterVehicle(Player player, Vehicle vehicle, sbyte seatID)
        {
            if (!player.HasData("USER_CLASS"))
            {
                return;
            }
            Data.Entities.User user = player.GetData <Data.Entities.User>("USER_CLASS");

            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 (veh.business.spawn != null)
                        {
                            player.TriggerEvent("OpenCarshopBrowser", veh.business.name, veh.model, veh.price);
                        }
                        else
                        {
                            Utilities.Notifications.SendNotificationERROR(player, "Esta empresa no tiene punto de spawn para vehículos. Contacta con un administrador.");
                        }
                    }
                    else
                    {
                        Utilities.Notifications.SendNotificationERROR(player, "No eres dueño de ninguna empresa");
                    }
                }
            }
        }
コード例 #2
0
        public async Task CMD_borrarnegocioveh(Player player)
        {
            if (!player.HasData("USER_CLASS"))
            {
                return;
            }
            Data.Entities.User user = player.GetData <Data.Entities.User>("USER_CLASS");
            if (user.adminLv == 5)
            {
                if (player.IsInVehicle)
                {
                    if (player.Vehicle.HasData("VEHICLE_BUSINESS_DATA"))
                    {
                        Data.Entities.VehicleBusiness veh = player.Vehicle.GetData <Data.Entities.VehicleBusiness>("VEHICLE_BUSINESS_DATA");
                        await World.Business.DbFunctions.DeleteBusinessVehicle(veh.id);

                        player.Vehicle.Delete();

                        Utilities.Notifications.SendNotificationOK(player, "Has borrado el vehículo del negocio correctamente");
                    }
                }
            }
        }
コード例 #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");
                        }
                    }
                }
            }
        }
コード例 #4
0
        public async Task CMD_crearnegocioveh(Player player, string model, int price, int color1, int color2, string numberplate)
        {
            if (!player.HasData("USER_CLASS"))
            {
                return;
            }
            Data.Entities.User user = player.GetData <Data.Entities.User>("USER_CLASS");
            if (user.adminLv == 5)
            {
                if (!player.HasData("CREATE_VEHICLE_BUSINESS"))
                {
                    Utilities.Notifications.SendNotificationERROR(player, "Debes usar primero /crearvehiculosnegocio en la entrada de un negocio");
                    return;
                }

                Data.Entities.Business business = player.GetData <Data.Entities.Business>("CREATE_VEHICLE_BUSINESS");

                uint      hash  = NAPI.Util.GetHashKey(model);
                Vehicle   veh   = NAPI.Vehicle.CreateVehicle(hash, player.Position.Subtract(new Vector3(0, 0, 1)), player.Heading, color1, color2, numberplate, 255, false, false);
                TextLabel label = NAPI.TextLabel.CreateTextLabel($"~y~{model}~n~~w~Precio: ~g~${price}", player.Position.Subtract(new Vector3(0, 0, 1)), 3, 1, 0, new Color(255, 255, 255));
                veh.NumberPlate = numberplate;

                int vehicle_id = await World.Business.DbFunctions.CreateBusinessVehicle(business.id, model, price, color1, color2, numberplate, player.Position.X, player.Position.Y, player.Position.Z, (double)player.Heading);

                bool isCompanySelling = false;
                bool isRentSelling    = false;
                bool isNormalSelling  = false;

                switch (business.type)
                {
                case 6:
                    isRentSelling = true;
                    break;

                case 7:
                    isNormalSelling = true;
                    break;

                case 8:
                    isCompanySelling = true;
                    break;
                }

                Data.Entities.VehicleBusiness vehicle = new Data.Entities.VehicleBusiness()
                {
                    id               = vehicle_id,
                    model            = model,
                    vehicle          = veh,
                    business         = business,
                    price            = price,
                    isCompanySelling = isCompanySelling,
                    isRentSelling    = isRentSelling,
                    isNormalSelling  = isNormalSelling,
                    label            = label
                };

                veh.SetData("VEHICLE_BUSINESS_DATA", vehicle);

                veh.SetSharedData("BUSINESS_VEHICLE_SHARED", veh);
                veh.SetSharedData("IS_BUSINESS_VEHICLE", true);
            }
            else
            {
                player.SendChatMessage("<font color='red'>[ERROR]</font> El comando no existe. (/ayuda para mas información)");
            }
        }
コード例 #5
0
        public static async Task SpawnVehicleBusiness(Data.Entities.Business business)
        {
            using (MySqlConnection connection = new MySqlConnection(Data.DatabaseHandler.connectionHandle))
            {
                await connection.OpenAsync().ConfigureAwait(false);

                MySqlCommand command = connection.CreateCommand();
                command.CommandText = "SELECT * FROM vehicles_business WHERE business = @business";
                command.Parameters.AddWithValue("@business", business.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    price       = reader.GetInt32(reader.GetOrdinal("price"));
                        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"));

                        bool isCompanySelling = false;
                        bool isRentSelling    = false;
                        bool isNormalSelling  = false;

                        switch (business.type)
                        {
                        case 6:
                            isRentSelling = true;
                            break;

                        case 7:
                            isNormalSelling = true;
                            break;

                        case 8:
                            isCompanySelling = true;
                            break;
                        }

                        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);
                            TextLabel label     = NAPI.TextLabel.CreateTextLabel($"~y~{type}~n~~w~Precio: ~g~${price}", position, 8, 1, 0, new Color(255, 255, 255));
                            vehicle.NumberPlate = numberplate;

                            Data.Entities.VehicleBusiness veh = new Data.Entities.VehicleBusiness()
                            {
                                id               = id,
                                model            = type,
                                vehicle          = vehicle,
                                business         = business,
                                price            = price,
                                isRentSelling    = isRentSelling,
                                isNormalSelling  = isNormalSelling,
                                isCompanySelling = isCompanySelling,
                                label            = label
                            };

                            vehicle.SetData("VEHICLE_BUSINESS_DATA", veh);

                            vehicle.SetSharedData("BUSINESS_VEHICLE_SHARED", vehicle);
                            vehicle.SetSharedData("IS_BUSINESS_VEHICLE", true);
                        });
                    }
                }
            }
        }