Beispiel #1
0
        public void Business_EnterColShape(ColShape shape, Client player)
        {
            //var business = shape.GetExternalData<Data.Entities.Business>(0);
            if (!shape.HasData("BUSINESS_CLASS"))
            {
                return;
            }
            Data.Entities.Business business = shape.GetData("BUSINESS_CLASS");

            //var user = player.GetExternalData<Data.Entities.User>(0);
            if (!player.HasData("USER_CLASS"))
            {
                return;
            }
            Data.Entities.User user = player.GetData("USER_CLASS");

            if (business != null)
            {
                if (business.owner == 0)
                {
                    player.TriggerEvent("displayBusinessVenta");
                }
                else
                {
                    if (business.type == 6 || business.type == 7 || business.type == 8)
                    {
                        player.TriggerEvent("adviceBuyVehicle");
                    }
                }

                user.isInBusiness = true;
                user.business     = business;
            }
        }
Beispiel #2
0
        public async Task CMD_crearnegociospawn(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.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");

                if (business.spawn != null)
                {
                    Utilities.Notifications.SendNotificationERROR(player, "Este negocio ya tiene punto de spawn");
                    return;
                }

                await World.Business.DbFunctions.CreateBusinessVehicleSpawn(business.id, player.Position.X, player.Position.Y, player.Position.Z, player.Heading);

                business.spawn    = player.Position;
                business.spawnRot = player.Heading;

                Utilities.Notifications.SendNotificationOK(player, "Has creado el punto de spawn correctamente");
            }
        }
Beispiel #3
0
        public void Business_ExitColShape(ColShape shape, Client player)
        {
            //var business = shape.GetExternalData<Data.Entities.Business>(0);
            if (!shape.HasData("BUSINESS_CLASS"))
            {
                return;
            }
            Data.Entities.Business business = shape.GetData("BUSINESS_CLASS");
            //var user = player.GetExternalData<Data.Entities.User>(0);
            if (!player.HasData("USER_CLASS"))
            {
                return;
            }
            Data.Entities.User user = player.GetData("USER_CLASS");

            if (business != null)
            {
                user.isInBusiness = false;
                user.business     = null;
            }
        }
Beispiel #4
0
        public async static Task GetBusinessVehicleSpawn(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 business_vehicle_spawn WHERE business = @id";
                command.Parameters.AddWithValue("@id", business.id);

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

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        business.spawn    = new Vector3(reader.GetDouble(reader.GetOrdinal("x")), reader.GetDouble(reader.GetOrdinal("y")), reader.GetDouble(reader.GetOrdinal("z")));
                        business.spawnRot = (float)reader.GetDouble(reader.GetOrdinal("rot"));
                    }
                }
            }
        }
Beispiel #5
0
        public async Task RE_BusinessFinishCreation(Client player, string name)
        {
            //var user = player.GetExternalData<Data.Entities.User>(0);
            if (!player.HasData("USER_CLASS"))
            {
                return;
            }
            Data.Entities.User user = player.GetData("USER_CLASS");

            if (user.adminLv == 5)
            {
                if (player.HasData("CreateBusinessType"))
                {
                    if (player.HasData("CreateBusinessPrice"))
                    {
                        int streetid = await DbFunctions.GetLastStreetNumber(name) + 1;

                        //int type = player.GetData<int>("CreateCompanyType");
                        //int price = player.GetData<int>("CreateCompanyPrice
                        int type  = player.GetData("CreateBusinessType");
                        int price = player.GetData("CreateBusinessPrice");

                        int idempresa = await World.Business.DbFunctions.CreateBusiness(player, type, price, name, streetid);

                        Data.Entities.Business business = new Data.Entities.Business();

                        ColShape  buss   = NAPI.ColShape.CreateCylinderColShape(player.Position, 2, 2);
                        Marker    marker = NAPI.Marker.CreateMarker(0, player.Position, new Vector3(), new Vector3(), 1, new Color(248, 218, 79));
                        TextLabel label  = NAPI.TextLabel.CreateTextLabel($"Negocio en venta~n~Pulsa ~y~F5 ~w~para interactuar~n~~p~{name}, {streetid}", player.Position, 5, 1, 0, new Color(255, 255, 255));
                        Blip      blip   = NAPI.Blip.CreateBlip(player.Position);
                        blip.Color = 3;
                        blip.Name  = "Negocio en venta";

                        switch (type)
                        {
                        case 1:
                            blip.Sprite = 198;
                            break;

                        case 2:
                            blip.Sprite = 477;
                            break;

                        case 3:
                            blip.Sprite = 72;
                            break;

                        case 4:
                            blip.Sprite = 528;
                            break;

                        case 5:
                            blip.Sprite = 135;
                            break;

                        case 6:
                            blip.Sprite = 135;
                            label.Text  = $"Negocio en venta~n~~p~{name}, {streetid}";
                            break;

                        case 7:
                            blip.Sprite = 135;
                            label.Text  = $"Negocio en venta~n~~p~{name}, {streetid}";
                            break;

                        case 8:
                            blip.Sprite = 135;
                            label.Text  = $"Negocio en venta~n~~p~{name}, {streetid}";
                            break;

                        case 9:
                            blip.Sprite = 135;
                            break;
                        }

                        business.id      = idempresa;
                        business.type    = type;
                        business.name    = "Compañía en venta";
                        business.owner   = 0;
                        business.price   = price;
                        business.blip    = blip;
                        business.marker  = marker;
                        business.label   = label;
                        business.area    = name;
                        business.number  = streetid;
                        business.safeBox = 0;
                        business.shape   = buss;

                        //empresa.SetExternalData<Data.Entities.Company>(0, company);
                        buss.SetData("BUSINESS_CLASS", business);
                    }
                }
            }
        }
