Esempio n. 1
0
        public async Task RE_CompanyFinishCreation(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("CreateCompanyType"))
                {
                    if (player.HasData("CreateCompanyPrice"))
                    {
                        int streetid = await DbFunctions.GetLastStreetNumber(name) + 1;

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

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

                        Data.Entities.Company company = new Data.Entities.Company();

                        ColShape  empresa = 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($"Compañía 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  = "Compañía 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;
                        }

                        company.id         = idempresa;
                        company.type       = type;
                        company.name       = "Compañía en venta";
                        company.owner      = 0;
                        company.price      = price;
                        company.blip       = blip;
                        company.marker     = marker;
                        company.label      = label;
                        company.area       = name;
                        company.number     = streetid;
                        company.safeBox    = 0;
                        company.workers    = 0;
                        company.percentage = 0;
                        company.subsidy    = 0;
                        company.shape      = empresa;

                        //empresa.SetExternalData<Data.Entities.Company>(0, company);
                        empresa.SetData("COMPANY_CLASS", company);

                        Data.Lists.Companies.Add(company);
                    }
                }
            }
        }