const { weaponshop, slots, rarecars, simplecars, houses, cars, phones, weapons, equipment, UserModel, WorldModel, JobModel, PropertyModel, BusinessModel, ReportModel, BlockModel, PromocodeModel, mainChat, adminList, expToUp, topSym } = require('/workspace/degradin/Dev/Telegram/CampFire Play/config') const { spaces, spacesWithMarkdown, escape, generatePromo, generateVoucher, getCurrentTime, getSlot, giveExp, matPriceUpdate, rand, random, setCooldown, weaponShopUpdate, stats } = require('/workspace/degradin/Dev/Telegram/CampFire Play/utils') module.exports = async (ctx) => { let data = ctx.update.callback_query.data; data = JSON.parse(data) let user = await UserModel.findByPk(ctx.from.id) let property = await PropertyModel.findByPk(ctx.from.id); let world = await WorldModel.findByPk(1) if (data.type == "house") { if (user.money < houses[data.value].price) return await ctx.reply(`У вас недостаточно средств!`) if (property.house.name) return await ctx.reply(`У вас уже есть дом.`) user.money -= houses[data.value].price world.balance += houses[data.value].price property.house = houses[data.value] await user.save() await world.save() await property.save() return await ctx.reply(`Вы купили ${houses[data.value].name}`) } if (data.type == "car") { if (user.money < cars[data.value].price) return await ctx.reply(`У вас недостаточно средств!`) if (property.car.name) return await ctx.reply(`У вас уже есть автомобиль.`) if (!property.house.name) return await ctx.reply(`Для покупки автомобиля, у Вас должен быть дом.`) user.money -= cars[data.value].price world.balance += cars[data.value].price property.car = cars[data.value] await user.save() await world.save() await property.save() return await ctx.reply(`Вы купили ${cars[data.value].name}`) } if (data.type == "phone") { if (user.money < phones[data.value].price) return await ctx.reply(`У вас недостаточно средств!`) if (property.mobile.name) return await ctx.reply(`У вас уже есть телефон.`) user.money -= phones[data.value].price world.balance += phones[data.value].price property.mobile = phones[data.value] await user.save() await world.save() await property.save() return await ctx.reply(`Вы купили ${phones[data.value].name}`) } if (data.type == "equipment") { if (user.money < weaponshop[data.value].price) return await ctx.reply(`У вас недостаточно средств!`) if (data.type == weaponshop[data.value].type) { if (property.equipment.name) return await ctx.reply(`У вас уже есть экипировка.`) user.money -= weaponshop[data.value].price world.balance += weaponshop[data.value].price property.equipment = weaponshop[data.value] await user.save() await world.save() await property.save() await ctx.reply(`Вы купили ${weaponshop[data.value].name}`) return delete weaponshop[data.value] } if (property.weapon.name) return await ctx.reply(`У вас уже есть оружие.`) user.money -= weaponshop[data.value].price world.balance += weaponshop[data.value].price property.weapon = weaponshop[data.value] await user.save() await world.save() await property.save() await ctx.reply(`Вы купили ${weaponshop[data.value].name}`) return delete weaponshop[data.value] } }