Postado Fevereiro 17, 2020 5 anos .Qual servidor ou website você utiliza como base? tfs 1.0 versao 12.00 Qual o motivo deste tópico? Preciso de ajuda na parte de travar a 3° prey quando o player cria o char. Quando cria accout o char ja vem com a 3° prey liberada, queria deixar pra liberar so comprando na store... Obrigado REP++ pra quem ajudar ai valeu precisar de algum arquivo é só falar gostaria que ficasse igual o da imagem Está surgindo algum erro? Se sim coloque-o aqui. Citar Você tem o código disponível? Se tiver publique-o aqui: Você tem alguma imagem que possa auxiliar no problema? Se sim, coloque-a aqui. Editado Fevereiro 17, 2020 5 anos por dougotserv (veja o histórico de edições)
Postado Fevereiro 17, 2020 5 anos Eu consegui resolver por conta própria, porém acredito de fato que não seja o melhor jeito para resolver essa situação, mas foi da única forma que consegui. 1 - No arquivo "src/iologindata.cpp", altere o seguinte trecho: De: DBInsert preyDataQuery("INSERT INTO `prey_slots` (`player_id`, `num`, `state`, `unlocked`, `current`, `monster_list`, `free_reroll_in`, `time_left`, `next_use`, `bonus_type`, `bonus_value`, `bonus_grade`) VALUES "); for (size_t num = 0; num < PREY_SLOTNUM_THIRD + 1; num++) { query << player->getGUID() << ',' << num << ',' << 3 << ',' << 1 << ',' << db.escapeString("") << ',' << db.escapeString("") << ',' << 0 << ',' << 0 << ',' << 0 << ',' << 0 << ',' << 0 << ',' << 0; if (!preyDataQuery.addRow(query)) { return false; } } Para: DBInsert preyDataQuery("INSERT INTO `prey_slots` (`player_id`, `num`, `state`, `unlocked`, `current`, `monster_list`, `free_reroll_in`, `time_left`, `next_use`, `bonus_type`, `bonus_value`, `bonus_grade`) VALUES "); for (size_t num = 0; num < PREY_SLOTNUM_THIRD + 1; num++) { query << player->getGUID() << ',' << num << ',' << "CASE WHEN `num` = 2 AND `player_id` NOT IN(SELECT `player_id` FROM `player_storage` WHERE `key` = 63253 AND `value` = 1) THEN 1 ELSE 3 END" << ',' << "CASE WHEN `num` = 2 AND `player_id` NOT IN(SELECT `player_id` FROM `player_storage` WHERE `key` = 63253 AND `value` = 1) THEN 0 ELSE 1 END" << ',' << db.escapeString("") << ',' << db.escapeString("") << ',' << 0 << ',' << 0 << ',' << 0 << ',' << 0 << ',' << 0 << ',' << 0; if (!preyDataQuery.addRow(query)) { return false; } } 2 - No arquivo "data/modules/scripts/gamestore/gamestore.lua" defina o preço da compra do slot prey e guarde esse valor pois será utilizado no próximo arquivo. 3 - No arquivo "data/modules/scripts/gamestore/init.lua" altere o seguinte trecho: De: function GameStore.processPreySlotPurchase(player) if player:getStorageValue(63253) < 1 then player:setStorageValue(63253, 1) end player:setStorageValue(63253, 1) end Para: function GameStore.processPreySlotPurchase(player) local playerId = player:getId() local playerGuid = player:getGuid() local accountId = player:getAccountId() if player:getStorageValue(63253) < 1 then local tile = Tile(player:getPosition()) if (tile) then if (not tile:hasFlag(TILESTATE_PROTECTIONZONE)) then return error({code = 1, message = "You can unlock your third prey slot only in Protection Zone."}) end end player:setStorageValue(63253, 1) message = "You have successfully unlocked your third prey slot permanently, relogin!" player:remove() db.query("UPDATE `prey_slots` SET `state` = 3, `unlocked` = 1 WHERE `player_id` = " .. playerGuid .. " AND `num` = 2") db.query("UPDATE `accounts` SET `coins` = `coins` -30 WHERE `id` = " .. accountId) GameStore.insertHistory(accountId, GameStore.HistoryTypes.HISTORY_TYPE_NONE, "Permanent Prey Slot", -30) addEvent(function() local player = Player(playerId) if not player then return false end end, 500) end end Na parte 3, você precisará alterar o valor da prey slot definida na gamestore. Altere nesses dois trechos em vermelho: 1: db.query("UPDATE `accounts` SET `coins` = `coins` -30 WHERE `id` = " .. accountId) 2: GameStore.insertHistory(accountId, GameStore.HistoryTypes.HISTORY_TYPE_NONE, "Permanent Prey Slot", -30) Feito isso, basta compilar novamente o tfs e testar. Aqui funcionou direito. Caso tenha algum problema, pode me perguntar que eu tento ajudar. Vale ressaltar novamente: o método que eu utilizei não é o mais adequado por causa dos CASES no iologindata.cpp e também por dar muita volta atoa, mas foi o único jeito que consegui pois me falta muito conhecimento em C++ e LUA para poder desenvolver melhor esse código. []s
Postado Fevereiro 17, 2020 5 anos Autor Em 17/02/2020 em 17:27, VitorNM disse: Eu consegui resolver por conta própria, porém acredito de fato que não seja o melhor jeito para resolver essa situação, mas foi da única forma que consegui. 1 - No arquivo "src/iologindata.cpp", altere o seguinte trecho: De: DBInsert preyDataQuery("INSERT INTO `prey_slots` (`player_id`, `num`, `state`, `unlocked`, `current`, `monster_list`, `free_reroll_in`, `time_left`, `next_use`, `bonus_type`, `bonus_value`, `bonus_grade`) VALUES "); for (size_t num = 0; num < PREY_SLOTNUM_THIRD + 1; num++) { query << player->getGUID() << ',' << num << ',' << 3 << ',' << 1 << ',' << db.escapeString("") << ',' << db.escapeString("") << ',' << 0 << ',' << 0 << ',' << 0 << ',' << 0 << ',' << 0 << ',' << 0; if (!preyDataQuery.addRow(query)) { return false; } } Para: DBInsert preyDataQuery("INSERT INTO `prey_slots` (`player_id`, `num`, `state`, `unlocked`, `current`, `monster_list`, `free_reroll_in`, `time_left`, `next_use`, `bonus_type`, `bonus_value`, `bonus_grade`) VALUES "); for (size_t num = 0; num < PREY_SLOTNUM_THIRD + 1; num++) { query << player->getGUID() << ',' << num << ',' << "CASE WHEN `num` = 2 AND `player_id` NOT IN(SELECT `player_id` FROM `player_storage` WHERE `key` = 63253 AND `value` = 1) THEN 1 ELSE 3 END" << ',' << "CASE WHEN `num` = 2 AND `player_id` NOT IN(SELECT `player_id` FROM `player_storage` WHERE `key` = 63253 AND `value` = 1) THEN 0 ELSE 1 END" << ',' << db.escapeString("") << ',' << db.escapeString("") << ',' << 0 << ',' << 0 << ',' << 0 << ',' << 0 << ',' << 0 << ',' << 0; if (!preyDataQuery.addRow(query)) { return false; } } 2 - No arquivo "data/modules/scripts/gamestore/gamestore.lua" defina o preço da compra do slot prey e guarde esse valor pois será utilizado no próximo arquivo. 3 - No arquivo "data/modules/scripts/gamestore/init.lua" altere o seguinte trecho: De: function GameStore.processPreySlotPurchase(player) if player:getStorageValue(63253) < 1 then player:setStorageValue(63253, 1) end player:setStorageValue(63253, 1) end Para: function GameStore.processPreySlotPurchase(player) local playerId = player:getId() local playerGuid = player:getGuid() local accountId = player:getAccountId() if player:getStorageValue(63253) < 1 then local tile = Tile(player:getPosition()) if (tile) then if (not tile:hasFlag(TILESTATE_PROTECTIONZONE)) then return error({code = 1, message = "You can unlock your third prey slot only in Protection Zone."}) end end player:setStorageValue(63253, 1) message = "You have successfully unlocked your third prey slot permanently, relogin!" player:remove() db.query("UPDATE `prey_slots` SET `state` = 3, `unlocked` = 1 WHERE `player_id` = " .. playerGuid .. " AND `num` = 2") db.query("UPDATE `accounts` SET `coins` = `coins` -30 WHERE `id` = " .. accountId) GameStore.insertHistory(accountId, GameStore.HistoryTypes.HISTORY_TYPE_NONE, "Permanent Prey Slot", -30) addEvent(function() local player = Player(playerId) if not player then return false end end, 500) end end Na parte 3, você precisará alterar o valor da prey slot definida na gamestore. Altere nesses dois trechos em vermelho: 1: db.query("UPDATE `accounts` SET `coins` = `coins` -30 WHERE `id` = " .. accountId) 2: GameStore.insertHistory(accountId, GameStore.HistoryTypes.HISTORY_TYPE_NONE, "Permanent Prey Slot", -30) Feito isso, basta compilar novamente o tfs e testar. Aqui funcionou direito. Caso tenha algum problema, pode me perguntar que eu tento ajudar. Vale ressaltar novamente: o método que eu utilizei não é o mais adequado por causa dos CASES no iologindata.cpp e também por dar muita volta atoa, mas foi o único jeito que consegui pois me falta muito conhecimento em C++ e LUA para poder desenvolver melhor esse código. []s fiz tudo isso, rodou o game certinho, porem apresentou erro na gamestore.lua e init.lua: Lua Script Error: [Test Interface] data/modules/scripts/gamestore/gamestore.lua data/modules/scripts/gamestore/init.lua:1268: '=' expected near 'playerId' stack traceback: [C]: at 0x004f1d20 [C]: in function 'dofile' data/modules/scripts/gamestore/gamestore.lua:9: in main chunk [Warning - Event::checkScript] Can not load script: scripts/gamestore/gamestore.lua Lua Script Error: [Test Interface] data/modules/scripts/gamestore/gamestore.lua data/modules/scripts/gamestore/init.lua:1268: '=' expected near 'playerId' stack traceback: [C]: at 0x004f1d20 [C]: in function 'dofile' data/modules/scripts/gamestore/gamestore.lua:9: in main chunk [Warning - Event::checkScript] Can not load script: scripts/gamestore/gamestore.lua Lua Script Error: [Test Interface] data/modules/scripts/gamestore/gamestore.lua data/modules/scripts/gamestore/init.lua:1268: '=' expected near 'playerId' stack traceback: [C]: at 0x004f1d20 [C]: in function 'dofile' data/modules/scripts/gamestore/gamestore.lua:9: in main chunk [Warning - Event::checkScript] Can not load script: scripts/gamestore/gamestore.lua Lua Script Error: [Test Interface] data/modules/scripts/gamestore/gamestore.lua data/modules/scripts/gamestore/init.lua:1268: '=' expected near 'playerId' stack traceback: [C]: at 0x004f1d20 [C]: in function 'dofile' data/modules/scripts/gamestore/gamestore.lua:9: in main chunk [Warning - Event::checkScript] Can not load script: scripts/gamestore/gamestore.lua Lua Script Error: [Test Interface] data/modules/scripts/gamestore/gamestore.lua data/modules/scripts/gamestore/init.lua:1268: '=' expected near 'playerId' stack traceback: [C]: at 0x004f1d20 [C]: in function 'dofile' data/modules/scripts/gamestore/gamestore.lua:9: in main chunk [Warning - Event::checkScript] Can not load script: scripts/gamestore/gamestore.lua Lua Script Error: [Test Interface] data/modules/scripts/gamestore/gamestore.lua data/modules/scripts/gamestore/init.lua:1268: '=' expected near 'playerId' stack traceback: [C]: at 0x004f1d20 [C]: in function 'dofile' data/modules/scripts/gamestore/gamestore.lua:9: in main chunk [Warning - Event::checkScript] Can not load script: scripts/gamestore/gamestore.lua Lua Script Error: [Test Interface] data/modules/scripts/gamestore/gamestore.lua data/modules/scripts/gamestore/init.lua:1268: '=' expected near 'playerId' stack traceback: [C]: at 0x004f1d20 [C]: in function 'dofile' data/modules/scripts/gamestore/gamestore.lua:9: in main chunk [Warning - Event::checkScript] Can not load script: scripts/gamestore/gamestore.lua Lua Script Error: [Test Interface] data/modules/scripts/gamestore/gamestore.lua data/modules/scripts/gamestore/init.lua:1268: '=' expected near 'playerId' stack traceback: [C]: at 0x004f1d20 [C]: in function 'dofile' data/modules/scripts/gamestore/gamestore.lua:9: in main chunk [Warning - Event::checkScript] Can not load script: scripts/gamestore/gamestore.lua Reparei que nessa parte: local playerId = player:getId() local playerGuid = player:getGuid() local accountId = player:getAccountId( O local, ficaram com a cor azul no seu código, mas aqui no meu arquivo.lua só ficou 2 em azul. Tem algo a ver? *OBS: foi bem a linha que marcou error local playerId = player:getId() Editado Fevereiro 17, 2020 5 anos por dougotserv (veja o histórico de edições)
Postado Fevereiro 17, 2020 5 anos Me manda seu init.lua e gamestore.lua para eu dar uma olhada por favor
Postado Fevereiro 17, 2020 5 anos Autor init.luaUnavailable gamestore.luaUnavailable Editado Fevereiro 17, 2020 5 anos por dougotserv (veja o histórico de edições)
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.