Beispiel #6
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)");
            }
        }
Beispiel #7
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);
                        });
                    }
                }
            }
        }
Beispiel #8
0
        public static async Task SpawnBusiness()
        {
            using (MySqlConnection connection = new MySqlConnection(Data.DatabaseHandler.connectionHandle))
            {
                await connection.OpenAsync().ConfigureAwait(false);

                MySqlCommand command = connection.CreateCommand();
                command.CommandText = "SELECT * FROM business";

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

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        int    id      = reader.GetInt32(reader.GetOrdinal("id"));
                        int    userid  = reader.GetInt32(reader.GetOrdinal("owner"));
                        int    type    = reader.GetInt32(reader.GetOrdinal("type"));
                        string name    = reader.GetString(reader.GetOrdinal("name"));
                        int    price   = reader.GetInt32(reader.GetOrdinal("price"));
                        double safeBox = reader.GetDouble(reader.GetOrdinal("safeBox"));
                        string area    = reader.GetString(reader.GetOrdinal("area"));
                        int    number  = reader.GetInt32(reader.GetOrdinal("number"));

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

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

                        if (name == "NO")
                        {
                            nombre = "Negocio en venta";
                        }
                        else
                        {
                            nombre = name;
                        }

                        NAPI.Task.Run(async() =>
                        {
                            ColShape shape  = NAPI.ColShape.CreateCylinderColShape(position.Subtract(new Vector3(0, 0, 1)), 2, 2);
                            TextLabel label = NAPI.TextLabel.CreateTextLabel($"{nombre}~n~Pulsa ~y~F5 ~w~para interactuar~n~~p~{area}, {number}", position, 3, 1, 0, new Color(255, 255, 255));
                            Marker marker   = NAPI.Marker.CreateMarker(0, position.Subtract(new Vector3(0, 0, 0.1)), new Vector3(), new Vector3(), 1, new Color(251, 244, 1));
                            Blip blip       = NAPI.Blip.CreateBlip(position);
                            blip.Color      = 3;
                            blip.Name       = nombre;

                            switch (type)
                            {
                            case 1:
                                blip.Sprite = 198;
                                break;

                            case 2:
                                blip.Sprite = 477;
                                break;

                            case 3:
                                blip.Sprite = 72;
                                break;

                            case 4:
                                blip.Sprite = 528;
                                break;

                            case 5:
                                blip.Sprite = 135;
                                break;

                            case 6:
                                blip.Sprite = 135;
                                label.Text  = $"{nombre}~n~~p~{area}, {number}";
                                break;

                            case 7:
                                blip.Sprite = 135;
                                label.Text  = $"{nombre}~n~~p~{area}, {number}";
                                break;

                            case 8:
                                blip.Sprite = 135;
                                label.Text  = $"{nombre}~n~~p~{area}, {number}";
                                break;

                            case 9:
                                blip.Sprite = 135;
                                break;
                            }

                            Data.Entities.Business business = new Data.Entities.Business
                            {
                                id      = id,
                                owner   = userid,
                                type    = type,
                                name    = name,
                                price   = price,
                                blip    = blip,
                                label   = label,
                                marker  = marker,
                                area    = area,
                                number  = number,
                                safeBox = safeBox,
                                shape   = shape
                            };

                            //shape.SetExternalData<Data.Entities.Business>(0, business);
                            shape.SetData("BUSINESS_CLASS", business);

                            Data.Info.businessSpanwed++;

                            await SpawnVehicleBusiness(business);
                            await GetBusinessVehicleSpawn(business);
                        });
                    }
                }
            }
        }