public void DressEquipedClothesEvent(Client player, params object[] arguments) { int type = Int32.Parse(arguments[0].ToString()); int slot = Int32.Parse(arguments[1].ToString()); int playerId = NAPI.Data.GetEntityData(player, EntityData.PLAYER_SQL_ID); ClothesModel clothes = Globals.GetDressedClothesInSlot(playerId, type, slot); // Miramos si llevaba algo o no if (clothes != null) { if (type == 0) { NAPI.Player.SetPlayerClothes(player, slot, clothes.drawable, clothes.texture); } else { NAPI.Player.SetPlayerAccessory(player, slot, clothes.drawable, clothes.texture); } } else { if (type == 0) { NAPI.Player.SetPlayerClothes(player, slot, 0, 0); } else { NAPI.Player.SetPlayerAccessory(player, slot, 0, 0); } } }
/// <summary> /// Возвращает одежду игрока для эвента /// </summary> internal static List <ClothesModel> GetEventClothes(EventTeam team, bool isMale) { var head = new ClothesModel { Slot = 0, Variation = isMale ? 20 : 22, Texture = isMale ? 5 : 3, IsClothes = false }; var top = new ClothesModel { Slot = 11, Undershirt = isMale ? 57 : 3, IsClothes = true }; if (team == EventTeam.Red) { top.Variation = isMale ? 14 : 169; top.Texture = isMale ? 9 : 2; top.Torso = isMale ? 0 : 15; } else { top.Variation = isMale ? 14 : 195; top.Texture = isMale ? 0 : 8; top.Torso = isMale ? 0 : 4; } var legs = new ClothesModel { Slot = 4, Variation = isMale ? 43 : 4, IsClothes = true }; var feets = new ClothesModel { Slot = 6, Variation = isMale ? 12 : 4, IsClothes = true }; return(new List <ClothesModel> { head, top, legs, feets }); }
// Получение одежды персонажа по ID. public static List <ClothesModel> GetCharacterClothes(int characterId) { List <ClothesModel> clothesList = new List <ClothesModel>(); using (MySqlConnection connection = new MySqlConnection(connectionString)) { connection.Open(); MySqlCommand command = connection.CreateCommand(); command.CommandText = "SELECT * FROM clothes WHERE characterid = @characterid"; command.Parameters.AddWithValue("@characterid", characterId); using (MySqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { ClothesModel clothes = new ClothesModel(); clothes.slot = reader.GetInt32("slot"); clothes.drawable = reader.GetInt32("drawable"); clothes.texture = reader.GetInt32("texture"); clothesList.Add(clothes); } } } return(clothesList); }
public void DressEquipedClothesEvent(Client player, int type, int slot) { int playerId = NAPI.Data.GetEntityData(player, EntityData.PLAYER_SQL_ID); ClothesModel clothes = Globals.GetDressedClothesInSlot(playerId, type, slot); if (clothes != null) { if (type == 0) { NAPI.Player.SetPlayerClothes(player, slot, clothes.drawable, clothes.texture); } else { NAPI.Player.SetPlayerAccessory(player, slot, clothes.drawable, clothes.texture); } } else { if (type == 0) { NAPI.Player.SetPlayerClothes(player, slot, 0, 0); } else { NAPI.Player.SetPlayerAccessory(player, slot, 0, 0); } } }
public async Task <IActionResult> Edit(Guid id, [Bind("ID,VendorCode,Price,SizesString,Brand,ImgFormat,ImagesCount,ImgPath,CollectionID")] ClothesModel clothesModel) { if (id != clothesModel.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(clothesModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ClothesModelExists(clothesModel.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CollectionID"] = new SelectList(_context.CollectionModels, "ID", "Name", clothesModel.CollectionID); return(View(clothesModel)); }
public void DressEquipedClothesEvent(Client player, int type, int slot) { int playerId = player.GetData(EntityData.PLAYER_SQL_ID); ClothesModel clothes = Globals.GetDressedClothesInSlot(playerId, type, slot); if (clothes != null) { if (type == 0) { player.SetClothes(slot, clothes.drawable, clothes.texture); } else { player.SetAccessories(slot, clothes.drawable, clothes.texture); } } else { if (type == 0) { player.SetClothes(slot, 0, 0); } else { player.SetAccessories(slot, 255, 255); } } }
public void ClothesItemSelectedEvent(Client player, int clothesId, int type, int slot) { int businessId = NAPI.Data.GetEntityData(player, EntityData.PLAYER_BUSINESS_ENTERED); int sex = NAPI.Data.GetEntitySharedData(player, EntityData.PLAYER_SEX); int products = GetClothesProductsPrice(clothesId, sex, type, slot); BusinessModel business = GetBusinessById(businessId); int price = (int)Math.Round(products * business.multiplier); // We check whether the player has enough money int playerMoney = NAPI.Data.GetEntitySharedData(player, EntityData.PLAYER_MONEY); if (playerMoney >= price) { int playerId = NAPI.Data.GetEntityData(player, EntityData.PLAYER_SQL_ID); // Substracting paid money NAPI.Data.SetEntitySharedData(player, EntityData.PLAYER_MONEY, playerMoney - price); // We substract the product and add funds to the business if (business.owner != String.Empty) { business.funds += price; business.products -= products; Task.Factory.StartNew(() => { // Update the business Database.UpdateBusiness(business); }); } // Undress previous clothes Globals.UndressClothes(playerId, type, slot); // We make the new clothes model ClothesModel clothesModel = new ClothesModel(); clothesModel.player = playerId; clothesModel.type = type; clothesModel.slot = slot; clothesModel.drawable = clothesId; clothesModel.dressed = true; Task.Factory.StartNew(() => { // Storing the clothes into database clothesModel.id = Database.AddClothes(clothesModel); Globals.clothesList.Add(clothesModel); // Confirmation message sent to the player String purchaseMessage = String.Format(Messages.INF_BUSINESS_ITEM_PURCHASED, price); NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_INFO + purchaseMessage); }); } else { NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_PLAYER_NOT_ENOUGH_MONEY); } }
/// <summary> /// Купить одежду /// </summary> public bool BuyGood(Client player, PlayerInfo playerInfo, ClothesModel good) { if (playerInfo.Balance < good.Price) { API.sendNotificationToPlayer(player, "~r~Недостаточно средств", true); return(false); } playerInfo.Balance -= good.Price; return(true); }
public void ClothesItemSelectedEvent(Client player, params object[] arguments) { // Calculamos el precio de la ropa int clothesId = Int32.Parse(arguments[0].ToString()); int businessId = NAPI.Data.GetEntityData(player, EntityData.PLAYER_BUSINESS_ENTERED); int type = Int32.Parse(arguments[1].ToString()); int slot = Int32.Parse(arguments[2].ToString()); int sex = NAPI.Data.GetEntitySharedData(player, EntityData.PLAYER_SEX); int products = GetClothesProductsPrice(clothesId, sex, type, slot); BusinessModel business = GetBusinessById(businessId); int price = (int)Math.Round(products * business.multiplier); // Miramos si tiene dinero suficiente int playerMoney = NAPI.Data.GetEntitySharedData(player, EntityData.PLAYER_MONEY); if (playerMoney >= price) { // Sacamos el identificador del jugador int playerId = NAPI.Data.GetEntityData(player, EntityData.PLAYER_SQL_ID); // Restamos al jugador el dinero NAPI.Data.SetEntitySharedData(player, EntityData.PLAYER_MONEY, playerMoney - price); // Si el negocio tiene dueño, le damos el dinero y descontamos los productos if (business.owner != String.Empty) { business.funds += price; business.products -= products; Database.UpdateBusiness(business); } // Desequipamos la ropa anterior Globals.UndressClothes(playerId, type, slot); // Creamos el modelo de ropa ClothesModel clothesModel = new ClothesModel(); clothesModel.player = playerId; clothesModel.type = type; clothesModel.slot = slot; clothesModel.drawable = clothesId; clothesModel.dressed = true; // Añadimos el objeto a la base de datos clothesModel.id = Database.AddClothes(clothesModel); Globals.clothesList.Add(clothesModel); // Enviamos el mensaje al jugador String purchaseMessage = String.Format(Messages.INF_BUSINESS_ITEM_PURCHASED, price); NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_INFO + purchaseMessage); } else { NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_ERROR + Messages.ERR_PLAYER_NOT_ENOUGH_MONEY); } }
/// <summary> /// Сменить одежду /// </summary> private static void ChangeGood(PlayerInfo playerInfo, ClothesModel playerGood, int texture) { var oldGoods = playerInfo.Clothes.Where(e => e.Slot == playerGood.Slot).ToList(); foreach (var oldGood in oldGoods) { oldGood.OnPlayer = false; } playerGood.Texture = texture; playerGood.OnPlayer = true; }
/// <summary> /// This function is used to set the current clothes on the ped. /// </summary> public bool AddClothes(ClothesTexture texture, ClothesModel model, ClothesSlot slot) { string t = texture.ToString(); string m = model.ToString(); if (IsClothesSlotTattoo(slot)) { t = ((int)slot).ToString() + t; m = ((int)slot).ToString() + m; } return(MtaShared.AddPedClothes(element, t, m, (int)slot)); }
public void ClothesItemSelectedEvent(Client player, string clothesJson) { ClothesModel clothesModel = NAPI.Util.FromJson <ClothesModel>(clothesJson); int businessId = player.GetData(EntityData.PLAYER_BUSINESS_ENTERED); int sex = player.GetData(EntityData.PLAYER_SEX); int products = GetClothesProductsPrice(clothesModel.id, sex, clothesModel.type, clothesModel.slot); BusinessModel business = GetBusinessById(businessId); int price = (int)Math.Round(products * business.multiplier); // We check whether the player has enough money int playerMoney = player.GetSharedData(EntityData.PLAYER_MONEY); if (playerMoney >= price) { int playerId = player.GetData(EntityData.PLAYER_SQL_ID); // Substracting paid money player.SetSharedData(EntityData.PLAYER_MONEY, playerMoney - price); // We substract the product and add funds to the business if (business.owner != string.Empty) { business.funds += price; business.products -= products; Task.Factory.StartNew(() => { // Update the business Database.UpdateBusiness(business); }); } // Undress previous clothes Globals.UndressClothes(playerId, clothesModel.type, clothesModel.slot); // Store the remaining data clothesModel.player = playerId; clothesModel.dressed = true; Task.Factory.StartNew(() => { // Storing the clothes into database clothesModel.id = Database.AddClothes(clothesModel); Globals.clothesList.Add(clothesModel); // Confirmation message sent to the player string purchaseMessage = string.Format(InfoRes.business_item_purchased, price); player.SendChatMessage(Constants.COLOR_INFO + purchaseMessage); }); } else { player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.player_not_enough_money); } }
public async Task <IActionResult> Create([Bind("ID,VendorCode,Price,SizesString,Brand,ImgFormat,ImagesCount,ImgPath,CollectionID")] ClothesModel clothesModel) { if (ModelState.IsValid) { _context.Add(clothesModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CollectionID"] = new SelectList(_context.CollectionModels, "ID", "Name", clothesModel.CollectionID); return(View(clothesModel)); }
/// <summary> /// Создать новую одежду /// </summary> private static ClothesModel CreateGood(ClothesModel good) { return(new ClothesModel { Variation = good.Variation, Slot = good.Slot, Torso = good.Torso, Undershirt = good.Undershirt, Textures = new List <int> { good.Texture }, IsClothes = good.IsClothes }); }
private void PurchaseClothesEvent(object[] args) { // Get the variables from the arguments int index = Convert.ToInt32(args[0]); // Create the clothes model ClothesModel clothesModel = new ClothesModel(); { clothesModel.type = clothesTypes[index].type; clothesModel.slot = clothesTypes[index].bodyPart; clothesModel.drawable = clothesTypes[index].clothesId; clothesModel.texture = Convert.ToInt32(args[1]); } // Purchase the clothes Events.CallRemote("clothesItemSelected", JsonConvert.SerializeObject(clothesModel)); }
/// <summary> /// Установить одежду /// </summary> public void SetClothes(Client player, ClothesModel clothes) { if (clothes.Torso.HasValue) { API.setPlayerClothes(player, 3, clothes.Torso.Value, 0); } if (clothes.Undershirt.HasValue) { API.setPlayerClothes(player, 8, clothes.Undershirt.Value, 0); } if (clothes.IsClothes) { API.setPlayerClothes(player, clothes.Slot, clothes.Variation, clothes.Texture); } else { API.setPlayerAccessory(player, clothes.Slot, clothes.Variation, clothes.Texture); } }
/// <summary> /// Возвращает одежду игрока для эвента /// </summary> internal static List <ClothesModel> GetEventClothes(EventTeam team, bool isMale) { var top = new ClothesModel { Slot = 11, Undershirt = isMale ? 57 : 3, Torso = 0, IsClothes = true }; if (team == EventTeam.Red) { top.Variation = isMale ? 1 : 0; top.Texture = isMale ? 4 : 5; } else { top.Variation = isMale ? 47 : 0; top.Texture = isMale ? 0 : 6; } return(new List <ClothesModel> { top }); }
/// <summary> /// Конвертация сущностей в модели /// </summary> public static List <ClothesModel> ConvertTModels(IEnumerable <PlayerClothes> entities) { var result = new List <ClothesModel>(); foreach (var entity in entities) { var model = new ClothesModel { Variation = entity.Variation, Slot = entity.Slot, Torso = entity.Torso, Undershirt = entity.Undershirt, Texture = entity.Texture, Textures = entity.Textures.Split(',').Select(e => Convert.ToInt32(e)).ToList(), OnPlayer = entity.OnPlayer, IsClothes = entity.IsClothes }; result.Add(model); } return(result); }
public void ClothesItemSelectedEvent(Client player, string clothesJson) { BusinessClothesModel clothesModel = NAPI.Util.FromJson <BusinessClothesModel>(clothesJson); // Get the player's clothes int playerId = player.GetData(EntityData.PLAYER_SQL_ID); List <ClothesModel> ownedClothes = Globals.GetPlayerClothes(playerId); if (ownedClothes.Any(c => c.slot == clothesModel.bodyPart && c.type == clothesModel.type && c.drawable == clothesModel.clothesId && c.texture == clothesModel.texture)) { // The player already has those clothes player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.player_owns_clothes); return; } // Store the data from the purchase ClothesModel clothes = new ClothesModel(); { clothes.type = clothesModel.type; clothes.slot = clothesModel.bodyPart; clothes.drawable = clothesModel.clothesId; clothes.texture = clothesModel.texture; clothes.player = playerId; clothes.dressed = true; }; int businessId = player.GetData(EntityData.PLAYER_BUSINESS_ENTERED); int sex = player.GetData(EntityData.PLAYER_SEX); int products = GetClothesProductsPrice(clothesModel.clothesId, sex, clothesModel.type, clothesModel.bodyPart); BusinessModel business = GetBusinessById(businessId); int price = (int)Math.Round(products * business.multiplier); // We check whether the player has enough money int playerMoney = player.GetSharedData(EntityData.PLAYER_MONEY); if (playerMoney >= price) { // Substracting paid money player.SetSharedData(EntityData.PLAYER_MONEY, playerMoney - price); // We substract the product and add funds to the business if (business.owner != string.Empty) { business.funds += price; business.products -= products; Task.Factory.StartNew(() => { NAPI.Task.Run(() => { // Update the business Database.UpdateBusiness(business); }); }); } // Undress previous clothes Globals.UndressClothes(playerId, clothesModel.type, clothesModel.bodyPart); Task.Factory.StartNew(() => { NAPI.Task.Run(() => { // Storing the clothes into database clothes.id = Database.AddClothes(clothes); Globals.clothesList.Add(clothes); // Confirmation message sent to the player string purchaseMessage = string.Format(InfoRes.business_item_purchased, price); player.SendChatMessage(Constants.COLOR_INFO + purchaseMessage); }); }); } else { player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.player_not_enough_money); } }
/// <summary> /// Add clothes from only texture and model (does not work on tattoos) /// </summary> public bool AddClothes(ClothesTexture texture, ClothesModel model) { Tuple <int, int> result = MtaShared.GetTypeIndexFromClothes(texture.ToString(), model.ToString()); return(AddClothes((ClothesSlot)result.Item1, result.Item2)); }
public void OnCloseCustomization(Client player, string playerJsonInfo, string name, string surname, int gender, int age, string clothes) { // Лист с будущим списком одежды. List <ClothesModel> clothesModels = new List <ClothesModel>(); CharacterModel characterModel = new CharacterModel(); // Внешний вид игрока. SkinModel skinModel = new SkinModel(); // Получаем одежду из редактора. var obj_clothes = NAPI.Util.FromJson(clothes); for (int i = 0; i < obj_clothes.Count; i++) { ClothesModel clothes_model = new ClothesModel(); switch (i) { case 0: clothes_model.slot = 11; clothes_model.drawable = (int)obj_clothes[i]; clothes_model.texture = 0; clothesModels.Add(clothes_model); break; case 1: clothes_model.slot = 4; clothes_model.drawable = (int)obj_clothes[i]; clothes_model.texture = 0; clothesModels.Add(clothes_model); break; case 2: clothes_model.slot = 6; clothes_model.drawable = (int)obj_clothes[i]; clothes_model.texture = 0; clothesModels.Add(clothes_model); break; } } characterModel.characterName = name + "_" + surname; characterModel.sex = gender; characterModel.age = age; var data = NAPI.Util.FromJson(playerJsonInfo); skinModel.firstHeadShape = (int)data[0]; skinModel.secondHeadShape = (int)data[1]; skinModel.firstSkinTone = (int)data[2]; skinModel.secondSkinTone = (int)data[3]; skinModel.headMix = (float)data[4]; skinModel.skinMix = (float)data[5]; skinModel.hairModel = (int)data[6]; skinModel.firstHairColor = (int)data[7]; skinModel.secondHairColor = (int)data[8]; skinModel.beardModel = (int)data[9]; skinModel.beardColor = (int)data[10]; skinModel.chestModel = (int)data[11]; skinModel.chestColor = (int)data[12]; skinModel.blemishesModel = (int)data[13]; skinModel.ageingModel = (int)data[14]; skinModel.complexionModel = (int)data[15]; skinModel.sundamageModel = (int)data[16]; skinModel.frecklesModel = (int)data[17]; skinModel.eyesColor = (int)data[18]; skinModel.eyebrowsModel = (int)data[19]; skinModel.eyebrowsColor = (int)data[20]; skinModel.makeupModel = (int)data[21]; skinModel.blushModel = (int)data[22]; skinModel.blushColor = (int)data[23]; skinModel.lipstickModel = (int)data[24]; skinModel.lipstickColor = (int)data[25]; skinModel.noseWidth = (float)data[26]; skinModel.noseHeight = (float)data[27]; skinModel.noseLength = (float)data[28]; skinModel.noseBridge = (float)data[29]; skinModel.noseTip = (float)data[30]; skinModel.noseShift = (float)data[31]; skinModel.browHeight = (float)data[32]; skinModel.browWidth = (float)data[33]; skinModel.cheekboneHeight = (float)data[34]; skinModel.cheekboneWidth = (float)data[35]; skinModel.cheeksWidth = (float)data[36]; skinModel.eyes = (float)data[37]; skinModel.lips = (float)data[38]; skinModel.jawWidth = (float)data[39]; skinModel.jawHeight = (float)data[40]; skinModel.chinLength = (float)data[41]; skinModel.chinPosition = (float)data[42]; skinModel.chinWidth = (float)data[43]; skinModel.chinShape = (float)data[44]; skinModel.neckWidth = (float)data[45]; player.SetData(EntityData.PLAYER_SKIN_MODEL, skinModel); ApplyPlayerCustomization(player, skinModel, gender); NAPI.Task.Run(() => { // Создаем персонажа и сохраняем его данные: внешний вид, одежда, информация о персонаже. int playerId = Database.Database.CreateCharacter(player, characterModel, skinModel, clothesModels); }); Auth.OnCharSelected(player, characterModel.characterName); }