
Histórico de Curtidas
-
Pedriinz recebeu reputação de DiigooMix em [PESQUISA] Como se prevenir das disputas no PagSeguro?Na maioria dos caso isso resolve.
Coloque em seus termos, que você não está vendendo nada, e sim gratificando a pessoa pelo ato de doação ao seu servidor e que a partir do momento que ela confirma os termos, ela assume que ao ser feito a doacao o ela perde o direito de disputas ou reembolso. Eu fiz isso e resolveu 98%.
LEMBRE-SE: Nunca coloque que você vende algo e SIM gratifica os jogadores com algo simbólico. Ou seja que você entende a doação como uma mão de via dupla.
-
Pedriinz recebeu reputação de L3K0T em Auto Loot Sytem for TFS 1.3 + revscriptsDepois de milhões de anos sem programar porcaria nenhuma... Eu desenvolvi este sistema como um método de estudo. (C++)
Este sistema foi inspirado no Auto Loot System por @psychonaut. (OTland)
Criei o mesmo na versão mais recente do tfs.
Auto Loot System for TFS 1.3
Como funciona?
Simples, quando você mata um monstro e abre o corpo (você precisa clicar no corpo), os itens vão para o seu personagem.
Instalando
em actions.cpp, encontre:
if (corpseOwner != 0 && !player->canOpenCorpse(corpseOwner)) { return RETURNVALUE_YOUARENOTTHEOWNER; } e mude isso para:
if (corpseOwner != 0 && !player->canOpenCorpse(corpseOwner)) { return RETURNVALUE_YOUARENOTTHEOWNER; } else { if (player->canOpenCorpse(corpseOwner) && player->autoLootList.size() != 0) { if (player->getCapacity() > 100 * 100) { //Minimum of Capacity for autoloot works. (100 CAP) for (Item* item : container->getItemList()) { if (player->getItemFromAutoLoot(item->getID())) { std::ostringstream msgAutoLoot; msgAutoLoot << "You looted a " << item->getItemCount() << "x " << item->getName() << "."; g_game.internalMoveItem(container, player, CONST_SLOT_WHEREEVER, item, item->getItemCount(), nullptr); player->sendTextMessage(MESSAGE_INFO_DESCR, msgAutoLoot.str()); } } } else { player->sendTextMessage(MESSAGE_INFO_DESCR, "Sorry, you don't have enough capacity to use auto loot, so it has been disabled. (100+ capacity is required)"); } } } em player.h, abaixo de:
std::unordered_set<uint32_t> VIPList; adicione isso:
std::set<uint32_t> autoLootList; ainda em player.h encontre:
bool hasLearnedInstantSpell(const std::string& spellName) const; adicione em baixo:
void addItemToAutoLoot(uint16_t itemId); void removeItemFromAutoLoot(uint16_t itemId); bool getItemFromAutoLoot(uint16_t itemId); em player.cpp no final do arquivo, adicione:
void Player::addItemToAutoLoot(uint16_t itemId) { autoLootList.insert(itemId); } void Player::removeItemFromAutoLoot(uint16_t itemId) { autoLootList.erase(itemId); } bool Player::getItemFromAutoLoot(const uint16_t itemId) { return autoLootList.find(itemId) != autoLootList.end(); } em luascript.cpp encontre:
registerMethod("Player", "getFightMode", LuaScriptInterface::luaPlayerGetFightMode); e adicione em baixo:
registerMethod("Player", "addItemToAutoLoot", LuaScriptInterface::luaPlayerAddItemToAutoLoot); registerMethod("Player", "removeItemFromAutoLoot", LuaScriptInterface::luaPlayerRemoveItemFromAutoLoot); registerMethod("Player", "getItemFromAutoLoot", LuaScriptInterface::luaPlayerGetItemFromAutoLoot); registerMethod("Player", "getAutoLootList", LuaScriptInterface::luaPlayerGetAutoLootList); ainda em luascript.cpp encontre essa função:
int LuaScriptInterface::luaPlayerGetFightMode(lua_State* L) { // player:getFightMode() Player* player = getUserdata<Player>(L, 1); if (player) { lua_pushnumber(L, player->fightMode); } else { lua_pushnil(L); } return 1; }
abaixo dela, adicione:
int LuaScriptInterface::luaPlayerAddItemToAutoLoot(lua_State* L) { // player:addItemToAutoLoot(itemId) Player* player = getUserdata<Player>(L, 1); if (!player) { lua_pushnil(L); return 1; } uint16_t itemId; if (isNumber(L, 2)) { itemId = getNumber<uint16_t>(L, 2); } else { itemId = Item::items.getItemIdByName(getString(L, 2)); if (itemId == 0) { lua_pushnil(L); return 1; } } player->addItemToAutoLoot(itemId); pushBoolean(L, true); return 1; } int LuaScriptInterface::luaPlayerRemoveItemFromAutoLoot(lua_State* L) { // player:removeItemFromAutoLoot(itemId) Player* player = getUserdata<Player>(L, 1); if (!player) { lua_pushnil(L); return 1; } uint16_t itemId; if (isNumber(L, 2)) { itemId = getNumber<uint16_t>(L, 2); } else { itemId = Item::items.getItemIdByName(getString(L, 2)); if (itemId == 0) { lua_pushnil(L); return 1; } } player->removeItemFromAutoLoot(itemId); pushBoolean(L, true); return 1; } int LuaScriptInterface::luaPlayerGetItemFromAutoLoot(lua_State* L) { // player:getItemFromAutoLoot(itemId) Player* player = getUserdata<Player>(L, 1); if (!player) { lua_pushnil(L); return 1; } uint16_t itemId; if (isNumber(L, 2)) { itemId = getNumber<uint16_t>(L, 2); } else { itemId = Item::items.getItemIdByName(getString(L, 2)); if (itemId == 0) { lua_pushnil(L); return 1; } } if (player->getItemFromAutoLoot(itemId)) { pushBoolean(L, true); } else { pushBoolean(L, false); } return 1; } int LuaScriptInterface::luaPlayerGetAutoLootList(lua_State* L) { // player:getAutoLootList() Player* player = getUserdata<Player>(L, 1); if (player) { std::set<uint32_t> value = player->autoLootList; if (value.size() == 0) { lua_pushnil(L); return 1; } int index = 0; lua_createtable(L, value.size(), 0); for(auto i : value) { lua_pushnumber(L, i); lua_rawseti(L, -2, ++index); } } else { lua_pushnil(L); } return 1; }
em luascript.h encontre:
static int luaPlayerGetFightMode(lua_State* L);
adicione a baixo:
static int luaPlayerAddItemToAutoLoot(lua_State* L); static int luaPlayerRemoveItemFromAutoLoot(lua_State* L); static int luaPlayerGetItemFromAutoLoot(lua_State* L); static int luaPlayerGetAutoLootList(lua_State* L);
em iologindata.cpp encontre:
//load storage map query.str(std::string()); query << "SELECT `key`, `value` FROM `player_storage` WHERE `player_id` = " << player->getGUID(); if ((result = db.storeQuery(query.str()))) { do { player->addStorageValue(result->getNumber<uint32_t>("key"), result->getNumber<int32_t>("value"), true); } while (result->next()); }
e adicione em baixo:
query.str(std::string()); query << "SELECT `autoloot_list` FROM `player_autoloot` WHERE `player_id` = " << player->getGUID(); if ((result = db.storeQuery(query.str()))) { unsigned long lootlistSize; const char* autolootlist = result->getStream("autoloot_list", lootlistSize); PropStream propStreamList; propStreamList.init(autolootlist, lootlistSize); int16_t value; int16_t item = propStreamList.read<int16_t>(value); while (item) { player->addItemToAutoLoot(value); item = propStreamList.read<int16_t>(value); } }
acima de:
//save inbox items adicione:
query.str(std::string()); query << "DELETE FROM `player_autoloot` WHERE `player_id` = " << player->getGUID(); if (!db.executeQuery(query.str())) { return false; } PropWriteStream propWriteStreamAutoLoot; for (auto i : player->autoLootList) { propWriteStreamAutoLoot.write<uint16_t>(i); } size_t lootlistSize; const char* autolootlist = propWriteStreamAutoLoot.getStream(lootlistSize); query.str(std::string()); DBInsert autolootQuery("INSERT INTO `player_autoloot` (`player_id`, `autoloot_list`) VALUES "); query << player->getGUID() << ',' << db.escapeBlob(autolootlist, lootlistSize); if (!autolootQuery.addRow(query)) { return false; } if (!autolootQuery.execute()) { return false; }
em sua database, execute esta query
CREATE TABLE player_autoloot ( id int NOT NULL AUTO_INCREMENT, player_id int NOT NULL, autoloot_list blob, PRIMARY KEY (id) );
agora vá em data/scripts/talkactions e crie esse arquivo LUA
autoloot.lua
local talk = TalkAction("!autoloot") function talk.onSay(player, words, param) local i = player:getAutoLootList() local cache = "Check your loot list: " local split = param:split(",") local action = split[1] if param == "list" then if i then for _, item in ipairs(i) do cache = cache .. (ItemType(item)):getName() .. ", " end else player:sendTextMessage(MESSAGE_INFO_DESCR, "Your list is empty! Add some item and try again.") return false end player:sendTextMessage(MESSAGE_INFO_DESCR, cache:sub(1, -3)) return false end if action == "add" then local item = split[2]:gsub("%s+", "", 1) local itemType = ItemType(item) if itemType:getId() == 0 then itemType = ItemType(tonumber(item)) if itemType:getName() == '' then player:sendCancelMessage("There is no item with that id or name.") return false end end if player:getItemFromAutoLoot(itemType:getId()) then player:sendCancelMessage("You're already autolooting this item.") return false end player:addItemToAutoLoot(itemType:getId()) player:sendTextMessage(MESSAGE_INFO_DESCR, "You're now auto looting " .. itemType:getName()) return false elseif action == "remove" then local item = split[2]:gsub("%s+", "", 1) local itemType = ItemType(item) if itemType:getId() == 0 then itemType = ItemType(tonumber(item)) if itemType:getName() == '' then player:sendCancelMessage("There is no item with that id or name.") return false end end if player:getItemFromAutoLoot(itemType:getId()) then player:removeItemFromAutoLoot(itemType:getId()) player:sendTextMessage(MESSAGE_INFO_DESCR, "You removed the " .. itemType:getName() .. " from your loot list.") else player:sendCancelMessage("This item does not exist in your loot list.") end return false end player:sendTextMessage(MESSAGE_EVENT_ORANGE, "Auto Loot commands (items are automatically moved to your bp if you open monster corpse):"..'\n'.."!addloot add, nameItem - add item to auto loot by name"..'\n'.."!autoloot remove, itemName - remove item from auto loot by name"..'\n'.."!autoloot list - list your current auto loot items") return false end talk:separator(" ") talk:register()
É isso, espero que gostem do sisteminha
Se você encontrar algum bug, deixe-me saber.
Falta fazer:
Optimizar a mensagem de loot.
Adicionar ModalWindow.
Cheers~
-
Pedriinz recebeu reputação de ITALOx em Auto Loot Sytem for TFS 1.3 + revscriptsDepois de milhões de anos sem programar porcaria nenhuma... Eu desenvolvi este sistema como um método de estudo. (C++)
Este sistema foi inspirado no Auto Loot System por @psychonaut. (OTland)
Criei o mesmo na versão mais recente do tfs.
Auto Loot System for TFS 1.3
Como funciona?
Simples, quando você mata um monstro e abre o corpo (você precisa clicar no corpo), os itens vão para o seu personagem.
Instalando
em actions.cpp, encontre:
if (corpseOwner != 0 && !player->canOpenCorpse(corpseOwner)) { return RETURNVALUE_YOUARENOTTHEOWNER; } e mude isso para:
if (corpseOwner != 0 && !player->canOpenCorpse(corpseOwner)) { return RETURNVALUE_YOUARENOTTHEOWNER; } else { if (player->canOpenCorpse(corpseOwner) && player->autoLootList.size() != 0) { if (player->getCapacity() > 100 * 100) { //Minimum of Capacity for autoloot works. (100 CAP) for (Item* item : container->getItemList()) { if (player->getItemFromAutoLoot(item->getID())) { std::ostringstream msgAutoLoot; msgAutoLoot << "You looted a " << item->getItemCount() << "x " << item->getName() << "."; g_game.internalMoveItem(container, player, CONST_SLOT_WHEREEVER, item, item->getItemCount(), nullptr); player->sendTextMessage(MESSAGE_INFO_DESCR, msgAutoLoot.str()); } } } else { player->sendTextMessage(MESSAGE_INFO_DESCR, "Sorry, you don't have enough capacity to use auto loot, so it has been disabled. (100+ capacity is required)"); } } } em player.h, abaixo de:
std::unordered_set<uint32_t> VIPList; adicione isso:
std::set<uint32_t> autoLootList; ainda em player.h encontre:
bool hasLearnedInstantSpell(const std::string& spellName) const; adicione em baixo:
void addItemToAutoLoot(uint16_t itemId); void removeItemFromAutoLoot(uint16_t itemId); bool getItemFromAutoLoot(uint16_t itemId); em player.cpp no final do arquivo, adicione:
void Player::addItemToAutoLoot(uint16_t itemId) { autoLootList.insert(itemId); } void Player::removeItemFromAutoLoot(uint16_t itemId) { autoLootList.erase(itemId); } bool Player::getItemFromAutoLoot(const uint16_t itemId) { return autoLootList.find(itemId) != autoLootList.end(); } em luascript.cpp encontre:
registerMethod("Player", "getFightMode", LuaScriptInterface::luaPlayerGetFightMode); e adicione em baixo:
registerMethod("Player", "addItemToAutoLoot", LuaScriptInterface::luaPlayerAddItemToAutoLoot); registerMethod("Player", "removeItemFromAutoLoot", LuaScriptInterface::luaPlayerRemoveItemFromAutoLoot); registerMethod("Player", "getItemFromAutoLoot", LuaScriptInterface::luaPlayerGetItemFromAutoLoot); registerMethod("Player", "getAutoLootList", LuaScriptInterface::luaPlayerGetAutoLootList); ainda em luascript.cpp encontre essa função:
int LuaScriptInterface::luaPlayerGetFightMode(lua_State* L) { // player:getFightMode() Player* player = getUserdata<Player>(L, 1); if (player) { lua_pushnumber(L, player->fightMode); } else { lua_pushnil(L); } return 1; }
abaixo dela, adicione:
int LuaScriptInterface::luaPlayerAddItemToAutoLoot(lua_State* L) { // player:addItemToAutoLoot(itemId) Player* player = getUserdata<Player>(L, 1); if (!player) { lua_pushnil(L); return 1; } uint16_t itemId; if (isNumber(L, 2)) { itemId = getNumber<uint16_t>(L, 2); } else { itemId = Item::items.getItemIdByName(getString(L, 2)); if (itemId == 0) { lua_pushnil(L); return 1; } } player->addItemToAutoLoot(itemId); pushBoolean(L, true); return 1; } int LuaScriptInterface::luaPlayerRemoveItemFromAutoLoot(lua_State* L) { // player:removeItemFromAutoLoot(itemId) Player* player = getUserdata<Player>(L, 1); if (!player) { lua_pushnil(L); return 1; } uint16_t itemId; if (isNumber(L, 2)) { itemId = getNumber<uint16_t>(L, 2); } else { itemId = Item::items.getItemIdByName(getString(L, 2)); if (itemId == 0) { lua_pushnil(L); return 1; } } player->removeItemFromAutoLoot(itemId); pushBoolean(L, true); return 1; } int LuaScriptInterface::luaPlayerGetItemFromAutoLoot(lua_State* L) { // player:getItemFromAutoLoot(itemId) Player* player = getUserdata<Player>(L, 1); if (!player) { lua_pushnil(L); return 1; } uint16_t itemId; if (isNumber(L, 2)) { itemId = getNumber<uint16_t>(L, 2); } else { itemId = Item::items.getItemIdByName(getString(L, 2)); if (itemId == 0) { lua_pushnil(L); return 1; } } if (player->getItemFromAutoLoot(itemId)) { pushBoolean(L, true); } else { pushBoolean(L, false); } return 1; } int LuaScriptInterface::luaPlayerGetAutoLootList(lua_State* L) { // player:getAutoLootList() Player* player = getUserdata<Player>(L, 1); if (player) { std::set<uint32_t> value = player->autoLootList; if (value.size() == 0) { lua_pushnil(L); return 1; } int index = 0; lua_createtable(L, value.size(), 0); for(auto i : value) { lua_pushnumber(L, i); lua_rawseti(L, -2, ++index); } } else { lua_pushnil(L); } return 1; }
em luascript.h encontre:
static int luaPlayerGetFightMode(lua_State* L);
adicione a baixo:
static int luaPlayerAddItemToAutoLoot(lua_State* L); static int luaPlayerRemoveItemFromAutoLoot(lua_State* L); static int luaPlayerGetItemFromAutoLoot(lua_State* L); static int luaPlayerGetAutoLootList(lua_State* L);
em iologindata.cpp encontre:
//load storage map query.str(std::string()); query << "SELECT `key`, `value` FROM `player_storage` WHERE `player_id` = " << player->getGUID(); if ((result = db.storeQuery(query.str()))) { do { player->addStorageValue(result->getNumber<uint32_t>("key"), result->getNumber<int32_t>("value"), true); } while (result->next()); }
e adicione em baixo:
query.str(std::string()); query << "SELECT `autoloot_list` FROM `player_autoloot` WHERE `player_id` = " << player->getGUID(); if ((result = db.storeQuery(query.str()))) { unsigned long lootlistSize; const char* autolootlist = result->getStream("autoloot_list", lootlistSize); PropStream propStreamList; propStreamList.init(autolootlist, lootlistSize); int16_t value; int16_t item = propStreamList.read<int16_t>(value); while (item) { player->addItemToAutoLoot(value); item = propStreamList.read<int16_t>(value); } }
acima de:
//save inbox items adicione:
query.str(std::string()); query << "DELETE FROM `player_autoloot` WHERE `player_id` = " << player->getGUID(); if (!db.executeQuery(query.str())) { return false; } PropWriteStream propWriteStreamAutoLoot; for (auto i : player->autoLootList) { propWriteStreamAutoLoot.write<uint16_t>(i); } size_t lootlistSize; const char* autolootlist = propWriteStreamAutoLoot.getStream(lootlistSize); query.str(std::string()); DBInsert autolootQuery("INSERT INTO `player_autoloot` (`player_id`, `autoloot_list`) VALUES "); query << player->getGUID() << ',' << db.escapeBlob(autolootlist, lootlistSize); if (!autolootQuery.addRow(query)) { return false; } if (!autolootQuery.execute()) { return false; }
em sua database, execute esta query
CREATE TABLE player_autoloot ( id int NOT NULL AUTO_INCREMENT, player_id int NOT NULL, autoloot_list blob, PRIMARY KEY (id) );
agora vá em data/scripts/talkactions e crie esse arquivo LUA
autoloot.lua
local talk = TalkAction("!autoloot") function talk.onSay(player, words, param) local i = player:getAutoLootList() local cache = "Check your loot list: " local split = param:split(",") local action = split[1] if param == "list" then if i then for _, item in ipairs(i) do cache = cache .. (ItemType(item)):getName() .. ", " end else player:sendTextMessage(MESSAGE_INFO_DESCR, "Your list is empty! Add some item and try again.") return false end player:sendTextMessage(MESSAGE_INFO_DESCR, cache:sub(1, -3)) return false end if action == "add" then local item = split[2]:gsub("%s+", "", 1) local itemType = ItemType(item) if itemType:getId() == 0 then itemType = ItemType(tonumber(item)) if itemType:getName() == '' then player:sendCancelMessage("There is no item with that id or name.") return false end end if player:getItemFromAutoLoot(itemType:getId()) then player:sendCancelMessage("You're already autolooting this item.") return false end player:addItemToAutoLoot(itemType:getId()) player:sendTextMessage(MESSAGE_INFO_DESCR, "You're now auto looting " .. itemType:getName()) return false elseif action == "remove" then local item = split[2]:gsub("%s+", "", 1) local itemType = ItemType(item) if itemType:getId() == 0 then itemType = ItemType(tonumber(item)) if itemType:getName() == '' then player:sendCancelMessage("There is no item with that id or name.") return false end end if player:getItemFromAutoLoot(itemType:getId()) then player:removeItemFromAutoLoot(itemType:getId()) player:sendTextMessage(MESSAGE_INFO_DESCR, "You removed the " .. itemType:getName() .. " from your loot list.") else player:sendCancelMessage("This item does not exist in your loot list.") end return false end player:sendTextMessage(MESSAGE_EVENT_ORANGE, "Auto Loot commands (items are automatically moved to your bp if you open monster corpse):"..'\n'.."!addloot add, nameItem - add item to auto loot by name"..'\n'.."!autoloot remove, itemName - remove item from auto loot by name"..'\n'.."!autoloot list - list your current auto loot items") return false end talk:separator(" ") talk:register()
É isso, espero que gostem do sisteminha
Se você encontrar algum bug, deixe-me saber.
Falta fazer:
Optimizar a mensagem de loot.
Adicionar ModalWindow.
Cheers~
-
Pedriinz recebeu reputação de Serpente em Auto Loot Sytem for TFS 1.3 + revscriptsDepois de milhões de anos sem programar porcaria nenhuma... Eu desenvolvi este sistema como um método de estudo. (C++)
Este sistema foi inspirado no Auto Loot System por @psychonaut. (OTland)
Criei o mesmo na versão mais recente do tfs.
Auto Loot System for TFS 1.3
Como funciona?
Simples, quando você mata um monstro e abre o corpo (você precisa clicar no corpo), os itens vão para o seu personagem.
Instalando
em actions.cpp, encontre:
if (corpseOwner != 0 && !player->canOpenCorpse(corpseOwner)) { return RETURNVALUE_YOUARENOTTHEOWNER; } e mude isso para:
if (corpseOwner != 0 && !player->canOpenCorpse(corpseOwner)) { return RETURNVALUE_YOUARENOTTHEOWNER; } else { if (player->canOpenCorpse(corpseOwner) && player->autoLootList.size() != 0) { if (player->getCapacity() > 100 * 100) { //Minimum of Capacity for autoloot works. (100 CAP) for (Item* item : container->getItemList()) { if (player->getItemFromAutoLoot(item->getID())) { std::ostringstream msgAutoLoot; msgAutoLoot << "You looted a " << item->getItemCount() << "x " << item->getName() << "."; g_game.internalMoveItem(container, player, CONST_SLOT_WHEREEVER, item, item->getItemCount(), nullptr); player->sendTextMessage(MESSAGE_INFO_DESCR, msgAutoLoot.str()); } } } else { player->sendTextMessage(MESSAGE_INFO_DESCR, "Sorry, you don't have enough capacity to use auto loot, so it has been disabled. (100+ capacity is required)"); } } } em player.h, abaixo de:
std::unordered_set<uint32_t> VIPList; adicione isso:
std::set<uint32_t> autoLootList; ainda em player.h encontre:
bool hasLearnedInstantSpell(const std::string& spellName) const; adicione em baixo:
void addItemToAutoLoot(uint16_t itemId); void removeItemFromAutoLoot(uint16_t itemId); bool getItemFromAutoLoot(uint16_t itemId); em player.cpp no final do arquivo, adicione:
void Player::addItemToAutoLoot(uint16_t itemId) { autoLootList.insert(itemId); } void Player::removeItemFromAutoLoot(uint16_t itemId) { autoLootList.erase(itemId); } bool Player::getItemFromAutoLoot(const uint16_t itemId) { return autoLootList.find(itemId) != autoLootList.end(); } em luascript.cpp encontre:
registerMethod("Player", "getFightMode", LuaScriptInterface::luaPlayerGetFightMode); e adicione em baixo:
registerMethod("Player", "addItemToAutoLoot", LuaScriptInterface::luaPlayerAddItemToAutoLoot); registerMethod("Player", "removeItemFromAutoLoot", LuaScriptInterface::luaPlayerRemoveItemFromAutoLoot); registerMethod("Player", "getItemFromAutoLoot", LuaScriptInterface::luaPlayerGetItemFromAutoLoot); registerMethod("Player", "getAutoLootList", LuaScriptInterface::luaPlayerGetAutoLootList); ainda em luascript.cpp encontre essa função:
int LuaScriptInterface::luaPlayerGetFightMode(lua_State* L) { // player:getFightMode() Player* player = getUserdata<Player>(L, 1); if (player) { lua_pushnumber(L, player->fightMode); } else { lua_pushnil(L); } return 1; }
abaixo dela, adicione:
int LuaScriptInterface::luaPlayerAddItemToAutoLoot(lua_State* L) { // player:addItemToAutoLoot(itemId) Player* player = getUserdata<Player>(L, 1); if (!player) { lua_pushnil(L); return 1; } uint16_t itemId; if (isNumber(L, 2)) { itemId = getNumber<uint16_t>(L, 2); } else { itemId = Item::items.getItemIdByName(getString(L, 2)); if (itemId == 0) { lua_pushnil(L); return 1; } } player->addItemToAutoLoot(itemId); pushBoolean(L, true); return 1; } int LuaScriptInterface::luaPlayerRemoveItemFromAutoLoot(lua_State* L) { // player:removeItemFromAutoLoot(itemId) Player* player = getUserdata<Player>(L, 1); if (!player) { lua_pushnil(L); return 1; } uint16_t itemId; if (isNumber(L, 2)) { itemId = getNumber<uint16_t>(L, 2); } else { itemId = Item::items.getItemIdByName(getString(L, 2)); if (itemId == 0) { lua_pushnil(L); return 1; } } player->removeItemFromAutoLoot(itemId); pushBoolean(L, true); return 1; } int LuaScriptInterface::luaPlayerGetItemFromAutoLoot(lua_State* L) { // player:getItemFromAutoLoot(itemId) Player* player = getUserdata<Player>(L, 1); if (!player) { lua_pushnil(L); return 1; } uint16_t itemId; if (isNumber(L, 2)) { itemId = getNumber<uint16_t>(L, 2); } else { itemId = Item::items.getItemIdByName(getString(L, 2)); if (itemId == 0) { lua_pushnil(L); return 1; } } if (player->getItemFromAutoLoot(itemId)) { pushBoolean(L, true); } else { pushBoolean(L, false); } return 1; } int LuaScriptInterface::luaPlayerGetAutoLootList(lua_State* L) { // player:getAutoLootList() Player* player = getUserdata<Player>(L, 1); if (player) { std::set<uint32_t> value = player->autoLootList; if (value.size() == 0) { lua_pushnil(L); return 1; } int index = 0; lua_createtable(L, value.size(), 0); for(auto i : value) { lua_pushnumber(L, i); lua_rawseti(L, -2, ++index); } } else { lua_pushnil(L); } return 1; }
em luascript.h encontre:
static int luaPlayerGetFightMode(lua_State* L);
adicione a baixo:
static int luaPlayerAddItemToAutoLoot(lua_State* L); static int luaPlayerRemoveItemFromAutoLoot(lua_State* L); static int luaPlayerGetItemFromAutoLoot(lua_State* L); static int luaPlayerGetAutoLootList(lua_State* L);
em iologindata.cpp encontre:
//load storage map query.str(std::string()); query << "SELECT `key`, `value` FROM `player_storage` WHERE `player_id` = " << player->getGUID(); if ((result = db.storeQuery(query.str()))) { do { player->addStorageValue(result->getNumber<uint32_t>("key"), result->getNumber<int32_t>("value"), true); } while (result->next()); }
e adicione em baixo:
query.str(std::string()); query << "SELECT `autoloot_list` FROM `player_autoloot` WHERE `player_id` = " << player->getGUID(); if ((result = db.storeQuery(query.str()))) { unsigned long lootlistSize; const char* autolootlist = result->getStream("autoloot_list", lootlistSize); PropStream propStreamList; propStreamList.init(autolootlist, lootlistSize); int16_t value; int16_t item = propStreamList.read<int16_t>(value); while (item) { player->addItemToAutoLoot(value); item = propStreamList.read<int16_t>(value); } }
acima de:
//save inbox items adicione:
query.str(std::string()); query << "DELETE FROM `player_autoloot` WHERE `player_id` = " << player->getGUID(); if (!db.executeQuery(query.str())) { return false; } PropWriteStream propWriteStreamAutoLoot; for (auto i : player->autoLootList) { propWriteStreamAutoLoot.write<uint16_t>(i); } size_t lootlistSize; const char* autolootlist = propWriteStreamAutoLoot.getStream(lootlistSize); query.str(std::string()); DBInsert autolootQuery("INSERT INTO `player_autoloot` (`player_id`, `autoloot_list`) VALUES "); query << player->getGUID() << ',' << db.escapeBlob(autolootlist, lootlistSize); if (!autolootQuery.addRow(query)) { return false; } if (!autolootQuery.execute()) { return false; }
em sua database, execute esta query
CREATE TABLE player_autoloot ( id int NOT NULL AUTO_INCREMENT, player_id int NOT NULL, autoloot_list blob, PRIMARY KEY (id) );
agora vá em data/scripts/talkactions e crie esse arquivo LUA
autoloot.lua
local talk = TalkAction("!autoloot") function talk.onSay(player, words, param) local i = player:getAutoLootList() local cache = "Check your loot list: " local split = param:split(",") local action = split[1] if param == "list" then if i then for _, item in ipairs(i) do cache = cache .. (ItemType(item)):getName() .. ", " end else player:sendTextMessage(MESSAGE_INFO_DESCR, "Your list is empty! Add some item and try again.") return false end player:sendTextMessage(MESSAGE_INFO_DESCR, cache:sub(1, -3)) return false end if action == "add" then local item = split[2]:gsub("%s+", "", 1) local itemType = ItemType(item) if itemType:getId() == 0 then itemType = ItemType(tonumber(item)) if itemType:getName() == '' then player:sendCancelMessage("There is no item with that id or name.") return false end end if player:getItemFromAutoLoot(itemType:getId()) then player:sendCancelMessage("You're already autolooting this item.") return false end player:addItemToAutoLoot(itemType:getId()) player:sendTextMessage(MESSAGE_INFO_DESCR, "You're now auto looting " .. itemType:getName()) return false elseif action == "remove" then local item = split[2]:gsub("%s+", "", 1) local itemType = ItemType(item) if itemType:getId() == 0 then itemType = ItemType(tonumber(item)) if itemType:getName() == '' then player:sendCancelMessage("There is no item with that id or name.") return false end end if player:getItemFromAutoLoot(itemType:getId()) then player:removeItemFromAutoLoot(itemType:getId()) player:sendTextMessage(MESSAGE_INFO_DESCR, "You removed the " .. itemType:getName() .. " from your loot list.") else player:sendCancelMessage("This item does not exist in your loot list.") end return false end player:sendTextMessage(MESSAGE_EVENT_ORANGE, "Auto Loot commands (items are automatically moved to your bp if you open monster corpse):"..'\n'.."!addloot add, nameItem - add item to auto loot by name"..'\n'.."!autoloot remove, itemName - remove item from auto loot by name"..'\n'.."!autoloot list - list your current auto loot items") return false end talk:separator(" ") talk:register()
É isso, espero que gostem do sisteminha
Se você encontrar algum bug, deixe-me saber.
Falta fazer:
Optimizar a mensagem de loot.
Adicionar ModalWindow.
Cheers~
-
Pedriinz recebeu reputação de Wakon em Auto Loot Sytem for TFS 1.3 + revscriptsDepois de milhões de anos sem programar porcaria nenhuma... Eu desenvolvi este sistema como um método de estudo. (C++)
Este sistema foi inspirado no Auto Loot System por @psychonaut. (OTland)
Criei o mesmo na versão mais recente do tfs.
Auto Loot System for TFS 1.3
Como funciona?
Simples, quando você mata um monstro e abre o corpo (você precisa clicar no corpo), os itens vão para o seu personagem.
Instalando
em actions.cpp, encontre:
if (corpseOwner != 0 && !player->canOpenCorpse(corpseOwner)) { return RETURNVALUE_YOUARENOTTHEOWNER; } e mude isso para:
if (corpseOwner != 0 && !player->canOpenCorpse(corpseOwner)) { return RETURNVALUE_YOUARENOTTHEOWNER; } else { if (player->canOpenCorpse(corpseOwner) && player->autoLootList.size() != 0) { if (player->getCapacity() > 100 * 100) { //Minimum of Capacity for autoloot works. (100 CAP) for (Item* item : container->getItemList()) { if (player->getItemFromAutoLoot(item->getID())) { std::ostringstream msgAutoLoot; msgAutoLoot << "You looted a " << item->getItemCount() << "x " << item->getName() << "."; g_game.internalMoveItem(container, player, CONST_SLOT_WHEREEVER, item, item->getItemCount(), nullptr); player->sendTextMessage(MESSAGE_INFO_DESCR, msgAutoLoot.str()); } } } else { player->sendTextMessage(MESSAGE_INFO_DESCR, "Sorry, you don't have enough capacity to use auto loot, so it has been disabled. (100+ capacity is required)"); } } } em player.h, abaixo de:
std::unordered_set<uint32_t> VIPList; adicione isso:
std::set<uint32_t> autoLootList; ainda em player.h encontre:
bool hasLearnedInstantSpell(const std::string& spellName) const; adicione em baixo:
void addItemToAutoLoot(uint16_t itemId); void removeItemFromAutoLoot(uint16_t itemId); bool getItemFromAutoLoot(uint16_t itemId); em player.cpp no final do arquivo, adicione:
void Player::addItemToAutoLoot(uint16_t itemId) { autoLootList.insert(itemId); } void Player::removeItemFromAutoLoot(uint16_t itemId) { autoLootList.erase(itemId); } bool Player::getItemFromAutoLoot(const uint16_t itemId) { return autoLootList.find(itemId) != autoLootList.end(); } em luascript.cpp encontre:
registerMethod("Player", "getFightMode", LuaScriptInterface::luaPlayerGetFightMode); e adicione em baixo:
registerMethod("Player", "addItemToAutoLoot", LuaScriptInterface::luaPlayerAddItemToAutoLoot); registerMethod("Player", "removeItemFromAutoLoot", LuaScriptInterface::luaPlayerRemoveItemFromAutoLoot); registerMethod("Player", "getItemFromAutoLoot", LuaScriptInterface::luaPlayerGetItemFromAutoLoot); registerMethod("Player", "getAutoLootList", LuaScriptInterface::luaPlayerGetAutoLootList); ainda em luascript.cpp encontre essa função:
int LuaScriptInterface::luaPlayerGetFightMode(lua_State* L) { // player:getFightMode() Player* player = getUserdata<Player>(L, 1); if (player) { lua_pushnumber(L, player->fightMode); } else { lua_pushnil(L); } return 1; }
abaixo dela, adicione:
int LuaScriptInterface::luaPlayerAddItemToAutoLoot(lua_State* L) { // player:addItemToAutoLoot(itemId) Player* player = getUserdata<Player>(L, 1); if (!player) { lua_pushnil(L); return 1; } uint16_t itemId; if (isNumber(L, 2)) { itemId = getNumber<uint16_t>(L, 2); } else { itemId = Item::items.getItemIdByName(getString(L, 2)); if (itemId == 0) { lua_pushnil(L); return 1; } } player->addItemToAutoLoot(itemId); pushBoolean(L, true); return 1; } int LuaScriptInterface::luaPlayerRemoveItemFromAutoLoot(lua_State* L) { // player:removeItemFromAutoLoot(itemId) Player* player = getUserdata<Player>(L, 1); if (!player) { lua_pushnil(L); return 1; } uint16_t itemId; if (isNumber(L, 2)) { itemId = getNumber<uint16_t>(L, 2); } else { itemId = Item::items.getItemIdByName(getString(L, 2)); if (itemId == 0) { lua_pushnil(L); return 1; } } player->removeItemFromAutoLoot(itemId); pushBoolean(L, true); return 1; } int LuaScriptInterface::luaPlayerGetItemFromAutoLoot(lua_State* L) { // player:getItemFromAutoLoot(itemId) Player* player = getUserdata<Player>(L, 1); if (!player) { lua_pushnil(L); return 1; } uint16_t itemId; if (isNumber(L, 2)) { itemId = getNumber<uint16_t>(L, 2); } else { itemId = Item::items.getItemIdByName(getString(L, 2)); if (itemId == 0) { lua_pushnil(L); return 1; } } if (player->getItemFromAutoLoot(itemId)) { pushBoolean(L, true); } else { pushBoolean(L, false); } return 1; } int LuaScriptInterface::luaPlayerGetAutoLootList(lua_State* L) { // player:getAutoLootList() Player* player = getUserdata<Player>(L, 1); if (player) { std::set<uint32_t> value = player->autoLootList; if (value.size() == 0) { lua_pushnil(L); return 1; } int index = 0; lua_createtable(L, value.size(), 0); for(auto i : value) { lua_pushnumber(L, i); lua_rawseti(L, -2, ++index); } } else { lua_pushnil(L); } return 1; }
em luascript.h encontre:
static int luaPlayerGetFightMode(lua_State* L);
adicione a baixo:
static int luaPlayerAddItemToAutoLoot(lua_State* L); static int luaPlayerRemoveItemFromAutoLoot(lua_State* L); static int luaPlayerGetItemFromAutoLoot(lua_State* L); static int luaPlayerGetAutoLootList(lua_State* L);
em iologindata.cpp encontre:
//load storage map query.str(std::string()); query << "SELECT `key`, `value` FROM `player_storage` WHERE `player_id` = " << player->getGUID(); if ((result = db.storeQuery(query.str()))) { do { player->addStorageValue(result->getNumber<uint32_t>("key"), result->getNumber<int32_t>("value"), true); } while (result->next()); }
e adicione em baixo:
query.str(std::string()); query << "SELECT `autoloot_list` FROM `player_autoloot` WHERE `player_id` = " << player->getGUID(); if ((result = db.storeQuery(query.str()))) { unsigned long lootlistSize; const char* autolootlist = result->getStream("autoloot_list", lootlistSize); PropStream propStreamList; propStreamList.init(autolootlist, lootlistSize); int16_t value; int16_t item = propStreamList.read<int16_t>(value); while (item) { player->addItemToAutoLoot(value); item = propStreamList.read<int16_t>(value); } }
acima de:
//save inbox items adicione:
query.str(std::string()); query << "DELETE FROM `player_autoloot` WHERE `player_id` = " << player->getGUID(); if (!db.executeQuery(query.str())) { return false; } PropWriteStream propWriteStreamAutoLoot; for (auto i : player->autoLootList) { propWriteStreamAutoLoot.write<uint16_t>(i); } size_t lootlistSize; const char* autolootlist = propWriteStreamAutoLoot.getStream(lootlistSize); query.str(std::string()); DBInsert autolootQuery("INSERT INTO `player_autoloot` (`player_id`, `autoloot_list`) VALUES "); query << player->getGUID() << ',' << db.escapeBlob(autolootlist, lootlistSize); if (!autolootQuery.addRow(query)) { return false; } if (!autolootQuery.execute()) { return false; }
em sua database, execute esta query
CREATE TABLE player_autoloot ( id int NOT NULL AUTO_INCREMENT, player_id int NOT NULL, autoloot_list blob, PRIMARY KEY (id) );
agora vá em data/scripts/talkactions e crie esse arquivo LUA
autoloot.lua
local talk = TalkAction("!autoloot") function talk.onSay(player, words, param) local i = player:getAutoLootList() local cache = "Check your loot list: " local split = param:split(",") local action = split[1] if param == "list" then if i then for _, item in ipairs(i) do cache = cache .. (ItemType(item)):getName() .. ", " end else player:sendTextMessage(MESSAGE_INFO_DESCR, "Your list is empty! Add some item and try again.") return false end player:sendTextMessage(MESSAGE_INFO_DESCR, cache:sub(1, -3)) return false end if action == "add" then local item = split[2]:gsub("%s+", "", 1) local itemType = ItemType(item) if itemType:getId() == 0 then itemType = ItemType(tonumber(item)) if itemType:getName() == '' then player:sendCancelMessage("There is no item with that id or name.") return false end end if player:getItemFromAutoLoot(itemType:getId()) then player:sendCancelMessage("You're already autolooting this item.") return false end player:addItemToAutoLoot(itemType:getId()) player:sendTextMessage(MESSAGE_INFO_DESCR, "You're now auto looting " .. itemType:getName()) return false elseif action == "remove" then local item = split[2]:gsub("%s+", "", 1) local itemType = ItemType(item) if itemType:getId() == 0 then itemType = ItemType(tonumber(item)) if itemType:getName() == '' then player:sendCancelMessage("There is no item with that id or name.") return false end end if player:getItemFromAutoLoot(itemType:getId()) then player:removeItemFromAutoLoot(itemType:getId()) player:sendTextMessage(MESSAGE_INFO_DESCR, "You removed the " .. itemType:getName() .. " from your loot list.") else player:sendCancelMessage("This item does not exist in your loot list.") end return false end player:sendTextMessage(MESSAGE_EVENT_ORANGE, "Auto Loot commands (items are automatically moved to your bp if you open monster corpse):"..'\n'.."!addloot add, nameItem - add item to auto loot by name"..'\n'.."!autoloot remove, itemName - remove item from auto loot by name"..'\n'.."!autoloot list - list your current auto loot items") return false end talk:separator(" ") talk:register()
É isso, espero que gostem do sisteminha
Se você encontrar algum bug, deixe-me saber.
Falta fazer:
Optimizar a mensagem de loot.
Adicionar ModalWindow.
Cheers~
-
Pedriinz recebeu reputação de d0gw4r em Auto Loot Sytem for TFS 1.3 + revscriptsDepois de milhões de anos sem programar porcaria nenhuma... Eu desenvolvi este sistema como um método de estudo. (C++)
Este sistema foi inspirado no Auto Loot System por @psychonaut. (OTland)
Criei o mesmo na versão mais recente do tfs.
Auto Loot System for TFS 1.3
Como funciona?
Simples, quando você mata um monstro e abre o corpo (você precisa clicar no corpo), os itens vão para o seu personagem.
Instalando
em actions.cpp, encontre:
if (corpseOwner != 0 && !player->canOpenCorpse(corpseOwner)) { return RETURNVALUE_YOUARENOTTHEOWNER; } e mude isso para:
if (corpseOwner != 0 && !player->canOpenCorpse(corpseOwner)) { return RETURNVALUE_YOUARENOTTHEOWNER; } else { if (player->canOpenCorpse(corpseOwner) && player->autoLootList.size() != 0) { if (player->getCapacity() > 100 * 100) { //Minimum of Capacity for autoloot works. (100 CAP) for (Item* item : container->getItemList()) { if (player->getItemFromAutoLoot(item->getID())) { std::ostringstream msgAutoLoot; msgAutoLoot << "You looted a " << item->getItemCount() << "x " << item->getName() << "."; g_game.internalMoveItem(container, player, CONST_SLOT_WHEREEVER, item, item->getItemCount(), nullptr); player->sendTextMessage(MESSAGE_INFO_DESCR, msgAutoLoot.str()); } } } else { player->sendTextMessage(MESSAGE_INFO_DESCR, "Sorry, you don't have enough capacity to use auto loot, so it has been disabled. (100+ capacity is required)"); } } } em player.h, abaixo de:
std::unordered_set<uint32_t> VIPList; adicione isso:
std::set<uint32_t> autoLootList; ainda em player.h encontre:
bool hasLearnedInstantSpell(const std::string& spellName) const; adicione em baixo:
void addItemToAutoLoot(uint16_t itemId); void removeItemFromAutoLoot(uint16_t itemId); bool getItemFromAutoLoot(uint16_t itemId); em player.cpp no final do arquivo, adicione:
void Player::addItemToAutoLoot(uint16_t itemId) { autoLootList.insert(itemId); } void Player::removeItemFromAutoLoot(uint16_t itemId) { autoLootList.erase(itemId); } bool Player::getItemFromAutoLoot(const uint16_t itemId) { return autoLootList.find(itemId) != autoLootList.end(); } em luascript.cpp encontre:
registerMethod("Player", "getFightMode", LuaScriptInterface::luaPlayerGetFightMode); e adicione em baixo:
registerMethod("Player", "addItemToAutoLoot", LuaScriptInterface::luaPlayerAddItemToAutoLoot); registerMethod("Player", "removeItemFromAutoLoot", LuaScriptInterface::luaPlayerRemoveItemFromAutoLoot); registerMethod("Player", "getItemFromAutoLoot", LuaScriptInterface::luaPlayerGetItemFromAutoLoot); registerMethod("Player", "getAutoLootList", LuaScriptInterface::luaPlayerGetAutoLootList); ainda em luascript.cpp encontre essa função:
int LuaScriptInterface::luaPlayerGetFightMode(lua_State* L) { // player:getFightMode() Player* player = getUserdata<Player>(L, 1); if (player) { lua_pushnumber(L, player->fightMode); } else { lua_pushnil(L); } return 1; }
abaixo dela, adicione:
int LuaScriptInterface::luaPlayerAddItemToAutoLoot(lua_State* L) { // player:addItemToAutoLoot(itemId) Player* player = getUserdata<Player>(L, 1); if (!player) { lua_pushnil(L); return 1; } uint16_t itemId; if (isNumber(L, 2)) { itemId = getNumber<uint16_t>(L, 2); } else { itemId = Item::items.getItemIdByName(getString(L, 2)); if (itemId == 0) { lua_pushnil(L); return 1; } } player->addItemToAutoLoot(itemId); pushBoolean(L, true); return 1; } int LuaScriptInterface::luaPlayerRemoveItemFromAutoLoot(lua_State* L) { // player:removeItemFromAutoLoot(itemId) Player* player = getUserdata<Player>(L, 1); if (!player) { lua_pushnil(L); return 1; } uint16_t itemId; if (isNumber(L, 2)) { itemId = getNumber<uint16_t>(L, 2); } else { itemId = Item::items.getItemIdByName(getString(L, 2)); if (itemId == 0) { lua_pushnil(L); return 1; } } player->removeItemFromAutoLoot(itemId); pushBoolean(L, true); return 1; } int LuaScriptInterface::luaPlayerGetItemFromAutoLoot(lua_State* L) { // player:getItemFromAutoLoot(itemId) Player* player = getUserdata<Player>(L, 1); if (!player) { lua_pushnil(L); return 1; } uint16_t itemId; if (isNumber(L, 2)) { itemId = getNumber<uint16_t>(L, 2); } else { itemId = Item::items.getItemIdByName(getString(L, 2)); if (itemId == 0) { lua_pushnil(L); return 1; } } if (player->getItemFromAutoLoot(itemId)) { pushBoolean(L, true); } else { pushBoolean(L, false); } return 1; } int LuaScriptInterface::luaPlayerGetAutoLootList(lua_State* L) { // player:getAutoLootList() Player* player = getUserdata<Player>(L, 1); if (player) { std::set<uint32_t> value = player->autoLootList; if (value.size() == 0) { lua_pushnil(L); return 1; } int index = 0; lua_createtable(L, value.size(), 0); for(auto i : value) { lua_pushnumber(L, i); lua_rawseti(L, -2, ++index); } } else { lua_pushnil(L); } return 1; }
em luascript.h encontre:
static int luaPlayerGetFightMode(lua_State* L);
adicione a baixo:
static int luaPlayerAddItemToAutoLoot(lua_State* L); static int luaPlayerRemoveItemFromAutoLoot(lua_State* L); static int luaPlayerGetItemFromAutoLoot(lua_State* L); static int luaPlayerGetAutoLootList(lua_State* L);
em iologindata.cpp encontre:
//load storage map query.str(std::string()); query << "SELECT `key`, `value` FROM `player_storage` WHERE `player_id` = " << player->getGUID(); if ((result = db.storeQuery(query.str()))) { do { player->addStorageValue(result->getNumber<uint32_t>("key"), result->getNumber<int32_t>("value"), true); } while (result->next()); }
e adicione em baixo:
query.str(std::string()); query << "SELECT `autoloot_list` FROM `player_autoloot` WHERE `player_id` = " << player->getGUID(); if ((result = db.storeQuery(query.str()))) { unsigned long lootlistSize; const char* autolootlist = result->getStream("autoloot_list", lootlistSize); PropStream propStreamList; propStreamList.init(autolootlist, lootlistSize); int16_t value; int16_t item = propStreamList.read<int16_t>(value); while (item) { player->addItemToAutoLoot(value); item = propStreamList.read<int16_t>(value); } }
acima de:
//save inbox items adicione:
query.str(std::string()); query << "DELETE FROM `player_autoloot` WHERE `player_id` = " << player->getGUID(); if (!db.executeQuery(query.str())) { return false; } PropWriteStream propWriteStreamAutoLoot; for (auto i : player->autoLootList) { propWriteStreamAutoLoot.write<uint16_t>(i); } size_t lootlistSize; const char* autolootlist = propWriteStreamAutoLoot.getStream(lootlistSize); query.str(std::string()); DBInsert autolootQuery("INSERT INTO `player_autoloot` (`player_id`, `autoloot_list`) VALUES "); query << player->getGUID() << ',' << db.escapeBlob(autolootlist, lootlistSize); if (!autolootQuery.addRow(query)) { return false; } if (!autolootQuery.execute()) { return false; }
em sua database, execute esta query
CREATE TABLE player_autoloot ( id int NOT NULL AUTO_INCREMENT, player_id int NOT NULL, autoloot_list blob, PRIMARY KEY (id) );
agora vá em data/scripts/talkactions e crie esse arquivo LUA
autoloot.lua
local talk = TalkAction("!autoloot") function talk.onSay(player, words, param) local i = player:getAutoLootList() local cache = "Check your loot list: " local split = param:split(",") local action = split[1] if param == "list" then if i then for _, item in ipairs(i) do cache = cache .. (ItemType(item)):getName() .. ", " end else player:sendTextMessage(MESSAGE_INFO_DESCR, "Your list is empty! Add some item and try again.") return false end player:sendTextMessage(MESSAGE_INFO_DESCR, cache:sub(1, -3)) return false end if action == "add" then local item = split[2]:gsub("%s+", "", 1) local itemType = ItemType(item) if itemType:getId() == 0 then itemType = ItemType(tonumber(item)) if itemType:getName() == '' then player:sendCancelMessage("There is no item with that id or name.") return false end end if player:getItemFromAutoLoot(itemType:getId()) then player:sendCancelMessage("You're already autolooting this item.") return false end player:addItemToAutoLoot(itemType:getId()) player:sendTextMessage(MESSAGE_INFO_DESCR, "You're now auto looting " .. itemType:getName()) return false elseif action == "remove" then local item = split[2]:gsub("%s+", "", 1) local itemType = ItemType(item) if itemType:getId() == 0 then itemType = ItemType(tonumber(item)) if itemType:getName() == '' then player:sendCancelMessage("There is no item with that id or name.") return false end end if player:getItemFromAutoLoot(itemType:getId()) then player:removeItemFromAutoLoot(itemType:getId()) player:sendTextMessage(MESSAGE_INFO_DESCR, "You removed the " .. itemType:getName() .. " from your loot list.") else player:sendCancelMessage("This item does not exist in your loot list.") end return false end player:sendTextMessage(MESSAGE_EVENT_ORANGE, "Auto Loot commands (items are automatically moved to your bp if you open monster corpse):"..'\n'.."!addloot add, nameItem - add item to auto loot by name"..'\n'.."!autoloot remove, itemName - remove item from auto loot by name"..'\n'.."!autoloot list - list your current auto loot items") return false end talk:separator(" ") talk:register()
É isso, espero que gostem do sisteminha
Se você encontrar algum bug, deixe-me saber.
Falta fazer:
Optimizar a mensagem de loot.
Adicionar ModalWindow.
Cheers~
-
Pedriinz recebeu reputação de d0gw4r em Auto Loot Sytem for TFS 1.3 + revscriptsYo!
Acabei de realizar algumas atualizações no código. As mudanças foram:
Junção de todos os scripts LUA em um só, resultando em um único comando para administrar o sistema de autoloot.
Exemplo:
!autoloot add, boots of haste !autoloot remove, boots of haste !autoloot list !autoloot
Também adicionei algumas verificações no script para que o mesmo não seja executado caso o personagem não tenha nenhum item adicionado a lista de autoloot. (optimização). Verificação de capacidade também está aqui agora, caso o personagem não tenha mais que 100 de cap uma mensagem é retornada para o player informando que não foi possível saquear aquele loot devida a mesma. (No futuro talvez eu deixe isso configurável pelo config.lua).
Cheers
-
Pedriinz deu reputação a luanluciano93 em [TFS 1.2] Função getCorpseOwner em Lualocal corpse = Tile(target:getPosition()):getTopDownItem() if not corpse or not corpse:isContainer() then return false end if corpse:getType():isCorpse() and corpse:getAttribute(ITEM_ATTRIBUTE_CORPSEOWNER) == player:getId() then return true end
-
Pedriinz recebeu reputação de luanluciano93 em Auto Loot Sytem for TFS 1.3 + revscriptsDepois de milhões de anos sem programar porcaria nenhuma... Eu desenvolvi este sistema como um método de estudo. (C++)
Este sistema foi inspirado no Auto Loot System por @psychonaut. (OTland)
Criei o mesmo na versão mais recente do tfs.
Auto Loot System for TFS 1.3
Como funciona?
Simples, quando você mata um monstro e abre o corpo (você precisa clicar no corpo), os itens vão para o seu personagem.
Instalando
em actions.cpp, encontre:
if (corpseOwner != 0 && !player->canOpenCorpse(corpseOwner)) { return RETURNVALUE_YOUARENOTTHEOWNER; } e mude isso para:
if (corpseOwner != 0 && !player->canOpenCorpse(corpseOwner)) { return RETURNVALUE_YOUARENOTTHEOWNER; } else { if (player->canOpenCorpse(corpseOwner) && player->autoLootList.size() != 0) { if (player->getCapacity() > 100 * 100) { //Minimum of Capacity for autoloot works. (100 CAP) for (Item* item : container->getItemList()) { if (player->getItemFromAutoLoot(item->getID())) { std::ostringstream msgAutoLoot; msgAutoLoot << "You looted a " << item->getItemCount() << "x " << item->getName() << "."; g_game.internalMoveItem(container, player, CONST_SLOT_WHEREEVER, item, item->getItemCount(), nullptr); player->sendTextMessage(MESSAGE_INFO_DESCR, msgAutoLoot.str()); } } } else { player->sendTextMessage(MESSAGE_INFO_DESCR, "Sorry, you don't have enough capacity to use auto loot, so it has been disabled. (100+ capacity is required)"); } } } em player.h, abaixo de:
std::unordered_set<uint32_t> VIPList; adicione isso:
std::set<uint32_t> autoLootList; ainda em player.h encontre:
bool hasLearnedInstantSpell(const std::string& spellName) const; adicione em baixo:
void addItemToAutoLoot(uint16_t itemId); void removeItemFromAutoLoot(uint16_t itemId); bool getItemFromAutoLoot(uint16_t itemId); em player.cpp no final do arquivo, adicione:
void Player::addItemToAutoLoot(uint16_t itemId) { autoLootList.insert(itemId); } void Player::removeItemFromAutoLoot(uint16_t itemId) { autoLootList.erase(itemId); } bool Player::getItemFromAutoLoot(const uint16_t itemId) { return autoLootList.find(itemId) != autoLootList.end(); } em luascript.cpp encontre:
registerMethod("Player", "getFightMode", LuaScriptInterface::luaPlayerGetFightMode); e adicione em baixo:
registerMethod("Player", "addItemToAutoLoot", LuaScriptInterface::luaPlayerAddItemToAutoLoot); registerMethod("Player", "removeItemFromAutoLoot", LuaScriptInterface::luaPlayerRemoveItemFromAutoLoot); registerMethod("Player", "getItemFromAutoLoot", LuaScriptInterface::luaPlayerGetItemFromAutoLoot); registerMethod("Player", "getAutoLootList", LuaScriptInterface::luaPlayerGetAutoLootList); ainda em luascript.cpp encontre essa função:
int LuaScriptInterface::luaPlayerGetFightMode(lua_State* L) { // player:getFightMode() Player* player = getUserdata<Player>(L, 1); if (player) { lua_pushnumber(L, player->fightMode); } else { lua_pushnil(L); } return 1; }
abaixo dela, adicione:
int LuaScriptInterface::luaPlayerAddItemToAutoLoot(lua_State* L) { // player:addItemToAutoLoot(itemId) Player* player = getUserdata<Player>(L, 1); if (!player) { lua_pushnil(L); return 1; } uint16_t itemId; if (isNumber(L, 2)) { itemId = getNumber<uint16_t>(L, 2); } else { itemId = Item::items.getItemIdByName(getString(L, 2)); if (itemId == 0) { lua_pushnil(L); return 1; } } player->addItemToAutoLoot(itemId); pushBoolean(L, true); return 1; } int LuaScriptInterface::luaPlayerRemoveItemFromAutoLoot(lua_State* L) { // player:removeItemFromAutoLoot(itemId) Player* player = getUserdata<Player>(L, 1); if (!player) { lua_pushnil(L); return 1; } uint16_t itemId; if (isNumber(L, 2)) { itemId = getNumber<uint16_t>(L, 2); } else { itemId = Item::items.getItemIdByName(getString(L, 2)); if (itemId == 0) { lua_pushnil(L); return 1; } } player->removeItemFromAutoLoot(itemId); pushBoolean(L, true); return 1; } int LuaScriptInterface::luaPlayerGetItemFromAutoLoot(lua_State* L) { // player:getItemFromAutoLoot(itemId) Player* player = getUserdata<Player>(L, 1); if (!player) { lua_pushnil(L); return 1; } uint16_t itemId; if (isNumber(L, 2)) { itemId = getNumber<uint16_t>(L, 2); } else { itemId = Item::items.getItemIdByName(getString(L, 2)); if (itemId == 0) { lua_pushnil(L); return 1; } } if (player->getItemFromAutoLoot(itemId)) { pushBoolean(L, true); } else { pushBoolean(L, false); } return 1; } int LuaScriptInterface::luaPlayerGetAutoLootList(lua_State* L) { // player:getAutoLootList() Player* player = getUserdata<Player>(L, 1); if (player) { std::set<uint32_t> value = player->autoLootList; if (value.size() == 0) { lua_pushnil(L); return 1; } int index = 0; lua_createtable(L, value.size(), 0); for(auto i : value) { lua_pushnumber(L, i); lua_rawseti(L, -2, ++index); } } else { lua_pushnil(L); } return 1; }
em luascript.h encontre:
static int luaPlayerGetFightMode(lua_State* L);
adicione a baixo:
static int luaPlayerAddItemToAutoLoot(lua_State* L); static int luaPlayerRemoveItemFromAutoLoot(lua_State* L); static int luaPlayerGetItemFromAutoLoot(lua_State* L); static int luaPlayerGetAutoLootList(lua_State* L);
em iologindata.cpp encontre:
//load storage map query.str(std::string()); query << "SELECT `key`, `value` FROM `player_storage` WHERE `player_id` = " << player->getGUID(); if ((result = db.storeQuery(query.str()))) { do { player->addStorageValue(result->getNumber<uint32_t>("key"), result->getNumber<int32_t>("value"), true); } while (result->next()); }
e adicione em baixo:
query.str(std::string()); query << "SELECT `autoloot_list` FROM `player_autoloot` WHERE `player_id` = " << player->getGUID(); if ((result = db.storeQuery(query.str()))) { unsigned long lootlistSize; const char* autolootlist = result->getStream("autoloot_list", lootlistSize); PropStream propStreamList; propStreamList.init(autolootlist, lootlistSize); int16_t value; int16_t item = propStreamList.read<int16_t>(value); while (item) { player->addItemToAutoLoot(value); item = propStreamList.read<int16_t>(value); } }
acima de:
//save inbox items adicione:
query.str(std::string()); query << "DELETE FROM `player_autoloot` WHERE `player_id` = " << player->getGUID(); if (!db.executeQuery(query.str())) { return false; } PropWriteStream propWriteStreamAutoLoot; for (auto i : player->autoLootList) { propWriteStreamAutoLoot.write<uint16_t>(i); } size_t lootlistSize; const char* autolootlist = propWriteStreamAutoLoot.getStream(lootlistSize); query.str(std::string()); DBInsert autolootQuery("INSERT INTO `player_autoloot` (`player_id`, `autoloot_list`) VALUES "); query << player->getGUID() << ',' << db.escapeBlob(autolootlist, lootlistSize); if (!autolootQuery.addRow(query)) { return false; } if (!autolootQuery.execute()) { return false; }
em sua database, execute esta query
CREATE TABLE player_autoloot ( id int NOT NULL AUTO_INCREMENT, player_id int NOT NULL, autoloot_list blob, PRIMARY KEY (id) );
agora vá em data/scripts/talkactions e crie esse arquivo LUA
autoloot.lua
local talk = TalkAction("!autoloot") function talk.onSay(player, words, param) local i = player:getAutoLootList() local cache = "Check your loot list: " local split = param:split(",") local action = split[1] if param == "list" then if i then for _, item in ipairs(i) do cache = cache .. (ItemType(item)):getName() .. ", " end else player:sendTextMessage(MESSAGE_INFO_DESCR, "Your list is empty! Add some item and try again.") return false end player:sendTextMessage(MESSAGE_INFO_DESCR, cache:sub(1, -3)) return false end if action == "add" then local item = split[2]:gsub("%s+", "", 1) local itemType = ItemType(item) if itemType:getId() == 0 then itemType = ItemType(tonumber(item)) if itemType:getName() == '' then player:sendCancelMessage("There is no item with that id or name.") return false end end if player:getItemFromAutoLoot(itemType:getId()) then player:sendCancelMessage("You're already autolooting this item.") return false end player:addItemToAutoLoot(itemType:getId()) player:sendTextMessage(MESSAGE_INFO_DESCR, "You're now auto looting " .. itemType:getName()) return false elseif action == "remove" then local item = split[2]:gsub("%s+", "", 1) local itemType = ItemType(item) if itemType:getId() == 0 then itemType = ItemType(tonumber(item)) if itemType:getName() == '' then player:sendCancelMessage("There is no item with that id or name.") return false end end if player:getItemFromAutoLoot(itemType:getId()) then player:removeItemFromAutoLoot(itemType:getId()) player:sendTextMessage(MESSAGE_INFO_DESCR, "You removed the " .. itemType:getName() .. " from your loot list.") else player:sendCancelMessage("This item does not exist in your loot list.") end return false end player:sendTextMessage(MESSAGE_EVENT_ORANGE, "Auto Loot commands (items are automatically moved to your bp if you open monster corpse):"..'\n'.."!addloot add, nameItem - add item to auto loot by name"..'\n'.."!autoloot remove, itemName - remove item from auto loot by name"..'\n'.."!autoloot list - list your current auto loot items") return false end talk:separator(" ") talk:register()
É isso, espero que gostem do sisteminha
Se você encontrar algum bug, deixe-me saber.
Falta fazer:
Optimizar a mensagem de loot.
Adicionar ModalWindow.
Cheers~
-
Pedriinz recebeu reputação de KotZletY em Auto Loot Sytem for TFS 1.3 + revscriptsDepois de milhões de anos sem programar porcaria nenhuma... Eu desenvolvi este sistema como um método de estudo. (C++)
Este sistema foi inspirado no Auto Loot System por @psychonaut. (OTland)
Criei o mesmo na versão mais recente do tfs.
Auto Loot System for TFS 1.3
Como funciona?
Simples, quando você mata um monstro e abre o corpo (você precisa clicar no corpo), os itens vão para o seu personagem.
Instalando
em actions.cpp, encontre:
if (corpseOwner != 0 && !player->canOpenCorpse(corpseOwner)) { return RETURNVALUE_YOUARENOTTHEOWNER; } e mude isso para:
if (corpseOwner != 0 && !player->canOpenCorpse(corpseOwner)) { return RETURNVALUE_YOUARENOTTHEOWNER; } else { if (player->canOpenCorpse(corpseOwner) && player->autoLootList.size() != 0) { if (player->getCapacity() > 100 * 100) { //Minimum of Capacity for autoloot works. (100 CAP) for (Item* item : container->getItemList()) { if (player->getItemFromAutoLoot(item->getID())) { std::ostringstream msgAutoLoot; msgAutoLoot << "You looted a " << item->getItemCount() << "x " << item->getName() << "."; g_game.internalMoveItem(container, player, CONST_SLOT_WHEREEVER, item, item->getItemCount(), nullptr); player->sendTextMessage(MESSAGE_INFO_DESCR, msgAutoLoot.str()); } } } else { player->sendTextMessage(MESSAGE_INFO_DESCR, "Sorry, you don't have enough capacity to use auto loot, so it has been disabled. (100+ capacity is required)"); } } } em player.h, abaixo de:
std::unordered_set<uint32_t> VIPList; adicione isso:
std::set<uint32_t> autoLootList; ainda em player.h encontre:
bool hasLearnedInstantSpell(const std::string& spellName) const; adicione em baixo:
void addItemToAutoLoot(uint16_t itemId); void removeItemFromAutoLoot(uint16_t itemId); bool getItemFromAutoLoot(uint16_t itemId); em player.cpp no final do arquivo, adicione:
void Player::addItemToAutoLoot(uint16_t itemId) { autoLootList.insert(itemId); } void Player::removeItemFromAutoLoot(uint16_t itemId) { autoLootList.erase(itemId); } bool Player::getItemFromAutoLoot(const uint16_t itemId) { return autoLootList.find(itemId) != autoLootList.end(); } em luascript.cpp encontre:
registerMethod("Player", "getFightMode", LuaScriptInterface::luaPlayerGetFightMode); e adicione em baixo:
registerMethod("Player", "addItemToAutoLoot", LuaScriptInterface::luaPlayerAddItemToAutoLoot); registerMethod("Player", "removeItemFromAutoLoot", LuaScriptInterface::luaPlayerRemoveItemFromAutoLoot); registerMethod("Player", "getItemFromAutoLoot", LuaScriptInterface::luaPlayerGetItemFromAutoLoot); registerMethod("Player", "getAutoLootList", LuaScriptInterface::luaPlayerGetAutoLootList); ainda em luascript.cpp encontre essa função:
int LuaScriptInterface::luaPlayerGetFightMode(lua_State* L) { // player:getFightMode() Player* player = getUserdata<Player>(L, 1); if (player) { lua_pushnumber(L, player->fightMode); } else { lua_pushnil(L); } return 1; }
abaixo dela, adicione:
int LuaScriptInterface::luaPlayerAddItemToAutoLoot(lua_State* L) { // player:addItemToAutoLoot(itemId) Player* player = getUserdata<Player>(L, 1); if (!player) { lua_pushnil(L); return 1; } uint16_t itemId; if (isNumber(L, 2)) { itemId = getNumber<uint16_t>(L, 2); } else { itemId = Item::items.getItemIdByName(getString(L, 2)); if (itemId == 0) { lua_pushnil(L); return 1; } } player->addItemToAutoLoot(itemId); pushBoolean(L, true); return 1; } int LuaScriptInterface::luaPlayerRemoveItemFromAutoLoot(lua_State* L) { // player:removeItemFromAutoLoot(itemId) Player* player = getUserdata<Player>(L, 1); if (!player) { lua_pushnil(L); return 1; } uint16_t itemId; if (isNumber(L, 2)) { itemId = getNumber<uint16_t>(L, 2); } else { itemId = Item::items.getItemIdByName(getString(L, 2)); if (itemId == 0) { lua_pushnil(L); return 1; } } player->removeItemFromAutoLoot(itemId); pushBoolean(L, true); return 1; } int LuaScriptInterface::luaPlayerGetItemFromAutoLoot(lua_State* L) { // player:getItemFromAutoLoot(itemId) Player* player = getUserdata<Player>(L, 1); if (!player) { lua_pushnil(L); return 1; } uint16_t itemId; if (isNumber(L, 2)) { itemId = getNumber<uint16_t>(L, 2); } else { itemId = Item::items.getItemIdByName(getString(L, 2)); if (itemId == 0) { lua_pushnil(L); return 1; } } if (player->getItemFromAutoLoot(itemId)) { pushBoolean(L, true); } else { pushBoolean(L, false); } return 1; } int LuaScriptInterface::luaPlayerGetAutoLootList(lua_State* L) { // player:getAutoLootList() Player* player = getUserdata<Player>(L, 1); if (player) { std::set<uint32_t> value = player->autoLootList; if (value.size() == 0) { lua_pushnil(L); return 1; } int index = 0; lua_createtable(L, value.size(), 0); for(auto i : value) { lua_pushnumber(L, i); lua_rawseti(L, -2, ++index); } } else { lua_pushnil(L); } return 1; }
em luascript.h encontre:
static int luaPlayerGetFightMode(lua_State* L);
adicione a baixo:
static int luaPlayerAddItemToAutoLoot(lua_State* L); static int luaPlayerRemoveItemFromAutoLoot(lua_State* L); static int luaPlayerGetItemFromAutoLoot(lua_State* L); static int luaPlayerGetAutoLootList(lua_State* L);
em iologindata.cpp encontre:
//load storage map query.str(std::string()); query << "SELECT `key`, `value` FROM `player_storage` WHERE `player_id` = " << player->getGUID(); if ((result = db.storeQuery(query.str()))) { do { player->addStorageValue(result->getNumber<uint32_t>("key"), result->getNumber<int32_t>("value"), true); } while (result->next()); }
e adicione em baixo:
query.str(std::string()); query << "SELECT `autoloot_list` FROM `player_autoloot` WHERE `player_id` = " << player->getGUID(); if ((result = db.storeQuery(query.str()))) { unsigned long lootlistSize; const char* autolootlist = result->getStream("autoloot_list", lootlistSize); PropStream propStreamList; propStreamList.init(autolootlist, lootlistSize); int16_t value; int16_t item = propStreamList.read<int16_t>(value); while (item) { player->addItemToAutoLoot(value); item = propStreamList.read<int16_t>(value); } }
acima de:
//save inbox items adicione:
query.str(std::string()); query << "DELETE FROM `player_autoloot` WHERE `player_id` = " << player->getGUID(); if (!db.executeQuery(query.str())) { return false; } PropWriteStream propWriteStreamAutoLoot; for (auto i : player->autoLootList) { propWriteStreamAutoLoot.write<uint16_t>(i); } size_t lootlistSize; const char* autolootlist = propWriteStreamAutoLoot.getStream(lootlistSize); query.str(std::string()); DBInsert autolootQuery("INSERT INTO `player_autoloot` (`player_id`, `autoloot_list`) VALUES "); query << player->getGUID() << ',' << db.escapeBlob(autolootlist, lootlistSize); if (!autolootQuery.addRow(query)) { return false; } if (!autolootQuery.execute()) { return false; }
em sua database, execute esta query
CREATE TABLE player_autoloot ( id int NOT NULL AUTO_INCREMENT, player_id int NOT NULL, autoloot_list blob, PRIMARY KEY (id) );
agora vá em data/scripts/talkactions e crie esse arquivo LUA
autoloot.lua
local talk = TalkAction("!autoloot") function talk.onSay(player, words, param) local i = player:getAutoLootList() local cache = "Check your loot list: " local split = param:split(",") local action = split[1] if param == "list" then if i then for _, item in ipairs(i) do cache = cache .. (ItemType(item)):getName() .. ", " end else player:sendTextMessage(MESSAGE_INFO_DESCR, "Your list is empty! Add some item and try again.") return false end player:sendTextMessage(MESSAGE_INFO_DESCR, cache:sub(1, -3)) return false end if action == "add" then local item = split[2]:gsub("%s+", "", 1) local itemType = ItemType(item) if itemType:getId() == 0 then itemType = ItemType(tonumber(item)) if itemType:getName() == '' then player:sendCancelMessage("There is no item with that id or name.") return false end end if player:getItemFromAutoLoot(itemType:getId()) then player:sendCancelMessage("You're already autolooting this item.") return false end player:addItemToAutoLoot(itemType:getId()) player:sendTextMessage(MESSAGE_INFO_DESCR, "You're now auto looting " .. itemType:getName()) return false elseif action == "remove" then local item = split[2]:gsub("%s+", "", 1) local itemType = ItemType(item) if itemType:getId() == 0 then itemType = ItemType(tonumber(item)) if itemType:getName() == '' then player:sendCancelMessage("There is no item with that id or name.") return false end end if player:getItemFromAutoLoot(itemType:getId()) then player:removeItemFromAutoLoot(itemType:getId()) player:sendTextMessage(MESSAGE_INFO_DESCR, "You removed the " .. itemType:getName() .. " from your loot list.") else player:sendCancelMessage("This item does not exist in your loot list.") end return false end player:sendTextMessage(MESSAGE_EVENT_ORANGE, "Auto Loot commands (items are automatically moved to your bp if you open monster corpse):"..'\n'.."!addloot add, nameItem - add item to auto loot by name"..'\n'.."!autoloot remove, itemName - remove item from auto loot by name"..'\n'.."!autoloot list - list your current auto loot items") return false end talk:separator(" ") talk:register()
É isso, espero que gostem do sisteminha
Se você encontrar algum bug, deixe-me saber.
Falta fazer:
Optimizar a mensagem de loot.
Adicionar ModalWindow.
Cheers~
-
Pedriinz recebeu reputação de Pedro. em Auto Loot Sytem for TFS 1.3 + revscriptsLogo logo eu lanço o modal dele...
Tudo é possível na programação mas não tenho planos pra fazer algo como tal.
Todavia, pretendo desenvolver algo similar... criar um "espaço" apenas para loots removidos do auto-loot. Como por exemplo uma bag dentro da store. Nesse espaço não daria pra mover items manualmente, apenas o auto-loot poderia mover pra lá e contaria CAP do jogador. Talvez eu adicione isso algum tempo...
-
Pedriinz recebeu reputação de Pedro. em Auto Loot Sytem for TFS 1.3 + revscriptsTente usar o meu auto loot e me diga se o erro acontece, caso aconteça... veremos isso!
Se você prefere utilizar o dele, então sugiro que procure o thread do sistema dele e peça ajuda lá! Outra opção é você abrir pedido de ajuda na seção de suporte.
Lembre-se, não estou sendo "rude" com você... apenas não dou suporte sobre códigos de outros.
-
Pedriinz recebeu reputação de Lyu em Auto Loot Sytem for TFS 1.3 + revscriptsDepois de milhões de anos sem programar porcaria nenhuma... Eu desenvolvi este sistema como um método de estudo. (C++)
Este sistema foi inspirado no Auto Loot System por @psychonaut. (OTland)
Criei o mesmo na versão mais recente do tfs.
Auto Loot System for TFS 1.3
Como funciona?
Simples, quando você mata um monstro e abre o corpo (você precisa clicar no corpo), os itens vão para o seu personagem.
Instalando
em actions.cpp, encontre:
if (corpseOwner != 0 && !player->canOpenCorpse(corpseOwner)) { return RETURNVALUE_YOUARENOTTHEOWNER; } e mude isso para:
if (corpseOwner != 0 && !player->canOpenCorpse(corpseOwner)) { return RETURNVALUE_YOUARENOTTHEOWNER; } else { if (player->canOpenCorpse(corpseOwner) && player->autoLootList.size() != 0) { if (player->getCapacity() > 100 * 100) { //Minimum of Capacity for autoloot works. (100 CAP) for (Item* item : container->getItemList()) { if (player->getItemFromAutoLoot(item->getID())) { std::ostringstream msgAutoLoot; msgAutoLoot << "You looted a " << item->getItemCount() << "x " << item->getName() << "."; g_game.internalMoveItem(container, player, CONST_SLOT_WHEREEVER, item, item->getItemCount(), nullptr); player->sendTextMessage(MESSAGE_INFO_DESCR, msgAutoLoot.str()); } } } else { player->sendTextMessage(MESSAGE_INFO_DESCR, "Sorry, you don't have enough capacity to use auto loot, so it has been disabled. (100+ capacity is required)"); } } } em player.h, abaixo de:
std::unordered_set<uint32_t> VIPList; adicione isso:
std::set<uint32_t> autoLootList; ainda em player.h encontre:
bool hasLearnedInstantSpell(const std::string& spellName) const; adicione em baixo:
void addItemToAutoLoot(uint16_t itemId); void removeItemFromAutoLoot(uint16_t itemId); bool getItemFromAutoLoot(uint16_t itemId); em player.cpp no final do arquivo, adicione:
void Player::addItemToAutoLoot(uint16_t itemId) { autoLootList.insert(itemId); } void Player::removeItemFromAutoLoot(uint16_t itemId) { autoLootList.erase(itemId); } bool Player::getItemFromAutoLoot(const uint16_t itemId) { return autoLootList.find(itemId) != autoLootList.end(); } em luascript.cpp encontre:
registerMethod("Player", "getFightMode", LuaScriptInterface::luaPlayerGetFightMode); e adicione em baixo:
registerMethod("Player", "addItemToAutoLoot", LuaScriptInterface::luaPlayerAddItemToAutoLoot); registerMethod("Player", "removeItemFromAutoLoot", LuaScriptInterface::luaPlayerRemoveItemFromAutoLoot); registerMethod("Player", "getItemFromAutoLoot", LuaScriptInterface::luaPlayerGetItemFromAutoLoot); registerMethod("Player", "getAutoLootList", LuaScriptInterface::luaPlayerGetAutoLootList); ainda em luascript.cpp encontre essa função:
int LuaScriptInterface::luaPlayerGetFightMode(lua_State* L) { // player:getFightMode() Player* player = getUserdata<Player>(L, 1); if (player) { lua_pushnumber(L, player->fightMode); } else { lua_pushnil(L); } return 1; }
abaixo dela, adicione:
int LuaScriptInterface::luaPlayerAddItemToAutoLoot(lua_State* L) { // player:addItemToAutoLoot(itemId) Player* player = getUserdata<Player>(L, 1); if (!player) { lua_pushnil(L); return 1; } uint16_t itemId; if (isNumber(L, 2)) { itemId = getNumber<uint16_t>(L, 2); } else { itemId = Item::items.getItemIdByName(getString(L, 2)); if (itemId == 0) { lua_pushnil(L); return 1; } } player->addItemToAutoLoot(itemId); pushBoolean(L, true); return 1; } int LuaScriptInterface::luaPlayerRemoveItemFromAutoLoot(lua_State* L) { // player:removeItemFromAutoLoot(itemId) Player* player = getUserdata<Player>(L, 1); if (!player) { lua_pushnil(L); return 1; } uint16_t itemId; if (isNumber(L, 2)) { itemId = getNumber<uint16_t>(L, 2); } else { itemId = Item::items.getItemIdByName(getString(L, 2)); if (itemId == 0) { lua_pushnil(L); return 1; } } player->removeItemFromAutoLoot(itemId); pushBoolean(L, true); return 1; } int LuaScriptInterface::luaPlayerGetItemFromAutoLoot(lua_State* L) { // player:getItemFromAutoLoot(itemId) Player* player = getUserdata<Player>(L, 1); if (!player) { lua_pushnil(L); return 1; } uint16_t itemId; if (isNumber(L, 2)) { itemId = getNumber<uint16_t>(L, 2); } else { itemId = Item::items.getItemIdByName(getString(L, 2)); if (itemId == 0) { lua_pushnil(L); return 1; } } if (player->getItemFromAutoLoot(itemId)) { pushBoolean(L, true); } else { pushBoolean(L, false); } return 1; } int LuaScriptInterface::luaPlayerGetAutoLootList(lua_State* L) { // player:getAutoLootList() Player* player = getUserdata<Player>(L, 1); if (player) { std::set<uint32_t> value = player->autoLootList; if (value.size() == 0) { lua_pushnil(L); return 1; } int index = 0; lua_createtable(L, value.size(), 0); for(auto i : value) { lua_pushnumber(L, i); lua_rawseti(L, -2, ++index); } } else { lua_pushnil(L); } return 1; }
em luascript.h encontre:
static int luaPlayerGetFightMode(lua_State* L);
adicione a baixo:
static int luaPlayerAddItemToAutoLoot(lua_State* L); static int luaPlayerRemoveItemFromAutoLoot(lua_State* L); static int luaPlayerGetItemFromAutoLoot(lua_State* L); static int luaPlayerGetAutoLootList(lua_State* L);
em iologindata.cpp encontre:
//load storage map query.str(std::string()); query << "SELECT `key`, `value` FROM `player_storage` WHERE `player_id` = " << player->getGUID(); if ((result = db.storeQuery(query.str()))) { do { player->addStorageValue(result->getNumber<uint32_t>("key"), result->getNumber<int32_t>("value"), true); } while (result->next()); }
e adicione em baixo:
query.str(std::string()); query << "SELECT `autoloot_list` FROM `player_autoloot` WHERE `player_id` = " << player->getGUID(); if ((result = db.storeQuery(query.str()))) { unsigned long lootlistSize; const char* autolootlist = result->getStream("autoloot_list", lootlistSize); PropStream propStreamList; propStreamList.init(autolootlist, lootlistSize); int16_t value; int16_t item = propStreamList.read<int16_t>(value); while (item) { player->addItemToAutoLoot(value); item = propStreamList.read<int16_t>(value); } }
acima de:
//save inbox items adicione:
query.str(std::string()); query << "DELETE FROM `player_autoloot` WHERE `player_id` = " << player->getGUID(); if (!db.executeQuery(query.str())) { return false; } PropWriteStream propWriteStreamAutoLoot; for (auto i : player->autoLootList) { propWriteStreamAutoLoot.write<uint16_t>(i); } size_t lootlistSize; const char* autolootlist = propWriteStreamAutoLoot.getStream(lootlistSize); query.str(std::string()); DBInsert autolootQuery("INSERT INTO `player_autoloot` (`player_id`, `autoloot_list`) VALUES "); query << player->getGUID() << ',' << db.escapeBlob(autolootlist, lootlistSize); if (!autolootQuery.addRow(query)) { return false; } if (!autolootQuery.execute()) { return false; }
em sua database, execute esta query
CREATE TABLE player_autoloot ( id int NOT NULL AUTO_INCREMENT, player_id int NOT NULL, autoloot_list blob, PRIMARY KEY (id) );
agora vá em data/scripts/talkactions e crie esse arquivo LUA
autoloot.lua
local talk = TalkAction("!autoloot") function talk.onSay(player, words, param) local i = player:getAutoLootList() local cache = "Check your loot list: " local split = param:split(",") local action = split[1] if param == "list" then if i then for _, item in ipairs(i) do cache = cache .. (ItemType(item)):getName() .. ", " end else player:sendTextMessage(MESSAGE_INFO_DESCR, "Your list is empty! Add some item and try again.") return false end player:sendTextMessage(MESSAGE_INFO_DESCR, cache:sub(1, -3)) return false end if action == "add" then local item = split[2]:gsub("%s+", "", 1) local itemType = ItemType(item) if itemType:getId() == 0 then itemType = ItemType(tonumber(item)) if itemType:getName() == '' then player:sendCancelMessage("There is no item with that id or name.") return false end end if player:getItemFromAutoLoot(itemType:getId()) then player:sendCancelMessage("You're already autolooting this item.") return false end player:addItemToAutoLoot(itemType:getId()) player:sendTextMessage(MESSAGE_INFO_DESCR, "You're now auto looting " .. itemType:getName()) return false elseif action == "remove" then local item = split[2]:gsub("%s+", "", 1) local itemType = ItemType(item) if itemType:getId() == 0 then itemType = ItemType(tonumber(item)) if itemType:getName() == '' then player:sendCancelMessage("There is no item with that id or name.") return false end end if player:getItemFromAutoLoot(itemType:getId()) then player:removeItemFromAutoLoot(itemType:getId()) player:sendTextMessage(MESSAGE_INFO_DESCR, "You removed the " .. itemType:getName() .. " from your loot list.") else player:sendCancelMessage("This item does not exist in your loot list.") end return false end player:sendTextMessage(MESSAGE_EVENT_ORANGE, "Auto Loot commands (items are automatically moved to your bp if you open monster corpse):"..'\n'.."!addloot add, nameItem - add item to auto loot by name"..'\n'.."!autoloot remove, itemName - remove item from auto loot by name"..'\n'.."!autoloot list - list your current auto loot items") return false end talk:separator(" ") talk:register()
É isso, espero que gostem do sisteminha
Se você encontrar algum bug, deixe-me saber.
Falta fazer:
Optimizar a mensagem de loot.
Adicionar ModalWindow.
Cheers~
-
Pedriinz deu reputação a MatCollier em Auto Loot Sytem for TFS 1.3 + revscripts@Pedriinz Você é um monstro! Pegou com o rewardboss aqui sem dar crash. Muito obrigado.
Rep+
-
Pedriinz recebeu reputação de MatCollier em Auto Loot Sytem for TFS 1.3 + revscriptsDepois de milhões de anos sem programar porcaria nenhuma... Eu desenvolvi este sistema como um método de estudo. (C++)
Este sistema foi inspirado no Auto Loot System por @psychonaut. (OTland)
Criei o mesmo na versão mais recente do tfs.
Auto Loot System for TFS 1.3
Como funciona?
Simples, quando você mata um monstro e abre o corpo (você precisa clicar no corpo), os itens vão para o seu personagem.
Instalando
em actions.cpp, encontre:
if (corpseOwner != 0 && !player->canOpenCorpse(corpseOwner)) { return RETURNVALUE_YOUARENOTTHEOWNER; } e mude isso para:
if (corpseOwner != 0 && !player->canOpenCorpse(corpseOwner)) { return RETURNVALUE_YOUARENOTTHEOWNER; } else { if (player->canOpenCorpse(corpseOwner) && player->autoLootList.size() != 0) { if (player->getCapacity() > 100 * 100) { //Minimum of Capacity for autoloot works. (100 CAP) for (Item* item : container->getItemList()) { if (player->getItemFromAutoLoot(item->getID())) { std::ostringstream msgAutoLoot; msgAutoLoot << "You looted a " << item->getItemCount() << "x " << item->getName() << "."; g_game.internalMoveItem(container, player, CONST_SLOT_WHEREEVER, item, item->getItemCount(), nullptr); player->sendTextMessage(MESSAGE_INFO_DESCR, msgAutoLoot.str()); } } } else { player->sendTextMessage(MESSAGE_INFO_DESCR, "Sorry, you don't have enough capacity to use auto loot, so it has been disabled. (100+ capacity is required)"); } } } em player.h, abaixo de:
std::unordered_set<uint32_t> VIPList; adicione isso:
std::set<uint32_t> autoLootList; ainda em player.h encontre:
bool hasLearnedInstantSpell(const std::string& spellName) const; adicione em baixo:
void addItemToAutoLoot(uint16_t itemId); void removeItemFromAutoLoot(uint16_t itemId); bool getItemFromAutoLoot(uint16_t itemId); em player.cpp no final do arquivo, adicione:
void Player::addItemToAutoLoot(uint16_t itemId) { autoLootList.insert(itemId); } void Player::removeItemFromAutoLoot(uint16_t itemId) { autoLootList.erase(itemId); } bool Player::getItemFromAutoLoot(const uint16_t itemId) { return autoLootList.find(itemId) != autoLootList.end(); } em luascript.cpp encontre:
registerMethod("Player", "getFightMode", LuaScriptInterface::luaPlayerGetFightMode); e adicione em baixo:
registerMethod("Player", "addItemToAutoLoot", LuaScriptInterface::luaPlayerAddItemToAutoLoot); registerMethod("Player", "removeItemFromAutoLoot", LuaScriptInterface::luaPlayerRemoveItemFromAutoLoot); registerMethod("Player", "getItemFromAutoLoot", LuaScriptInterface::luaPlayerGetItemFromAutoLoot); registerMethod("Player", "getAutoLootList", LuaScriptInterface::luaPlayerGetAutoLootList); ainda em luascript.cpp encontre essa função:
int LuaScriptInterface::luaPlayerGetFightMode(lua_State* L) { // player:getFightMode() Player* player = getUserdata<Player>(L, 1); if (player) { lua_pushnumber(L, player->fightMode); } else { lua_pushnil(L); } return 1; }
abaixo dela, adicione:
int LuaScriptInterface::luaPlayerAddItemToAutoLoot(lua_State* L) { // player:addItemToAutoLoot(itemId) Player* player = getUserdata<Player>(L, 1); if (!player) { lua_pushnil(L); return 1; } uint16_t itemId; if (isNumber(L, 2)) { itemId = getNumber<uint16_t>(L, 2); } else { itemId = Item::items.getItemIdByName(getString(L, 2)); if (itemId == 0) { lua_pushnil(L); return 1; } } player->addItemToAutoLoot(itemId); pushBoolean(L, true); return 1; } int LuaScriptInterface::luaPlayerRemoveItemFromAutoLoot(lua_State* L) { // player:removeItemFromAutoLoot(itemId) Player* player = getUserdata<Player>(L, 1); if (!player) { lua_pushnil(L); return 1; } uint16_t itemId; if (isNumber(L, 2)) { itemId = getNumber<uint16_t>(L, 2); } else { itemId = Item::items.getItemIdByName(getString(L, 2)); if (itemId == 0) { lua_pushnil(L); return 1; } } player->removeItemFromAutoLoot(itemId); pushBoolean(L, true); return 1; } int LuaScriptInterface::luaPlayerGetItemFromAutoLoot(lua_State* L) { // player:getItemFromAutoLoot(itemId) Player* player = getUserdata<Player>(L, 1); if (!player) { lua_pushnil(L); return 1; } uint16_t itemId; if (isNumber(L, 2)) { itemId = getNumber<uint16_t>(L, 2); } else { itemId = Item::items.getItemIdByName(getString(L, 2)); if (itemId == 0) { lua_pushnil(L); return 1; } } if (player->getItemFromAutoLoot(itemId)) { pushBoolean(L, true); } else { pushBoolean(L, false); } return 1; } int LuaScriptInterface::luaPlayerGetAutoLootList(lua_State* L) { // player:getAutoLootList() Player* player = getUserdata<Player>(L, 1); if (player) { std::set<uint32_t> value = player->autoLootList; if (value.size() == 0) { lua_pushnil(L); return 1; } int index = 0; lua_createtable(L, value.size(), 0); for(auto i : value) { lua_pushnumber(L, i); lua_rawseti(L, -2, ++index); } } else { lua_pushnil(L); } return 1; }
em luascript.h encontre:
static int luaPlayerGetFightMode(lua_State* L);
adicione a baixo:
static int luaPlayerAddItemToAutoLoot(lua_State* L); static int luaPlayerRemoveItemFromAutoLoot(lua_State* L); static int luaPlayerGetItemFromAutoLoot(lua_State* L); static int luaPlayerGetAutoLootList(lua_State* L);
em iologindata.cpp encontre:
//load storage map query.str(std::string()); query << "SELECT `key`, `value` FROM `player_storage` WHERE `player_id` = " << player->getGUID(); if ((result = db.storeQuery(query.str()))) { do { player->addStorageValue(result->getNumber<uint32_t>("key"), result->getNumber<int32_t>("value"), true); } while (result->next()); }
e adicione em baixo:
query.str(std::string()); query << "SELECT `autoloot_list` FROM `player_autoloot` WHERE `player_id` = " << player->getGUID(); if ((result = db.storeQuery(query.str()))) { unsigned long lootlistSize; const char* autolootlist = result->getStream("autoloot_list", lootlistSize); PropStream propStreamList; propStreamList.init(autolootlist, lootlistSize); int16_t value; int16_t item = propStreamList.read<int16_t>(value); while (item) { player->addItemToAutoLoot(value); item = propStreamList.read<int16_t>(value); } }
acima de:
//save inbox items adicione:
query.str(std::string()); query << "DELETE FROM `player_autoloot` WHERE `player_id` = " << player->getGUID(); if (!db.executeQuery(query.str())) { return false; } PropWriteStream propWriteStreamAutoLoot; for (auto i : player->autoLootList) { propWriteStreamAutoLoot.write<uint16_t>(i); } size_t lootlistSize; const char* autolootlist = propWriteStreamAutoLoot.getStream(lootlistSize); query.str(std::string()); DBInsert autolootQuery("INSERT INTO `player_autoloot` (`player_id`, `autoloot_list`) VALUES "); query << player->getGUID() << ',' << db.escapeBlob(autolootlist, lootlistSize); if (!autolootQuery.addRow(query)) { return false; } if (!autolootQuery.execute()) { return false; }
em sua database, execute esta query
CREATE TABLE player_autoloot ( id int NOT NULL AUTO_INCREMENT, player_id int NOT NULL, autoloot_list blob, PRIMARY KEY (id) );
agora vá em data/scripts/talkactions e crie esse arquivo LUA
autoloot.lua
local talk = TalkAction("!autoloot") function talk.onSay(player, words, param) local i = player:getAutoLootList() local cache = "Check your loot list: " local split = param:split(",") local action = split[1] if param == "list" then if i then for _, item in ipairs(i) do cache = cache .. (ItemType(item)):getName() .. ", " end else player:sendTextMessage(MESSAGE_INFO_DESCR, "Your list is empty! Add some item and try again.") return false end player:sendTextMessage(MESSAGE_INFO_DESCR, cache:sub(1, -3)) return false end if action == "add" then local item = split[2]:gsub("%s+", "", 1) local itemType = ItemType(item) if itemType:getId() == 0 then itemType = ItemType(tonumber(item)) if itemType:getName() == '' then player:sendCancelMessage("There is no item with that id or name.") return false end end if player:getItemFromAutoLoot(itemType:getId()) then player:sendCancelMessage("You're already autolooting this item.") return false end player:addItemToAutoLoot(itemType:getId()) player:sendTextMessage(MESSAGE_INFO_DESCR, "You're now auto looting " .. itemType:getName()) return false elseif action == "remove" then local item = split[2]:gsub("%s+", "", 1) local itemType = ItemType(item) if itemType:getId() == 0 then itemType = ItemType(tonumber(item)) if itemType:getName() == '' then player:sendCancelMessage("There is no item with that id or name.") return false end end if player:getItemFromAutoLoot(itemType:getId()) then player:removeItemFromAutoLoot(itemType:getId()) player:sendTextMessage(MESSAGE_INFO_DESCR, "You removed the " .. itemType:getName() .. " from your loot list.") else player:sendCancelMessage("This item does not exist in your loot list.") end return false end player:sendTextMessage(MESSAGE_EVENT_ORANGE, "Auto Loot commands (items are automatically moved to your bp if you open monster corpse):"..'\n'.."!addloot add, nameItem - add item to auto loot by name"..'\n'.."!autoloot remove, itemName - remove item from auto loot by name"..'\n'.."!autoloot list - list your current auto loot items") return false end talk:separator(" ") talk:register()
É isso, espero que gostem do sisteminha
Se você encontrar algum bug, deixe-me saber.
Falta fazer:
Optimizar a mensagem de loot.
Adicionar ModalWindow.
Cheers~
-
Pedriinz recebeu reputação de MatCollier em Auto Loot Sytem for TFS 1.3 + revscriptsYo!
Acabei de realizar algumas atualizações no código. As mudanças foram:
Junção de todos os scripts LUA em um só, resultando em um único comando para administrar o sistema de autoloot.
Exemplo:
!autoloot add, boots of haste !autoloot remove, boots of haste !autoloot list !autoloot
Também adicionei algumas verificações no script para que o mesmo não seja executado caso o personagem não tenha nenhum item adicionado a lista de autoloot. (optimização). Verificação de capacidade também está aqui agora, caso o personagem não tenha mais que 100 de cap uma mensagem é retornada para o player informando que não foi possível saquear aquele loot devida a mesma. (No futuro talvez eu deixe isso configurável pelo config.lua).
Cheers
-
Pedriinz deu reputação a Vodkart em [8.6] Task System 4.0! (Task system + Daily Task System)Removido:
*Boss Room
*Rank Task
*Prêmios para os 10 primeiros a terminar todas as tasks
Adicionado:
*Daily Task System (Sistema exclusivo de Task diario, podendo pegar 1x a cada 24 hrs, irei explicar mais depois.)
*Task agora é por progresso, você não pode sair e voltar, terá que terminar a task 1 para avançar para a task 2, assim sucessivamente.
*Task Points
*Level para realizar a task
*Nova talkaction que mostra uma janela de informações sobre o level da task, premios que irá receber, progresso, etc...
*Items para entrega(Se o jogador deverá levar algum item junto com a quantidade de monstro morta) para finalizar a task
*Sistema de look Task (Varia de acordo com a sua quantidade de Task Points, podendo ficar por exemplo como "Huntsman", "Ranger", etc...(alterável)
*Mods e npc mais "clean", várias linhas removidas e o sistema está mais rápido
*Vou Adicionar "scripts extras" Como:
--> Tile que só passa quem tiver permissão depois de finalizar determinada quest
--> Npc de Boss Room para entrar e enfrentar o monstro quem fez determinada quest
[+] Resumo do Task system + Daily Task System [+]
Task System: É o sistema de task "original", onde consiste em matar determinada quantidade de monstros(E entregar certo itens <- é configurável), para receber recompensas como Exp, Money e Items.
Algumas mudanças do simple task 3.0 para o 4.0 foram:
[+] O sistema agora é por progresso, isso quer dizer que você terá que ir terminando a quest para avançar para a seguinte.
[+] O sistema Também recebeu uma alteração, fazendo com que as Tasks precisem que o jogador tenha um level determinado
[+] A tabela para edição está mais fácil, fazendo com que você adicione ou remova monstros com mais tranquilidade, inclusive alterações das Rewards da Task.
Daily Task System: É um sistema que desenvolvi para que os jogadores sempre estejam se comunicando com o npc de Task, no caso da Task Diaria, vária de acordo com o level do jogador, por exemplo:
Jogadores entre level 6 ao 49 poderá cair em uma dessas 3 Task Diarias: Orcs, Tarantulas ou Wyverns
Jogadores entre level 50 ao 79 poderá cair em uma dessas 3 Task Diarias: Dragons, Wailing Widows ou Ancient Scarabs
E por ai vai, claro que você poderá aumentar as Task Diarias dependendo do level, eu fiz 3 para cada level que é pra postar, mas tudo isso você pode aumentar! Dependendo do seu servidor.
E sim, você pode fazer a TASK "ORIGINAL" e a TASK "DIARIA" ao mesmo tempo! Ambas são distintas e possuem Rewards diferenciadas!
No caso da Task diaria, levando em conta que você começou a fazer ela no dia 08/01 ás 20:00 Hrs, você tem até o dia 09/01 ás 20:00Hrs para termina-la e receber a recompensa, caso termine antes, a Task diaria só irá ficar disponível para repetição a partir desta mesma data 09/01 20:00 Hrs;
[+] Caso você não termine a tempo, não tem problema, basta esperar este horário e começar uma nova Task.
[+] Caso você começou a Daily Task e terminou antes desta data. mas por algum motivo esqueceu de entregar e a mesma passou do prazo, não tem importância, caso você tenha matado todos os monstros até 09/01 20:00 Hrs, você poderá entregar está Task em qualquer horário para receber suas Rewards e começar uma task a partir do momento em que você entregou! (INJUSTIÇA AQUI NÃO CARALHO).
[+] Comandos Adicionais [+]
/task -- Mostra as informações da sua Task Atual, como Nome da Task, Level, Rewards, Monstros que você poderá matar, Se tem que entregar algum Item junto, etc...
/task daily -- É basicamente mostra a mesma informação da Task Principal, porém mostra também qual o prazo limite para entrega da task.
/task counter -- É um comando que ATIVA ou DESATIVA o contador de monstros mortos na task no seu Channel.
[+] Imagens [+]
Cline neste link para ver algumas imagens da Task : http://imgur.com/a/eLIY3
------------------------------------------------ // --------------------------------------------------------------
[+] Instalação do Sistema [+]
Requisitos: Nível Médio de conhecimento em scripting LUA
Pasta Mods
Simple Task.xml
https://pastebin.com/raw/P5hqMC3j
NPC:
Ludger.xml
https://pastebin.com/raw/R56yLWHw
simple_task.lua
https://pastebin.com/raw/1mRzJ6aJ
---------------------------------------------- // ----------------------------------
[+] configuração [+ ]
Task System Principal
task_sys = { [1] = {name = "Trolls", start = 176201, monsters_list = {"Troll","Troll champion"}, level = 8, count = 40, points = 0, items = {}, reward = {}, exp = 2000, money = 2000} }
[1] --> O número entre os colchetes [] significa a ordem da Task, como a Task é por progresso sempre começará no 1 e irá pro [2], assim sucessivamente.
name --> É o nome da task que o jogador irá fazer.
start --> é a storage que indicará se o jogador começou a Task
monster_list ={} --> É o nome dos monstros em que o jogador deverá caçar para completar a Task
level --> É o level necessário para dar inicio á Task
count --> É o número de monstros que o jogador tem que matar para completar a Task
points --> Aqui determinada quantos Task points o jogador irá receber ao completar a Task
items = {} --> Aqui determinada se além de matar os monstros, o jogador terá que entregar item também! Caso tenha só colocar o {ITEM_ID, QUANTIDADE} EX:
items = {{2173,1},{2160,10},{2493,2}} rewad --> Aqui determinada se o jogador irá receber itens ao terminar a Task, mesma formula do items /\
reward = {{2520,1},{2173,1}} exp --> Se o jogador irá receber Exp ao terminar a task. 0 ou quantidade de exp
Money --> Se o jogador irá receber dinheiro ao terminar a task. 0 ou quantidade de dinheiro
Daily Task System
daily_task = { [1] = {name = "Orcs" ,monsters_list = {"Orc Berserker","Orc Rider","Orc Leader","Orc Warlord"}, count = 100, points = 0, reward = {}, exp = 5000, money = 10000} }
Segue o padrão da Task original, exceto que não precisa entregar items para o npc!
Como funciona A randomização de level de acordo com a Daily task?
Procure por está tabela em MODS
local t = { [{6,49}] = {1,3}, [{50,79}] = {4,6}, [{80,129}] = {7,9}, [{130,math.huge}] = {10,12} }
entre as chaves e colchetes é o level do jogador para as Daily Task, Você pode adicionar quantas você quiser!
Digamos que:
[{6,49}] = {1,3} --> Quer dizer que entre o level 6 ao 49 o jogador poderá cair na Daily Task número 1(Orcs), 2(Tarantulas) ou 3(Wyvern)!
[{50,79}] = {4,6} --> Quer dizer que entre o level 50 ao 79 o jogador poderá cair na Daily Task número 4(Dragons), 5(Wailing Widows) ou 6(Ancient Scarabs)!
...
[{130,math.huge}] = {10,12} --> Quer dizer que o jogador level 130 ou MAIS poderá cair na Daily Task número 10(Undead Dragons), 11(HydraS) ou 12(Ghastly Dragons)!
Look Rank System
Procure por está tabela em MODS
local ranks = { [{1, 20}] = "Huntsman", [{21, 50}] = "Ranger", [{51, 100}] = "Big Game Hunter", [{101, 200}] = "Trophy Hunter", [{201, math.huge}] = "Elite Hunter" }
Entre 1-20 Task points o Rank será Huntsman
Entre 21-50 Task posints o Rank será Ranger
Entre 51-100 Task Points o rank será Big Game Hunter
etc...
Altere como quiser!
-
Pedriinz recebeu reputação de lordzetros em Auto Loot Sytem for TFS 1.3 + revscriptsDepois de milhões de anos sem programar porcaria nenhuma... Eu desenvolvi este sistema como um método de estudo. (C++)
Este sistema foi inspirado no Auto Loot System por @psychonaut. (OTland)
Criei o mesmo na versão mais recente do tfs.
Auto Loot System for TFS 1.3
Como funciona?
Simples, quando você mata um monstro e abre o corpo (você precisa clicar no corpo), os itens vão para o seu personagem.
Instalando
em actions.cpp, encontre:
if (corpseOwner != 0 && !player->canOpenCorpse(corpseOwner)) { return RETURNVALUE_YOUARENOTTHEOWNER; } e mude isso para:
if (corpseOwner != 0 && !player->canOpenCorpse(corpseOwner)) { return RETURNVALUE_YOUARENOTTHEOWNER; } else { if (player->canOpenCorpse(corpseOwner) && player->autoLootList.size() != 0) { if (player->getCapacity() > 100 * 100) { //Minimum of Capacity for autoloot works. (100 CAP) for (Item* item : container->getItemList()) { if (player->getItemFromAutoLoot(item->getID())) { std::ostringstream msgAutoLoot; msgAutoLoot << "You looted a " << item->getItemCount() << "x " << item->getName() << "."; g_game.internalMoveItem(container, player, CONST_SLOT_WHEREEVER, item, item->getItemCount(), nullptr); player->sendTextMessage(MESSAGE_INFO_DESCR, msgAutoLoot.str()); } } } else { player->sendTextMessage(MESSAGE_INFO_DESCR, "Sorry, you don't have enough capacity to use auto loot, so it has been disabled. (100+ capacity is required)"); } } } em player.h, abaixo de:
std::unordered_set<uint32_t> VIPList; adicione isso:
std::set<uint32_t> autoLootList; ainda em player.h encontre:
bool hasLearnedInstantSpell(const std::string& spellName) const; adicione em baixo:
void addItemToAutoLoot(uint16_t itemId); void removeItemFromAutoLoot(uint16_t itemId); bool getItemFromAutoLoot(uint16_t itemId); em player.cpp no final do arquivo, adicione:
void Player::addItemToAutoLoot(uint16_t itemId) { autoLootList.insert(itemId); } void Player::removeItemFromAutoLoot(uint16_t itemId) { autoLootList.erase(itemId); } bool Player::getItemFromAutoLoot(const uint16_t itemId) { return autoLootList.find(itemId) != autoLootList.end(); } em luascript.cpp encontre:
registerMethod("Player", "getFightMode", LuaScriptInterface::luaPlayerGetFightMode); e adicione em baixo:
registerMethod("Player", "addItemToAutoLoot", LuaScriptInterface::luaPlayerAddItemToAutoLoot); registerMethod("Player", "removeItemFromAutoLoot", LuaScriptInterface::luaPlayerRemoveItemFromAutoLoot); registerMethod("Player", "getItemFromAutoLoot", LuaScriptInterface::luaPlayerGetItemFromAutoLoot); registerMethod("Player", "getAutoLootList", LuaScriptInterface::luaPlayerGetAutoLootList); ainda em luascript.cpp encontre essa função:
int LuaScriptInterface::luaPlayerGetFightMode(lua_State* L) { // player:getFightMode() Player* player = getUserdata<Player>(L, 1); if (player) { lua_pushnumber(L, player->fightMode); } else { lua_pushnil(L); } return 1; }
abaixo dela, adicione:
int LuaScriptInterface::luaPlayerAddItemToAutoLoot(lua_State* L) { // player:addItemToAutoLoot(itemId) Player* player = getUserdata<Player>(L, 1); if (!player) { lua_pushnil(L); return 1; } uint16_t itemId; if (isNumber(L, 2)) { itemId = getNumber<uint16_t>(L, 2); } else { itemId = Item::items.getItemIdByName(getString(L, 2)); if (itemId == 0) { lua_pushnil(L); return 1; } } player->addItemToAutoLoot(itemId); pushBoolean(L, true); return 1; } int LuaScriptInterface::luaPlayerRemoveItemFromAutoLoot(lua_State* L) { // player:removeItemFromAutoLoot(itemId) Player* player = getUserdata<Player>(L, 1); if (!player) { lua_pushnil(L); return 1; } uint16_t itemId; if (isNumber(L, 2)) { itemId = getNumber<uint16_t>(L, 2); } else { itemId = Item::items.getItemIdByName(getString(L, 2)); if (itemId == 0) { lua_pushnil(L); return 1; } } player->removeItemFromAutoLoot(itemId); pushBoolean(L, true); return 1; } int LuaScriptInterface::luaPlayerGetItemFromAutoLoot(lua_State* L) { // player:getItemFromAutoLoot(itemId) Player* player = getUserdata<Player>(L, 1); if (!player) { lua_pushnil(L); return 1; } uint16_t itemId; if (isNumber(L, 2)) { itemId = getNumber<uint16_t>(L, 2); } else { itemId = Item::items.getItemIdByName(getString(L, 2)); if (itemId == 0) { lua_pushnil(L); return 1; } } if (player->getItemFromAutoLoot(itemId)) { pushBoolean(L, true); } else { pushBoolean(L, false); } return 1; } int LuaScriptInterface::luaPlayerGetAutoLootList(lua_State* L) { // player:getAutoLootList() Player* player = getUserdata<Player>(L, 1); if (player) { std::set<uint32_t> value = player->autoLootList; if (value.size() == 0) { lua_pushnil(L); return 1; } int index = 0; lua_createtable(L, value.size(), 0); for(auto i : value) { lua_pushnumber(L, i); lua_rawseti(L, -2, ++index); } } else { lua_pushnil(L); } return 1; }
em luascript.h encontre:
static int luaPlayerGetFightMode(lua_State* L);
adicione a baixo:
static int luaPlayerAddItemToAutoLoot(lua_State* L); static int luaPlayerRemoveItemFromAutoLoot(lua_State* L); static int luaPlayerGetItemFromAutoLoot(lua_State* L); static int luaPlayerGetAutoLootList(lua_State* L);
em iologindata.cpp encontre:
//load storage map query.str(std::string()); query << "SELECT `key`, `value` FROM `player_storage` WHERE `player_id` = " << player->getGUID(); if ((result = db.storeQuery(query.str()))) { do { player->addStorageValue(result->getNumber<uint32_t>("key"), result->getNumber<int32_t>("value"), true); } while (result->next()); }
e adicione em baixo:
query.str(std::string()); query << "SELECT `autoloot_list` FROM `player_autoloot` WHERE `player_id` = " << player->getGUID(); if ((result = db.storeQuery(query.str()))) { unsigned long lootlistSize; const char* autolootlist = result->getStream("autoloot_list", lootlistSize); PropStream propStreamList; propStreamList.init(autolootlist, lootlistSize); int16_t value; int16_t item = propStreamList.read<int16_t>(value); while (item) { player->addItemToAutoLoot(value); item = propStreamList.read<int16_t>(value); } }
acima de:
//save inbox items adicione:
query.str(std::string()); query << "DELETE FROM `player_autoloot` WHERE `player_id` = " << player->getGUID(); if (!db.executeQuery(query.str())) { return false; } PropWriteStream propWriteStreamAutoLoot; for (auto i : player->autoLootList) { propWriteStreamAutoLoot.write<uint16_t>(i); } size_t lootlistSize; const char* autolootlist = propWriteStreamAutoLoot.getStream(lootlistSize); query.str(std::string()); DBInsert autolootQuery("INSERT INTO `player_autoloot` (`player_id`, `autoloot_list`) VALUES "); query << player->getGUID() << ',' << db.escapeBlob(autolootlist, lootlistSize); if (!autolootQuery.addRow(query)) { return false; } if (!autolootQuery.execute()) { return false; }
em sua database, execute esta query
CREATE TABLE player_autoloot ( id int NOT NULL AUTO_INCREMENT, player_id int NOT NULL, autoloot_list blob, PRIMARY KEY (id) );
agora vá em data/scripts/talkactions e crie esse arquivo LUA
autoloot.lua
local talk = TalkAction("!autoloot") function talk.onSay(player, words, param) local i = player:getAutoLootList() local cache = "Check your loot list: " local split = param:split(",") local action = split[1] if param == "list" then if i then for _, item in ipairs(i) do cache = cache .. (ItemType(item)):getName() .. ", " end else player:sendTextMessage(MESSAGE_INFO_DESCR, "Your list is empty! Add some item and try again.") return false end player:sendTextMessage(MESSAGE_INFO_DESCR, cache:sub(1, -3)) return false end if action == "add" then local item = split[2]:gsub("%s+", "", 1) local itemType = ItemType(item) if itemType:getId() == 0 then itemType = ItemType(tonumber(item)) if itemType:getName() == '' then player:sendCancelMessage("There is no item with that id or name.") return false end end if player:getItemFromAutoLoot(itemType:getId()) then player:sendCancelMessage("You're already autolooting this item.") return false end player:addItemToAutoLoot(itemType:getId()) player:sendTextMessage(MESSAGE_INFO_DESCR, "You're now auto looting " .. itemType:getName()) return false elseif action == "remove" then local item = split[2]:gsub("%s+", "", 1) local itemType = ItemType(item) if itemType:getId() == 0 then itemType = ItemType(tonumber(item)) if itemType:getName() == '' then player:sendCancelMessage("There is no item with that id or name.") return false end end if player:getItemFromAutoLoot(itemType:getId()) then player:removeItemFromAutoLoot(itemType:getId()) player:sendTextMessage(MESSAGE_INFO_DESCR, "You removed the " .. itemType:getName() .. " from your loot list.") else player:sendCancelMessage("This item does not exist in your loot list.") end return false end player:sendTextMessage(MESSAGE_EVENT_ORANGE, "Auto Loot commands (items are automatically moved to your bp if you open monster corpse):"..'\n'.."!addloot add, nameItem - add item to auto loot by name"..'\n'.."!autoloot remove, itemName - remove item from auto loot by name"..'\n'.."!autoloot list - list your current auto loot items") return false end talk:separator(" ") talk:register()
É isso, espero que gostem do sisteminha
Se você encontrar algum bug, deixe-me saber.
Falta fazer:
Optimizar a mensagem de loot.
Adicionar ModalWindow.
Cheers~
-
Pedriinz recebeu reputação de DdJs em Auto Loot Sytem for TFS 1.3 + revscriptsDepois de milhões de anos sem programar porcaria nenhuma... Eu desenvolvi este sistema como um método de estudo. (C++)
Este sistema foi inspirado no Auto Loot System por @psychonaut. (OTland)
Criei o mesmo na versão mais recente do tfs.
Auto Loot System for TFS 1.3
Como funciona?
Simples, quando você mata um monstro e abre o corpo (você precisa clicar no corpo), os itens vão para o seu personagem.
Instalando
em actions.cpp, encontre:
if (corpseOwner != 0 && !player->canOpenCorpse(corpseOwner)) { return RETURNVALUE_YOUARENOTTHEOWNER; } e mude isso para:
if (corpseOwner != 0 && !player->canOpenCorpse(corpseOwner)) { return RETURNVALUE_YOUARENOTTHEOWNER; } else { if (player->canOpenCorpse(corpseOwner) && player->autoLootList.size() != 0) { if (player->getCapacity() > 100 * 100) { //Minimum of Capacity for autoloot works. (100 CAP) for (Item* item : container->getItemList()) { if (player->getItemFromAutoLoot(item->getID())) { std::ostringstream msgAutoLoot; msgAutoLoot << "You looted a " << item->getItemCount() << "x " << item->getName() << "."; g_game.internalMoveItem(container, player, CONST_SLOT_WHEREEVER, item, item->getItemCount(), nullptr); player->sendTextMessage(MESSAGE_INFO_DESCR, msgAutoLoot.str()); } } } else { player->sendTextMessage(MESSAGE_INFO_DESCR, "Sorry, you don't have enough capacity to use auto loot, so it has been disabled. (100+ capacity is required)"); } } } em player.h, abaixo de:
std::unordered_set<uint32_t> VIPList; adicione isso:
std::set<uint32_t> autoLootList; ainda em player.h encontre:
bool hasLearnedInstantSpell(const std::string& spellName) const; adicione em baixo:
void addItemToAutoLoot(uint16_t itemId); void removeItemFromAutoLoot(uint16_t itemId); bool getItemFromAutoLoot(uint16_t itemId); em player.cpp no final do arquivo, adicione:
void Player::addItemToAutoLoot(uint16_t itemId) { autoLootList.insert(itemId); } void Player::removeItemFromAutoLoot(uint16_t itemId) { autoLootList.erase(itemId); } bool Player::getItemFromAutoLoot(const uint16_t itemId) { return autoLootList.find(itemId) != autoLootList.end(); } em luascript.cpp encontre:
registerMethod("Player", "getFightMode", LuaScriptInterface::luaPlayerGetFightMode); e adicione em baixo:
registerMethod("Player", "addItemToAutoLoot", LuaScriptInterface::luaPlayerAddItemToAutoLoot); registerMethod("Player", "removeItemFromAutoLoot", LuaScriptInterface::luaPlayerRemoveItemFromAutoLoot); registerMethod("Player", "getItemFromAutoLoot", LuaScriptInterface::luaPlayerGetItemFromAutoLoot); registerMethod("Player", "getAutoLootList", LuaScriptInterface::luaPlayerGetAutoLootList); ainda em luascript.cpp encontre essa função:
int LuaScriptInterface::luaPlayerGetFightMode(lua_State* L) { // player:getFightMode() Player* player = getUserdata<Player>(L, 1); if (player) { lua_pushnumber(L, player->fightMode); } else { lua_pushnil(L); } return 1; }
abaixo dela, adicione:
int LuaScriptInterface::luaPlayerAddItemToAutoLoot(lua_State* L) { // player:addItemToAutoLoot(itemId) Player* player = getUserdata<Player>(L, 1); if (!player) { lua_pushnil(L); return 1; } uint16_t itemId; if (isNumber(L, 2)) { itemId = getNumber<uint16_t>(L, 2); } else { itemId = Item::items.getItemIdByName(getString(L, 2)); if (itemId == 0) { lua_pushnil(L); return 1; } } player->addItemToAutoLoot(itemId); pushBoolean(L, true); return 1; } int LuaScriptInterface::luaPlayerRemoveItemFromAutoLoot(lua_State* L) { // player:removeItemFromAutoLoot(itemId) Player* player = getUserdata<Player>(L, 1); if (!player) { lua_pushnil(L); return 1; } uint16_t itemId; if (isNumber(L, 2)) { itemId = getNumber<uint16_t>(L, 2); } else { itemId = Item::items.getItemIdByName(getString(L, 2)); if (itemId == 0) { lua_pushnil(L); return 1; } } player->removeItemFromAutoLoot(itemId); pushBoolean(L, true); return 1; } int LuaScriptInterface::luaPlayerGetItemFromAutoLoot(lua_State* L) { // player:getItemFromAutoLoot(itemId) Player* player = getUserdata<Player>(L, 1); if (!player) { lua_pushnil(L); return 1; } uint16_t itemId; if (isNumber(L, 2)) { itemId = getNumber<uint16_t>(L, 2); } else { itemId = Item::items.getItemIdByName(getString(L, 2)); if (itemId == 0) { lua_pushnil(L); return 1; } } if (player->getItemFromAutoLoot(itemId)) { pushBoolean(L, true); } else { pushBoolean(L, false); } return 1; } int LuaScriptInterface::luaPlayerGetAutoLootList(lua_State* L) { // player:getAutoLootList() Player* player = getUserdata<Player>(L, 1); if (player) { std::set<uint32_t> value = player->autoLootList; if (value.size() == 0) { lua_pushnil(L); return 1; } int index = 0; lua_createtable(L, value.size(), 0); for(auto i : value) { lua_pushnumber(L, i); lua_rawseti(L, -2, ++index); } } else { lua_pushnil(L); } return 1; }
em luascript.h encontre:
static int luaPlayerGetFightMode(lua_State* L);
adicione a baixo:
static int luaPlayerAddItemToAutoLoot(lua_State* L); static int luaPlayerRemoveItemFromAutoLoot(lua_State* L); static int luaPlayerGetItemFromAutoLoot(lua_State* L); static int luaPlayerGetAutoLootList(lua_State* L);
em iologindata.cpp encontre:
//load storage map query.str(std::string()); query << "SELECT `key`, `value` FROM `player_storage` WHERE `player_id` = " << player->getGUID(); if ((result = db.storeQuery(query.str()))) { do { player->addStorageValue(result->getNumber<uint32_t>("key"), result->getNumber<int32_t>("value"), true); } while (result->next()); }
e adicione em baixo:
query.str(std::string()); query << "SELECT `autoloot_list` FROM `player_autoloot` WHERE `player_id` = " << player->getGUID(); if ((result = db.storeQuery(query.str()))) { unsigned long lootlistSize; const char* autolootlist = result->getStream("autoloot_list", lootlistSize); PropStream propStreamList; propStreamList.init(autolootlist, lootlistSize); int16_t value; int16_t item = propStreamList.read<int16_t>(value); while (item) { player->addItemToAutoLoot(value); item = propStreamList.read<int16_t>(value); } }
acima de:
//save inbox items adicione:
query.str(std::string()); query << "DELETE FROM `player_autoloot` WHERE `player_id` = " << player->getGUID(); if (!db.executeQuery(query.str())) { return false; } PropWriteStream propWriteStreamAutoLoot; for (auto i : player->autoLootList) { propWriteStreamAutoLoot.write<uint16_t>(i); } size_t lootlistSize; const char* autolootlist = propWriteStreamAutoLoot.getStream(lootlistSize); query.str(std::string()); DBInsert autolootQuery("INSERT INTO `player_autoloot` (`player_id`, `autoloot_list`) VALUES "); query << player->getGUID() << ',' << db.escapeBlob(autolootlist, lootlistSize); if (!autolootQuery.addRow(query)) { return false; } if (!autolootQuery.execute()) { return false; }
em sua database, execute esta query
CREATE TABLE player_autoloot ( id int NOT NULL AUTO_INCREMENT, player_id int NOT NULL, autoloot_list blob, PRIMARY KEY (id) );
agora vá em data/scripts/talkactions e crie esse arquivo LUA
autoloot.lua
local talk = TalkAction("!autoloot") function talk.onSay(player, words, param) local i = player:getAutoLootList() local cache = "Check your loot list: " local split = param:split(",") local action = split[1] if param == "list" then if i then for _, item in ipairs(i) do cache = cache .. (ItemType(item)):getName() .. ", " end else player:sendTextMessage(MESSAGE_INFO_DESCR, "Your list is empty! Add some item and try again.") return false end player:sendTextMessage(MESSAGE_INFO_DESCR, cache:sub(1, -3)) return false end if action == "add" then local item = split[2]:gsub("%s+", "", 1) local itemType = ItemType(item) if itemType:getId() == 0 then itemType = ItemType(tonumber(item)) if itemType:getName() == '' then player:sendCancelMessage("There is no item with that id or name.") return false end end if player:getItemFromAutoLoot(itemType:getId()) then player:sendCancelMessage("You're already autolooting this item.") return false end player:addItemToAutoLoot(itemType:getId()) player:sendTextMessage(MESSAGE_INFO_DESCR, "You're now auto looting " .. itemType:getName()) return false elseif action == "remove" then local item = split[2]:gsub("%s+", "", 1) local itemType = ItemType(item) if itemType:getId() == 0 then itemType = ItemType(tonumber(item)) if itemType:getName() == '' then player:sendCancelMessage("There is no item with that id or name.") return false end end if player:getItemFromAutoLoot(itemType:getId()) then player:removeItemFromAutoLoot(itemType:getId()) player:sendTextMessage(MESSAGE_INFO_DESCR, "You removed the " .. itemType:getName() .. " from your loot list.") else player:sendCancelMessage("This item does not exist in your loot list.") end return false end player:sendTextMessage(MESSAGE_EVENT_ORANGE, "Auto Loot commands (items are automatically moved to your bp if you open monster corpse):"..'\n'.."!addloot add, nameItem - add item to auto loot by name"..'\n'.."!autoloot remove, itemName - remove item from auto loot by name"..'\n'.."!autoloot list - list your current auto loot items") return false end talk:separator(" ") talk:register()
É isso, espero que gostem do sisteminha
Se você encontrar algum bug, deixe-me saber.
Falta fazer:
Optimizar a mensagem de loot.
Adicionar ModalWindow.
Cheers~
-
Pedriinz recebeu reputação de EduardoDantas em (Resolvido)PROBLEMAS COM O PKTroque seu creature.lua por este:
function Creature:onChangeOutfit(outfit) return true end function Creature:onAreaCombat(tile, isAggressive) return RETURNVALUE_NOERROR end local function removeCombatProtection(cid) local player = Player(cid) if not player then return true end local time = 0 if player:isMage() then time = 10 elseif player:isPaladin() then time = 20 else time = 30 end player:setStorageValue(Storage.combatProtectionStorage, 2) addEvent(function(cid) local player = Player(cid) if not player then return end player:setStorageValue(Storage.combatProtectionStorage, 0) player:remove() end, time * 1000, cid) end function Creature:onTargetCombat(target) if not self then return true end if target:isPlayer() then if self:isMonster() then local protectionStorage = target:getStorageValue(Storage.combatProtectionStorage) if target:getIp() == 0 then -- If player is disconnected, monster shall ignore to attack the player if not target:isPzLocked() then if protectionStorage <= 0 then addEvent(removeCombatProtection, 30 * 1000, target.uid) target:setStorageValue(Storage.combatProtectionStorage, 1) elseif protectionStorage == 1 then self:searchTarget() return RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER end end return true end if protectionStorage >= os.time() then return RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER end end end if PARTY_PROTECTION ~= 0 then if self:isPlayer() and target:isPlayer() then local party = self:getParty() if party then local targetParty = target:getParty() if targetParty and targetParty == party then return RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER end end end end if ADVANCED_SECURE_MODE ~= 0 then if self:isPlayer() and target:isPlayer() then if self:hasSecureMode() then return RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER end end end return true end E teste. (:
-
Pedriinz recebeu reputação de kihshero em (Resolvido)Ajuda a compilar OTXserver 10.98 no linux ubuntu 14.04Fica difícil de ajudar sem saber o que se passa, mas com toda certeza você está manipulando isso de forma incorreta.
Realize os seguintes passos, apague tudo que você baixou sobre.
Use os comandos a seguir de forma sequenciada e ordenada e tenha certeza de USAR todos os comandos que eu listar.
# apt-get install git cmake build-essential liblua5.2-dev libgmp3-dev libmysqlclient-dev libboost-system-dev libpugixml-dev # cd /home/ # git clone https://github.com/mattyx14/otxserver.git # cd /home/otxserver/path_10_9/ # mkdir build && cd build # cmake .. # make -
Pedriinz recebeu reputação de xWhiteWolf em [TFS 1.x] Anti BotComo o nome do tópico diz, eu trouxe para vocês um sistema de anti bot.
Minha intenção é atualizar este código ao máximo, deixando o mesmo bastante customizável.
Quaisquer erros ou problemas por favor me deixe saber.
Como ele funciona?
Após um jogador matar uma quantidade x de monstros, o sistema irá realizar uma verificação com ele para saber se o mesmo está ou não 100% afk.
Essa verificação é feita através de um channel que se abre após o jogador matar a quantidade de monstros, realizando uma pergunta para o jogador.
O que é possível configurar?
Praticamente tudo! Você também pode adicionar quantas perguntas desejar! Organizei o script para que qualquer um possa realizar as configurações que desejar. Confira:
ANTI_BOT_SYSTEM = { config = { minMonstersToCheck = 2, -- O sistema irá escolher aleatoriamente um número de monstros entre esses dois valores para verificar. maxMonstersToCheck = 4, channelId = 10, -- Id do channel que será aberto para realizar a verificação. timeToAnswer = 10, -- Quanto tempo em segundos o jogador tem para responder a verificação. monstersForNotCheck = {'rat', 'bug', 'tiger'}, -- Monstros que não serão verificados pelo sistema. notations = 3, -- Quantas notificações o jogador pode receber antes de ser banido. banDays = 1, -- Quantidade de dias o personagem vai ficar banido por utilizar bot. storageForNotations = 1222, -- Storage onde ficará salvo as notations. storageForOpenChat = 10383, -- Storage que permitira o chat ser aberto. (Aconselho não mudar). }, questions = { [1] = {question = 'Digite quantas letras possui a palavra: Carro', answer = '5'}, [2] = {question = 'O que significa Ying e Yang?', answer = 'bem e o mal'}, [3] = {question = 'Qual é a cor do sol?', answer = 'amarelo'}, --[numero seguinte] = {question = 'pergunta', answer = 'resposta'}, }, cache = { players = { --[player:getId()] = {count = 1} }, question = 0, }, messages = { reason = {msg = 'Você foi banido por utilizar bot 100% AFK.'}, notation = {msg = 'Você foi penalizado e recebeu um notificação. Lembre-se que após receber 3 notificações você será banido. Você possui %d notificações no momento.', type = MESSAGE_EVENT_ADVANCE}, attention = {msg = '[Anti-Bot] Atenção! Você só possui %d segundos para responder a verificação.', type = TALKTYPE_CHANNEL_O}, channel_enter = {msg = '[Anti-Bot] Você está sobre suspeitas de uso aplicativos não autorizados.\nPor favor, confirme a verificação a seguir, você possui %d segundos para isso.', type = TALKTYPE_CHANNEL_O}, channel_close = {msg = '[Anti-Bot] Para sua segurança, não é possivel fechar este channel antes da verificação. Por favor responda o que lhe foi perguntado para que não seja penalizado.', type = TALKTYPE_CHANNEL_O}, wrong_answer = {msg = '[Anti-Bot] Resposta errada, por favor tente novamente.', type = TALKTYPE_CHANNEL_O}, correct_answer = {msg = '[Anti-Bot] Você respondeu corretamente, obrigado e bom jogo! Você já pode fechar este channel.', type = TALKTYPE_CHANNEL_O}, unconfirmed = {msg = 'Você não realizou a verificação corretamente, por isso você foi penalizado. Este channel já pode ser fechado.', type = TALKTYPE_CHANNEL_O}, } }
Tudo dentro desses espaços pode ser configurado sem nenhuma complicação!
Instalação:
Vá na pasta creaturescript/scripts do seu servidor e crie um arquivo com o nome de antibot.lua e adicione o seguinte conteúdo:
--[[ ## SCRIPT BY: Pedriinz ## ## CONTACT SKYPE: pedrosz4 ## ]] ANTI_BOT_SYSTEM = { config = { minMonstersToCheck = 2, -- O sistema irá escolher aleatoriamente um número de monstros entre esses dois valores para verificar. maxMonstersToCheck = 4, channelId = 10, -- Id do channel que será aberto para realizar a verificação. timeToAnswer = 10, -- Quanto tempo em segundos o jogador tem para responder a verificação. monstersForNotCheck = {'rat', 'bug', 'tiger'}, -- Monstros que não serão verificados pelo sistema. notations = 3, -- Quantas notificações o jogador pode receber antes de ser banido. banDays = 1, -- Quantidade de dias o personagem vai ficar banido por utilizar bot. storageForNotations = 1222, -- Storage onde ficará salvo as notations. storageForOpenChat = 10383, -- Storage que permitira o chat ser aberto. (Aconselho não mudar). }, questions = { [1] = {question = 'Digite quantas letras possui a palavra: Carro', answer = '5'}, [2] = {question = 'O que significa Ying e Yang?', answer = 'bem e o mal'}, [3] = {question = 'Qual é a cor do sol?', answer = 'amarelo'}, --[numero seguinte] = {question = 'pergunta', answer = 'resposta'}, }, cache = { players = { --[player:getId()] = {count = 1} }, question = 0, }, messages = { reason = {msg = 'Você foi banido por utilizar bot 100% AFK.'}, notation = {msg = 'Você foi penalizado e recebeu um notificação. Lembre-se que após receber 3 notificações você será banido. Você possui %d notificações no momento.', type = MESSAGE_EVENT_ADVANCE}, attention = {msg = '[Anti-Bot] Atenção! Você só possui %d segundos para responder a verificação.', type = TALKTYPE_CHANNEL_O}, channel_enter = {msg = '[Anti-Bot] Você está sobre suspeitas de uso aplicativos não autorizados.\nPor favor, confirme a verificação a seguir, você possui %d segundos para isso.', type = TALKTYPE_CHANNEL_O}, channel_close = {msg = '[Anti-Bot] Para sua segurança, não é possivel fechar este channel antes da verificação. Por favor responda o que lhe foi perguntado para que não seja penalizado.', type = TALKTYPE_CHANNEL_O}, wrong_answer = {msg = '[Anti-Bot] Resposta errada, por favor tente novamente.', type = TALKTYPE_CHANNEL_O}, correct_answer = {msg = '[Anti-Bot] Você respondeu corretamente, obrigado e bom jogo! Você já pode fechar este channel.', type = TALKTYPE_CHANNEL_O}, unconfirmed = {msg = 'Você não realizou a verificação corretamente, por isso você foi penalizado. Este channel já pode ser fechado.', type = TALKTYPE_CHANNEL_O}, } } function vericationBot(cid) local player = Player(cid) local timeNow = os.time() if not player then return true end if not ANTI_BOT_SYSTEM.cache.players[player:getId()] or ANTI_BOT_SYSTEM.cache.players[player:getId()].verified == false then return true else player:sendChannelMessage("", ANTI_BOT_SYSTEM.messages.unconfirmed.msg, ANTI_BOT_SYSTEM.messages.unconfirmed.type, ANTI_BOT_SYSTEM.config.channelId) ANTI_BOT_SYSTEM.cache.players[player:getId()] = nil if player:getStorageValue(ANTI_BOT_SYSTEM.config.storageForNotations) < ANTI_BOT_SYSTEM.config.notations then if player:getStorageValue(ANTI_BOT_SYSTEM.config.storageForNotations) ~= -1 then player:setStorageValue(ANTI_BOT_SYSTEM.config.storageForNotations, math.max(player:getStorageValue(ANTI_BOT_SYSTEM.config.storageForNotations) + 1)) else player:setStorageValue(ANTI_BOT_SYSTEM.config.storageForNotations, 1) end player:teleportTo(player:getTown():getTemplePosition()) player:sendTextMessage(ANTI_BOT_SYSTEM.messages.notation.type, string.format(ANTI_BOT_SYSTEM.messages.notation.msg, math.max(player:getStorageValue(ANTI_BOT_SYSTEM.config.storageForNotations)))) else player:teleportTo(player:getTown():getTemplePosition()) db.query("INSERT INTO `account_bans` (`account_id`, `reason`, `banned_at`, `expires_at`, `banned_by`) VALUES (" ..getAccountNumberByPlayerName(player:getName())..", "..db.escapeString(ANTI_BOT_SYSTEM.messages.reason.msg)..", "..timeNow..", "..timeNow + (ANTI_BOT_SYSTEM.config.banDays * 86400) ..", 1)") player:remove() end end return true end function onKill(creature, target) local targetMonster = target:getMonster() local player = creature:getPlayer() local random = math.random(ANTI_BOT_SYSTEM.config.minMonstersToCheck, ANTI_BOT_SYSTEM.config.maxMonstersToCheck) if not targetMonster then return true end if isInArray(ANTI_BOT_SYSTEM.config.monstersForNotCheck, targetMonster:getName():lower()) then return true end if not ANTI_BOT_SYSTEM.cache.players[player:getId()] then ANTI_BOT_SYSTEM.cache.players[player:getId()] = {count = 1, verified = false} else if ANTI_BOT_SYSTEM.cache.players[player:getId()].count >= random then ANTI_BOT_SYSTEM.cache.players[player:getId()] = {count = math.max(ANTI_BOT_SYSTEM.cache.players[player:getId()].count), verified = true} player:openChannel(ANTI_BOT_SYSTEM.config.channelId) player:getPosition():sendMagicEffect(CONST_ME_TUTORIALSQUARE) else ANTI_BOT_SYSTEM.cache.players[player:getId()] = {count = math.max(ANTI_BOT_SYSTEM.cache.players[player:getId()].count) + 1, verified = false} end end return true end Após feito isso, abre o arquivo creaturescript/creaturescript.xml e adicione esta linha:
<!-- Anti Bot by Pedriinz --> <event type="kill" name="AntiBot" script="antibot.lua" /> Feito isso, abra o arquivo: creaturescript/scripts/others/login.lua e registre o script com a tag:
'AntiBot', Exemplo:
local events = { 'ElementalSpheresOverlords', 'BigfootBurdenVersperoth', 'Razzagorn', 'Shatterer', 'Zamulosh', 'The Hunger', 'AntiBot', } Agora, abre o arquivo chatchannels/chatchannels.xml e adicione a seguinte tag:
<channel id="10" name="Anti Bot" public="1" script="antibot.lua" /> Lembre-se que o ID deve ser o mesmo que você configurou no script principal lá em cima.
Agora abra a pasta chatchannels/scripts/ crie um script chamado antibot.lua e adicione:
function onJoin(player) if not player then return true end if not ANTI_BOT_SYSTEM.cache.players[player:getId()] or ANTI_BOT_SYSTEM.cache.players[player:getId()].verified == false then player:popupFYI('You can\'t open this channel.') return false end addEvent(function() player:sendChannelMessage("", string.format(ANTI_BOT_SYSTEM.messages.channel_enter.msg, ANTI_BOT_SYSTEM.config.timeToAnswer), ANTI_BOT_SYSTEM.messages.channel_enter.type, ANTI_BOT_SYSTEM.config.channelId) end, 300) addEvent(function() local random = math.random(#ANTI_BOT_SYSTEM.questions) player:sendChannelMessage("", ANTI_BOT_SYSTEM.questions[random].question, TALKTYPE_CHANNEL_R1, ANTI_BOT_SYSTEM.config.channelId) ANTI_BOT_SYSTEM.cache.question = random end, 2000) addEvent(vericationBot, ANTI_BOT_SYSTEM.config.timeToAnswer * 1000, player:getId()) return true end function onLeave(player) if not player then return true end if ANTI_BOT_SYSTEM.cache.players[player:getId()] then player:openChannel(ANTI_BOT_SYSTEM.config.channelId) addEvent(function() player:sendChannelMessage("", ANTI_BOT_SYSTEM.messages.channel_close.msg, ANTI_BOT_SYSTEM.messages.channel_close.type, ANTI_BOT_SYSTEM.config.channelId) end, 300) end end function onSpeak(player, type, message) player:sendChannelMessage(player:getName(), message, TALKTYPE_CHANNEL_Y, ANTI_BOT_SYSTEM.config.channelId) if message ~= ANTI_BOT_SYSTEM.questions[ANTI_BOT_SYSTEM.cache.question].answer then addEvent(function() player:sendChannelMessage("", ANTI_BOT_SYSTEM.messages.wrong_answer.msg, ANTI_BOT_SYSTEM.messages.wrong_answer.type, ANTI_BOT_SYSTEM.config.channelId) end, 300) else addEvent(function() player:sendChannelMessage("", ANTI_BOT_SYSTEM.messages.correct_answer.msg, ANTI_BOT_SYSTEM.messages.correct_answer.type, ANTI_BOT_SYSTEM.config.channelId) end, 300) ANTI_BOT_SYSTEM.cache.players[player:getId()] = nil end return false end Pronto! O seu antibot foi instalado com sucesso!
O código foi totalmente feito por mim, então os créditos são meus.
Qualquer sugestão para melhorias, por favor poste para que eu possa fazer
Abraços!
-
Pedriinz recebeu reputação de 139 em [TFS 1.x] Anti BotComo o nome do tópico diz, eu trouxe para vocês um sistema de anti bot.
Minha intenção é atualizar este código ao máximo, deixando o mesmo bastante customizável.
Quaisquer erros ou problemas por favor me deixe saber.
Como ele funciona?
Após um jogador matar uma quantidade x de monstros, o sistema irá realizar uma verificação com ele para saber se o mesmo está ou não 100% afk.
Essa verificação é feita através de um channel que se abre após o jogador matar a quantidade de monstros, realizando uma pergunta para o jogador.
O que é possível configurar?
Praticamente tudo! Você também pode adicionar quantas perguntas desejar! Organizei o script para que qualquer um possa realizar as configurações que desejar. Confira:
ANTI_BOT_SYSTEM = { config = { minMonstersToCheck = 2, -- O sistema irá escolher aleatoriamente um número de monstros entre esses dois valores para verificar. maxMonstersToCheck = 4, channelId = 10, -- Id do channel que será aberto para realizar a verificação. timeToAnswer = 10, -- Quanto tempo em segundos o jogador tem para responder a verificação. monstersForNotCheck = {'rat', 'bug', 'tiger'}, -- Monstros que não serão verificados pelo sistema. notations = 3, -- Quantas notificações o jogador pode receber antes de ser banido. banDays = 1, -- Quantidade de dias o personagem vai ficar banido por utilizar bot. storageForNotations = 1222, -- Storage onde ficará salvo as notations. storageForOpenChat = 10383, -- Storage que permitira o chat ser aberto. (Aconselho não mudar). }, questions = { [1] = {question = 'Digite quantas letras possui a palavra: Carro', answer = '5'}, [2] = {question = 'O que significa Ying e Yang?', answer = 'bem e o mal'}, [3] = {question = 'Qual é a cor do sol?', answer = 'amarelo'}, --[numero seguinte] = {question = 'pergunta', answer = 'resposta'}, }, cache = { players = { --[player:getId()] = {count = 1} }, question = 0, }, messages = { reason = {msg = 'Você foi banido por utilizar bot 100% AFK.'}, notation = {msg = 'Você foi penalizado e recebeu um notificação. Lembre-se que após receber 3 notificações você será banido. Você possui %d notificações no momento.', type = MESSAGE_EVENT_ADVANCE}, attention = {msg = '[Anti-Bot] Atenção! Você só possui %d segundos para responder a verificação.', type = TALKTYPE_CHANNEL_O}, channel_enter = {msg = '[Anti-Bot] Você está sobre suspeitas de uso aplicativos não autorizados.\nPor favor, confirme a verificação a seguir, você possui %d segundos para isso.', type = TALKTYPE_CHANNEL_O}, channel_close = {msg = '[Anti-Bot] Para sua segurança, não é possivel fechar este channel antes da verificação. Por favor responda o que lhe foi perguntado para que não seja penalizado.', type = TALKTYPE_CHANNEL_O}, wrong_answer = {msg = '[Anti-Bot] Resposta errada, por favor tente novamente.', type = TALKTYPE_CHANNEL_O}, correct_answer = {msg = '[Anti-Bot] Você respondeu corretamente, obrigado e bom jogo! Você já pode fechar este channel.', type = TALKTYPE_CHANNEL_O}, unconfirmed = {msg = 'Você não realizou a verificação corretamente, por isso você foi penalizado. Este channel já pode ser fechado.', type = TALKTYPE_CHANNEL_O}, } }
Tudo dentro desses espaços pode ser configurado sem nenhuma complicação!
Instalação:
Vá na pasta creaturescript/scripts do seu servidor e crie um arquivo com o nome de antibot.lua e adicione o seguinte conteúdo:
--[[ ## SCRIPT BY: Pedriinz ## ## CONTACT SKYPE: pedrosz4 ## ]] ANTI_BOT_SYSTEM = { config = { minMonstersToCheck = 2, -- O sistema irá escolher aleatoriamente um número de monstros entre esses dois valores para verificar. maxMonstersToCheck = 4, channelId = 10, -- Id do channel que será aberto para realizar a verificação. timeToAnswer = 10, -- Quanto tempo em segundos o jogador tem para responder a verificação. monstersForNotCheck = {'rat', 'bug', 'tiger'}, -- Monstros que não serão verificados pelo sistema. notations = 3, -- Quantas notificações o jogador pode receber antes de ser banido. banDays = 1, -- Quantidade de dias o personagem vai ficar banido por utilizar bot. storageForNotations = 1222, -- Storage onde ficará salvo as notations. storageForOpenChat = 10383, -- Storage que permitira o chat ser aberto. (Aconselho não mudar). }, questions = { [1] = {question = 'Digite quantas letras possui a palavra: Carro', answer = '5'}, [2] = {question = 'O que significa Ying e Yang?', answer = 'bem e o mal'}, [3] = {question = 'Qual é a cor do sol?', answer = 'amarelo'}, --[numero seguinte] = {question = 'pergunta', answer = 'resposta'}, }, cache = { players = { --[player:getId()] = {count = 1} }, question = 0, }, messages = { reason = {msg = 'Você foi banido por utilizar bot 100% AFK.'}, notation = {msg = 'Você foi penalizado e recebeu um notificação. Lembre-se que após receber 3 notificações você será banido. Você possui %d notificações no momento.', type = MESSAGE_EVENT_ADVANCE}, attention = {msg = '[Anti-Bot] Atenção! Você só possui %d segundos para responder a verificação.', type = TALKTYPE_CHANNEL_O}, channel_enter = {msg = '[Anti-Bot] Você está sobre suspeitas de uso aplicativos não autorizados.\nPor favor, confirme a verificação a seguir, você possui %d segundos para isso.', type = TALKTYPE_CHANNEL_O}, channel_close = {msg = '[Anti-Bot] Para sua segurança, não é possivel fechar este channel antes da verificação. Por favor responda o que lhe foi perguntado para que não seja penalizado.', type = TALKTYPE_CHANNEL_O}, wrong_answer = {msg = '[Anti-Bot] Resposta errada, por favor tente novamente.', type = TALKTYPE_CHANNEL_O}, correct_answer = {msg = '[Anti-Bot] Você respondeu corretamente, obrigado e bom jogo! Você já pode fechar este channel.', type = TALKTYPE_CHANNEL_O}, unconfirmed = {msg = 'Você não realizou a verificação corretamente, por isso você foi penalizado. Este channel já pode ser fechado.', type = TALKTYPE_CHANNEL_O}, } } function vericationBot(cid) local player = Player(cid) local timeNow = os.time() if not player then return true end if not ANTI_BOT_SYSTEM.cache.players[player:getId()] or ANTI_BOT_SYSTEM.cache.players[player:getId()].verified == false then return true else player:sendChannelMessage("", ANTI_BOT_SYSTEM.messages.unconfirmed.msg, ANTI_BOT_SYSTEM.messages.unconfirmed.type, ANTI_BOT_SYSTEM.config.channelId) ANTI_BOT_SYSTEM.cache.players[player:getId()] = nil if player:getStorageValue(ANTI_BOT_SYSTEM.config.storageForNotations) < ANTI_BOT_SYSTEM.config.notations then if player:getStorageValue(ANTI_BOT_SYSTEM.config.storageForNotations) ~= -1 then player:setStorageValue(ANTI_BOT_SYSTEM.config.storageForNotations, math.max(player:getStorageValue(ANTI_BOT_SYSTEM.config.storageForNotations) + 1)) else player:setStorageValue(ANTI_BOT_SYSTEM.config.storageForNotations, 1) end player:teleportTo(player:getTown():getTemplePosition()) player:sendTextMessage(ANTI_BOT_SYSTEM.messages.notation.type, string.format(ANTI_BOT_SYSTEM.messages.notation.msg, math.max(player:getStorageValue(ANTI_BOT_SYSTEM.config.storageForNotations)))) else player:teleportTo(player:getTown():getTemplePosition()) db.query("INSERT INTO `account_bans` (`account_id`, `reason`, `banned_at`, `expires_at`, `banned_by`) VALUES (" ..getAccountNumberByPlayerName(player:getName())..", "..db.escapeString(ANTI_BOT_SYSTEM.messages.reason.msg)..", "..timeNow..", "..timeNow + (ANTI_BOT_SYSTEM.config.banDays * 86400) ..", 1)") player:remove() end end return true end function onKill(creature, target) local targetMonster = target:getMonster() local player = creature:getPlayer() local random = math.random(ANTI_BOT_SYSTEM.config.minMonstersToCheck, ANTI_BOT_SYSTEM.config.maxMonstersToCheck) if not targetMonster then return true end if isInArray(ANTI_BOT_SYSTEM.config.monstersForNotCheck, targetMonster:getName():lower()) then return true end if not ANTI_BOT_SYSTEM.cache.players[player:getId()] then ANTI_BOT_SYSTEM.cache.players[player:getId()] = {count = 1, verified = false} else if ANTI_BOT_SYSTEM.cache.players[player:getId()].count >= random then ANTI_BOT_SYSTEM.cache.players[player:getId()] = {count = math.max(ANTI_BOT_SYSTEM.cache.players[player:getId()].count), verified = true} player:openChannel(ANTI_BOT_SYSTEM.config.channelId) player:getPosition():sendMagicEffect(CONST_ME_TUTORIALSQUARE) else ANTI_BOT_SYSTEM.cache.players[player:getId()] = {count = math.max(ANTI_BOT_SYSTEM.cache.players[player:getId()].count) + 1, verified = false} end end return true end Após feito isso, abre o arquivo creaturescript/creaturescript.xml e adicione esta linha:
<!-- Anti Bot by Pedriinz --> <event type="kill" name="AntiBot" script="antibot.lua" /> Feito isso, abra o arquivo: creaturescript/scripts/others/login.lua e registre o script com a tag:
'AntiBot', Exemplo:
local events = { 'ElementalSpheresOverlords', 'BigfootBurdenVersperoth', 'Razzagorn', 'Shatterer', 'Zamulosh', 'The Hunger', 'AntiBot', } Agora, abre o arquivo chatchannels/chatchannels.xml e adicione a seguinte tag:
<channel id="10" name="Anti Bot" public="1" script="antibot.lua" /> Lembre-se que o ID deve ser o mesmo que você configurou no script principal lá em cima.
Agora abra a pasta chatchannels/scripts/ crie um script chamado antibot.lua e adicione:
function onJoin(player) if not player then return true end if not ANTI_BOT_SYSTEM.cache.players[player:getId()] or ANTI_BOT_SYSTEM.cache.players[player:getId()].verified == false then player:popupFYI('You can\'t open this channel.') return false end addEvent(function() player:sendChannelMessage("", string.format(ANTI_BOT_SYSTEM.messages.channel_enter.msg, ANTI_BOT_SYSTEM.config.timeToAnswer), ANTI_BOT_SYSTEM.messages.channel_enter.type, ANTI_BOT_SYSTEM.config.channelId) end, 300) addEvent(function() local random = math.random(#ANTI_BOT_SYSTEM.questions) player:sendChannelMessage("", ANTI_BOT_SYSTEM.questions[random].question, TALKTYPE_CHANNEL_R1, ANTI_BOT_SYSTEM.config.channelId) ANTI_BOT_SYSTEM.cache.question = random end, 2000) addEvent(vericationBot, ANTI_BOT_SYSTEM.config.timeToAnswer * 1000, player:getId()) return true end function onLeave(player) if not player then return true end if ANTI_BOT_SYSTEM.cache.players[player:getId()] then player:openChannel(ANTI_BOT_SYSTEM.config.channelId) addEvent(function() player:sendChannelMessage("", ANTI_BOT_SYSTEM.messages.channel_close.msg, ANTI_BOT_SYSTEM.messages.channel_close.type, ANTI_BOT_SYSTEM.config.channelId) end, 300) end end function onSpeak(player, type, message) player:sendChannelMessage(player:getName(), message, TALKTYPE_CHANNEL_Y, ANTI_BOT_SYSTEM.config.channelId) if message ~= ANTI_BOT_SYSTEM.questions[ANTI_BOT_SYSTEM.cache.question].answer then addEvent(function() player:sendChannelMessage("", ANTI_BOT_SYSTEM.messages.wrong_answer.msg, ANTI_BOT_SYSTEM.messages.wrong_answer.type, ANTI_BOT_SYSTEM.config.channelId) end, 300) else addEvent(function() player:sendChannelMessage("", ANTI_BOT_SYSTEM.messages.correct_answer.msg, ANTI_BOT_SYSTEM.messages.correct_answer.type, ANTI_BOT_SYSTEM.config.channelId) end, 300) ANTI_BOT_SYSTEM.cache.players[player:getId()] = nil end return false end Pronto! O seu antibot foi instalado com sucesso!
O código foi totalmente feito por mim, então os créditos são meus.
Qualquer sugestão para melhorias, por favor poste para que eu possa fazer
Abraços!
-
Pedriinz recebeu reputação de luanluciano93 em [TFS 1.x] Anti BotComo o nome do tópico diz, eu trouxe para vocês um sistema de anti bot.
Minha intenção é atualizar este código ao máximo, deixando o mesmo bastante customizável.
Quaisquer erros ou problemas por favor me deixe saber.
Como ele funciona?
Após um jogador matar uma quantidade x de monstros, o sistema irá realizar uma verificação com ele para saber se o mesmo está ou não 100% afk.
Essa verificação é feita através de um channel que se abre após o jogador matar a quantidade de monstros, realizando uma pergunta para o jogador.
O que é possível configurar?
Praticamente tudo! Você também pode adicionar quantas perguntas desejar! Organizei o script para que qualquer um possa realizar as configurações que desejar. Confira:
ANTI_BOT_SYSTEM = { config = { minMonstersToCheck = 2, -- O sistema irá escolher aleatoriamente um número de monstros entre esses dois valores para verificar. maxMonstersToCheck = 4, channelId = 10, -- Id do channel que será aberto para realizar a verificação. timeToAnswer = 10, -- Quanto tempo em segundos o jogador tem para responder a verificação. monstersForNotCheck = {'rat', 'bug', 'tiger'}, -- Monstros que não serão verificados pelo sistema. notations = 3, -- Quantas notificações o jogador pode receber antes de ser banido. banDays = 1, -- Quantidade de dias o personagem vai ficar banido por utilizar bot. storageForNotations = 1222, -- Storage onde ficará salvo as notations. storageForOpenChat = 10383, -- Storage que permitira o chat ser aberto. (Aconselho não mudar). }, questions = { [1] = {question = 'Digite quantas letras possui a palavra: Carro', answer = '5'}, [2] = {question = 'O que significa Ying e Yang?', answer = 'bem e o mal'}, [3] = {question = 'Qual é a cor do sol?', answer = 'amarelo'}, --[numero seguinte] = {question = 'pergunta', answer = 'resposta'}, }, cache = { players = { --[player:getId()] = {count = 1} }, question = 0, }, messages = { reason = {msg = 'Você foi banido por utilizar bot 100% AFK.'}, notation = {msg = 'Você foi penalizado e recebeu um notificação. Lembre-se que após receber 3 notificações você será banido. Você possui %d notificações no momento.', type = MESSAGE_EVENT_ADVANCE}, attention = {msg = '[Anti-Bot] Atenção! Você só possui %d segundos para responder a verificação.', type = TALKTYPE_CHANNEL_O}, channel_enter = {msg = '[Anti-Bot] Você está sobre suspeitas de uso aplicativos não autorizados.\nPor favor, confirme a verificação a seguir, você possui %d segundos para isso.', type = TALKTYPE_CHANNEL_O}, channel_close = {msg = '[Anti-Bot] Para sua segurança, não é possivel fechar este channel antes da verificação. Por favor responda o que lhe foi perguntado para que não seja penalizado.', type = TALKTYPE_CHANNEL_O}, wrong_answer = {msg = '[Anti-Bot] Resposta errada, por favor tente novamente.', type = TALKTYPE_CHANNEL_O}, correct_answer = {msg = '[Anti-Bot] Você respondeu corretamente, obrigado e bom jogo! Você já pode fechar este channel.', type = TALKTYPE_CHANNEL_O}, unconfirmed = {msg = 'Você não realizou a verificação corretamente, por isso você foi penalizado. Este channel já pode ser fechado.', type = TALKTYPE_CHANNEL_O}, } }
Tudo dentro desses espaços pode ser configurado sem nenhuma complicação!
Instalação:
Vá na pasta creaturescript/scripts do seu servidor e crie um arquivo com o nome de antibot.lua e adicione o seguinte conteúdo:
--[[ ## SCRIPT BY: Pedriinz ## ## CONTACT SKYPE: pedrosz4 ## ]] ANTI_BOT_SYSTEM = { config = { minMonstersToCheck = 2, -- O sistema irá escolher aleatoriamente um número de monstros entre esses dois valores para verificar. maxMonstersToCheck = 4, channelId = 10, -- Id do channel que será aberto para realizar a verificação. timeToAnswer = 10, -- Quanto tempo em segundos o jogador tem para responder a verificação. monstersForNotCheck = {'rat', 'bug', 'tiger'}, -- Monstros que não serão verificados pelo sistema. notations = 3, -- Quantas notificações o jogador pode receber antes de ser banido. banDays = 1, -- Quantidade de dias o personagem vai ficar banido por utilizar bot. storageForNotations = 1222, -- Storage onde ficará salvo as notations. storageForOpenChat = 10383, -- Storage que permitira o chat ser aberto. (Aconselho não mudar). }, questions = { [1] = {question = 'Digite quantas letras possui a palavra: Carro', answer = '5'}, [2] = {question = 'O que significa Ying e Yang?', answer = 'bem e o mal'}, [3] = {question = 'Qual é a cor do sol?', answer = 'amarelo'}, --[numero seguinte] = {question = 'pergunta', answer = 'resposta'}, }, cache = { players = { --[player:getId()] = {count = 1} }, question = 0, }, messages = { reason = {msg = 'Você foi banido por utilizar bot 100% AFK.'}, notation = {msg = 'Você foi penalizado e recebeu um notificação. Lembre-se que após receber 3 notificações você será banido. Você possui %d notificações no momento.', type = MESSAGE_EVENT_ADVANCE}, attention = {msg = '[Anti-Bot] Atenção! Você só possui %d segundos para responder a verificação.', type = TALKTYPE_CHANNEL_O}, channel_enter = {msg = '[Anti-Bot] Você está sobre suspeitas de uso aplicativos não autorizados.\nPor favor, confirme a verificação a seguir, você possui %d segundos para isso.', type = TALKTYPE_CHANNEL_O}, channel_close = {msg = '[Anti-Bot] Para sua segurança, não é possivel fechar este channel antes da verificação. Por favor responda o que lhe foi perguntado para que não seja penalizado.', type = TALKTYPE_CHANNEL_O}, wrong_answer = {msg = '[Anti-Bot] Resposta errada, por favor tente novamente.', type = TALKTYPE_CHANNEL_O}, correct_answer = {msg = '[Anti-Bot] Você respondeu corretamente, obrigado e bom jogo! Você já pode fechar este channel.', type = TALKTYPE_CHANNEL_O}, unconfirmed = {msg = 'Você não realizou a verificação corretamente, por isso você foi penalizado. Este channel já pode ser fechado.', type = TALKTYPE_CHANNEL_O}, } } function vericationBot(cid) local player = Player(cid) local timeNow = os.time() if not player then return true end if not ANTI_BOT_SYSTEM.cache.players[player:getId()] or ANTI_BOT_SYSTEM.cache.players[player:getId()].verified == false then return true else player:sendChannelMessage("", ANTI_BOT_SYSTEM.messages.unconfirmed.msg, ANTI_BOT_SYSTEM.messages.unconfirmed.type, ANTI_BOT_SYSTEM.config.channelId) ANTI_BOT_SYSTEM.cache.players[player:getId()] = nil if player:getStorageValue(ANTI_BOT_SYSTEM.config.storageForNotations) < ANTI_BOT_SYSTEM.config.notations then if player:getStorageValue(ANTI_BOT_SYSTEM.config.storageForNotations) ~= -1 then player:setStorageValue(ANTI_BOT_SYSTEM.config.storageForNotations, math.max(player:getStorageValue(ANTI_BOT_SYSTEM.config.storageForNotations) + 1)) else player:setStorageValue(ANTI_BOT_SYSTEM.config.storageForNotations, 1) end player:teleportTo(player:getTown():getTemplePosition()) player:sendTextMessage(ANTI_BOT_SYSTEM.messages.notation.type, string.format(ANTI_BOT_SYSTEM.messages.notation.msg, math.max(player:getStorageValue(ANTI_BOT_SYSTEM.config.storageForNotations)))) else player:teleportTo(player:getTown():getTemplePosition()) db.query("INSERT INTO `account_bans` (`account_id`, `reason`, `banned_at`, `expires_at`, `banned_by`) VALUES (" ..getAccountNumberByPlayerName(player:getName())..", "..db.escapeString(ANTI_BOT_SYSTEM.messages.reason.msg)..", "..timeNow..", "..timeNow + (ANTI_BOT_SYSTEM.config.banDays * 86400) ..", 1)") player:remove() end end return true end function onKill(creature, target) local targetMonster = target:getMonster() local player = creature:getPlayer() local random = math.random(ANTI_BOT_SYSTEM.config.minMonstersToCheck, ANTI_BOT_SYSTEM.config.maxMonstersToCheck) if not targetMonster then return true end if isInArray(ANTI_BOT_SYSTEM.config.monstersForNotCheck, targetMonster:getName():lower()) then return true end if not ANTI_BOT_SYSTEM.cache.players[player:getId()] then ANTI_BOT_SYSTEM.cache.players[player:getId()] = {count = 1, verified = false} else if ANTI_BOT_SYSTEM.cache.players[player:getId()].count >= random then ANTI_BOT_SYSTEM.cache.players[player:getId()] = {count = math.max(ANTI_BOT_SYSTEM.cache.players[player:getId()].count), verified = true} player:openChannel(ANTI_BOT_SYSTEM.config.channelId) player:getPosition():sendMagicEffect(CONST_ME_TUTORIALSQUARE) else ANTI_BOT_SYSTEM.cache.players[player:getId()] = {count = math.max(ANTI_BOT_SYSTEM.cache.players[player:getId()].count) + 1, verified = false} end end return true end Após feito isso, abre o arquivo creaturescript/creaturescript.xml e adicione esta linha:
<!-- Anti Bot by Pedriinz --> <event type="kill" name="AntiBot" script="antibot.lua" /> Feito isso, abra o arquivo: creaturescript/scripts/others/login.lua e registre o script com a tag:
'AntiBot', Exemplo:
local events = { 'ElementalSpheresOverlords', 'BigfootBurdenVersperoth', 'Razzagorn', 'Shatterer', 'Zamulosh', 'The Hunger', 'AntiBot', } Agora, abre o arquivo chatchannels/chatchannels.xml e adicione a seguinte tag:
<channel id="10" name="Anti Bot" public="1" script="antibot.lua" /> Lembre-se que o ID deve ser o mesmo que você configurou no script principal lá em cima.
Agora abra a pasta chatchannels/scripts/ crie um script chamado antibot.lua e adicione:
function onJoin(player) if not player then return true end if not ANTI_BOT_SYSTEM.cache.players[player:getId()] or ANTI_BOT_SYSTEM.cache.players[player:getId()].verified == false then player:popupFYI('You can\'t open this channel.') return false end addEvent(function() player:sendChannelMessage("", string.format(ANTI_BOT_SYSTEM.messages.channel_enter.msg, ANTI_BOT_SYSTEM.config.timeToAnswer), ANTI_BOT_SYSTEM.messages.channel_enter.type, ANTI_BOT_SYSTEM.config.channelId) end, 300) addEvent(function() local random = math.random(#ANTI_BOT_SYSTEM.questions) player:sendChannelMessage("", ANTI_BOT_SYSTEM.questions[random].question, TALKTYPE_CHANNEL_R1, ANTI_BOT_SYSTEM.config.channelId) ANTI_BOT_SYSTEM.cache.question = random end, 2000) addEvent(vericationBot, ANTI_BOT_SYSTEM.config.timeToAnswer * 1000, player:getId()) return true end function onLeave(player) if not player then return true end if ANTI_BOT_SYSTEM.cache.players[player:getId()] then player:openChannel(ANTI_BOT_SYSTEM.config.channelId) addEvent(function() player:sendChannelMessage("", ANTI_BOT_SYSTEM.messages.channel_close.msg, ANTI_BOT_SYSTEM.messages.channel_close.type, ANTI_BOT_SYSTEM.config.channelId) end, 300) end end function onSpeak(player, type, message) player:sendChannelMessage(player:getName(), message, TALKTYPE_CHANNEL_Y, ANTI_BOT_SYSTEM.config.channelId) if message ~= ANTI_BOT_SYSTEM.questions[ANTI_BOT_SYSTEM.cache.question].answer then addEvent(function() player:sendChannelMessage("", ANTI_BOT_SYSTEM.messages.wrong_answer.msg, ANTI_BOT_SYSTEM.messages.wrong_answer.type, ANTI_BOT_SYSTEM.config.channelId) end, 300) else addEvent(function() player:sendChannelMessage("", ANTI_BOT_SYSTEM.messages.correct_answer.msg, ANTI_BOT_SYSTEM.messages.correct_answer.type, ANTI_BOT_SYSTEM.config.channelId) end, 300) ANTI_BOT_SYSTEM.cache.players[player:getId()] = nil end return false end Pronto! O seu antibot foi instalado com sucesso!
O código foi totalmente feito por mim, então os créditos são meus.
Qualquer sugestão para melhorias, por favor poste para que eu possa fazer
Abraços!
-
Pedriinz recebeu reputação de eviltox em [TFS 1.x] Anti BotComo o nome do tópico diz, eu trouxe para vocês um sistema de anti bot.
Minha intenção é atualizar este código ao máximo, deixando o mesmo bastante customizável.
Quaisquer erros ou problemas por favor me deixe saber.
Como ele funciona?
Após um jogador matar uma quantidade x de monstros, o sistema irá realizar uma verificação com ele para saber se o mesmo está ou não 100% afk.
Essa verificação é feita através de um channel que se abre após o jogador matar a quantidade de monstros, realizando uma pergunta para o jogador.
O que é possível configurar?
Praticamente tudo! Você também pode adicionar quantas perguntas desejar! Organizei o script para que qualquer um possa realizar as configurações que desejar. Confira:
ANTI_BOT_SYSTEM = { config = { minMonstersToCheck = 2, -- O sistema irá escolher aleatoriamente um número de monstros entre esses dois valores para verificar. maxMonstersToCheck = 4, channelId = 10, -- Id do channel que será aberto para realizar a verificação. timeToAnswer = 10, -- Quanto tempo em segundos o jogador tem para responder a verificação. monstersForNotCheck = {'rat', 'bug', 'tiger'}, -- Monstros que não serão verificados pelo sistema. notations = 3, -- Quantas notificações o jogador pode receber antes de ser banido. banDays = 1, -- Quantidade de dias o personagem vai ficar banido por utilizar bot. storageForNotations = 1222, -- Storage onde ficará salvo as notations. storageForOpenChat = 10383, -- Storage que permitira o chat ser aberto. (Aconselho não mudar). }, questions = { [1] = {question = 'Digite quantas letras possui a palavra: Carro', answer = '5'}, [2] = {question = 'O que significa Ying e Yang?', answer = 'bem e o mal'}, [3] = {question = 'Qual é a cor do sol?', answer = 'amarelo'}, --[numero seguinte] = {question = 'pergunta', answer = 'resposta'}, }, cache = { players = { --[player:getId()] = {count = 1} }, question = 0, }, messages = { reason = {msg = 'Você foi banido por utilizar bot 100% AFK.'}, notation = {msg = 'Você foi penalizado e recebeu um notificação. Lembre-se que após receber 3 notificações você será banido. Você possui %d notificações no momento.', type = MESSAGE_EVENT_ADVANCE}, attention = {msg = '[Anti-Bot] Atenção! Você só possui %d segundos para responder a verificação.', type = TALKTYPE_CHANNEL_O}, channel_enter = {msg = '[Anti-Bot] Você está sobre suspeitas de uso aplicativos não autorizados.\nPor favor, confirme a verificação a seguir, você possui %d segundos para isso.', type = TALKTYPE_CHANNEL_O}, channel_close = {msg = '[Anti-Bot] Para sua segurança, não é possivel fechar este channel antes da verificação. Por favor responda o que lhe foi perguntado para que não seja penalizado.', type = TALKTYPE_CHANNEL_O}, wrong_answer = {msg = '[Anti-Bot] Resposta errada, por favor tente novamente.', type = TALKTYPE_CHANNEL_O}, correct_answer = {msg = '[Anti-Bot] Você respondeu corretamente, obrigado e bom jogo! Você já pode fechar este channel.', type = TALKTYPE_CHANNEL_O}, unconfirmed = {msg = 'Você não realizou a verificação corretamente, por isso você foi penalizado. Este channel já pode ser fechado.', type = TALKTYPE_CHANNEL_O}, } }
Tudo dentro desses espaços pode ser configurado sem nenhuma complicação!
Instalação:
Vá na pasta creaturescript/scripts do seu servidor e crie um arquivo com o nome de antibot.lua e adicione o seguinte conteúdo:
--[[ ## SCRIPT BY: Pedriinz ## ## CONTACT SKYPE: pedrosz4 ## ]] ANTI_BOT_SYSTEM = { config = { minMonstersToCheck = 2, -- O sistema irá escolher aleatoriamente um número de monstros entre esses dois valores para verificar. maxMonstersToCheck = 4, channelId = 10, -- Id do channel que será aberto para realizar a verificação. timeToAnswer = 10, -- Quanto tempo em segundos o jogador tem para responder a verificação. monstersForNotCheck = {'rat', 'bug', 'tiger'}, -- Monstros que não serão verificados pelo sistema. notations = 3, -- Quantas notificações o jogador pode receber antes de ser banido. banDays = 1, -- Quantidade de dias o personagem vai ficar banido por utilizar bot. storageForNotations = 1222, -- Storage onde ficará salvo as notations. storageForOpenChat = 10383, -- Storage que permitira o chat ser aberto. (Aconselho não mudar). }, questions = { [1] = {question = 'Digite quantas letras possui a palavra: Carro', answer = '5'}, [2] = {question = 'O que significa Ying e Yang?', answer = 'bem e o mal'}, [3] = {question = 'Qual é a cor do sol?', answer = 'amarelo'}, --[numero seguinte] = {question = 'pergunta', answer = 'resposta'}, }, cache = { players = { --[player:getId()] = {count = 1} }, question = 0, }, messages = { reason = {msg = 'Você foi banido por utilizar bot 100% AFK.'}, notation = {msg = 'Você foi penalizado e recebeu um notificação. Lembre-se que após receber 3 notificações você será banido. Você possui %d notificações no momento.', type = MESSAGE_EVENT_ADVANCE}, attention = {msg = '[Anti-Bot] Atenção! Você só possui %d segundos para responder a verificação.', type = TALKTYPE_CHANNEL_O}, channel_enter = {msg = '[Anti-Bot] Você está sobre suspeitas de uso aplicativos não autorizados.\nPor favor, confirme a verificação a seguir, você possui %d segundos para isso.', type = TALKTYPE_CHANNEL_O}, channel_close = {msg = '[Anti-Bot] Para sua segurança, não é possivel fechar este channel antes da verificação. Por favor responda o que lhe foi perguntado para que não seja penalizado.', type = TALKTYPE_CHANNEL_O}, wrong_answer = {msg = '[Anti-Bot] Resposta errada, por favor tente novamente.', type = TALKTYPE_CHANNEL_O}, correct_answer = {msg = '[Anti-Bot] Você respondeu corretamente, obrigado e bom jogo! Você já pode fechar este channel.', type = TALKTYPE_CHANNEL_O}, unconfirmed = {msg = 'Você não realizou a verificação corretamente, por isso você foi penalizado. Este channel já pode ser fechado.', type = TALKTYPE_CHANNEL_O}, } } function vericationBot(cid) local player = Player(cid) local timeNow = os.time() if not player then return true end if not ANTI_BOT_SYSTEM.cache.players[player:getId()] or ANTI_BOT_SYSTEM.cache.players[player:getId()].verified == false then return true else player:sendChannelMessage("", ANTI_BOT_SYSTEM.messages.unconfirmed.msg, ANTI_BOT_SYSTEM.messages.unconfirmed.type, ANTI_BOT_SYSTEM.config.channelId) ANTI_BOT_SYSTEM.cache.players[player:getId()] = nil if player:getStorageValue(ANTI_BOT_SYSTEM.config.storageForNotations) < ANTI_BOT_SYSTEM.config.notations then if player:getStorageValue(ANTI_BOT_SYSTEM.config.storageForNotations) ~= -1 then player:setStorageValue(ANTI_BOT_SYSTEM.config.storageForNotations, math.max(player:getStorageValue(ANTI_BOT_SYSTEM.config.storageForNotations) + 1)) else player:setStorageValue(ANTI_BOT_SYSTEM.config.storageForNotations, 1) end player:teleportTo(player:getTown():getTemplePosition()) player:sendTextMessage(ANTI_BOT_SYSTEM.messages.notation.type, string.format(ANTI_BOT_SYSTEM.messages.notation.msg, math.max(player:getStorageValue(ANTI_BOT_SYSTEM.config.storageForNotations)))) else player:teleportTo(player:getTown():getTemplePosition()) db.query("INSERT INTO `account_bans` (`account_id`, `reason`, `banned_at`, `expires_at`, `banned_by`) VALUES (" ..getAccountNumberByPlayerName(player:getName())..", "..db.escapeString(ANTI_BOT_SYSTEM.messages.reason.msg)..", "..timeNow..", "..timeNow + (ANTI_BOT_SYSTEM.config.banDays * 86400) ..", 1)") player:remove() end end return true end function onKill(creature, target) local targetMonster = target:getMonster() local player = creature:getPlayer() local random = math.random(ANTI_BOT_SYSTEM.config.minMonstersToCheck, ANTI_BOT_SYSTEM.config.maxMonstersToCheck) if not targetMonster then return true end if isInArray(ANTI_BOT_SYSTEM.config.monstersForNotCheck, targetMonster:getName():lower()) then return true end if not ANTI_BOT_SYSTEM.cache.players[player:getId()] then ANTI_BOT_SYSTEM.cache.players[player:getId()] = {count = 1, verified = false} else if ANTI_BOT_SYSTEM.cache.players[player:getId()].count >= random then ANTI_BOT_SYSTEM.cache.players[player:getId()] = {count = math.max(ANTI_BOT_SYSTEM.cache.players[player:getId()].count), verified = true} player:openChannel(ANTI_BOT_SYSTEM.config.channelId) player:getPosition():sendMagicEffect(CONST_ME_TUTORIALSQUARE) else ANTI_BOT_SYSTEM.cache.players[player:getId()] = {count = math.max(ANTI_BOT_SYSTEM.cache.players[player:getId()].count) + 1, verified = false} end end return true end Após feito isso, abre o arquivo creaturescript/creaturescript.xml e adicione esta linha:
<!-- Anti Bot by Pedriinz --> <event type="kill" name="AntiBot" script="antibot.lua" /> Feito isso, abra o arquivo: creaturescript/scripts/others/login.lua e registre o script com a tag:
'AntiBot', Exemplo:
local events = { 'ElementalSpheresOverlords', 'BigfootBurdenVersperoth', 'Razzagorn', 'Shatterer', 'Zamulosh', 'The Hunger', 'AntiBot', } Agora, abre o arquivo chatchannels/chatchannels.xml e adicione a seguinte tag:
<channel id="10" name="Anti Bot" public="1" script="antibot.lua" /> Lembre-se que o ID deve ser o mesmo que você configurou no script principal lá em cima.
Agora abra a pasta chatchannels/scripts/ crie um script chamado antibot.lua e adicione:
function onJoin(player) if not player then return true end if not ANTI_BOT_SYSTEM.cache.players[player:getId()] or ANTI_BOT_SYSTEM.cache.players[player:getId()].verified == false then player:popupFYI('You can\'t open this channel.') return false end addEvent(function() player:sendChannelMessage("", string.format(ANTI_BOT_SYSTEM.messages.channel_enter.msg, ANTI_BOT_SYSTEM.config.timeToAnswer), ANTI_BOT_SYSTEM.messages.channel_enter.type, ANTI_BOT_SYSTEM.config.channelId) end, 300) addEvent(function() local random = math.random(#ANTI_BOT_SYSTEM.questions) player:sendChannelMessage("", ANTI_BOT_SYSTEM.questions[random].question, TALKTYPE_CHANNEL_R1, ANTI_BOT_SYSTEM.config.channelId) ANTI_BOT_SYSTEM.cache.question = random end, 2000) addEvent(vericationBot, ANTI_BOT_SYSTEM.config.timeToAnswer * 1000, player:getId()) return true end function onLeave(player) if not player then return true end if ANTI_BOT_SYSTEM.cache.players[player:getId()] then player:openChannel(ANTI_BOT_SYSTEM.config.channelId) addEvent(function() player:sendChannelMessage("", ANTI_BOT_SYSTEM.messages.channel_close.msg, ANTI_BOT_SYSTEM.messages.channel_close.type, ANTI_BOT_SYSTEM.config.channelId) end, 300) end end function onSpeak(player, type, message) player:sendChannelMessage(player:getName(), message, TALKTYPE_CHANNEL_Y, ANTI_BOT_SYSTEM.config.channelId) if message ~= ANTI_BOT_SYSTEM.questions[ANTI_BOT_SYSTEM.cache.question].answer then addEvent(function() player:sendChannelMessage("", ANTI_BOT_SYSTEM.messages.wrong_answer.msg, ANTI_BOT_SYSTEM.messages.wrong_answer.type, ANTI_BOT_SYSTEM.config.channelId) end, 300) else addEvent(function() player:sendChannelMessage("", ANTI_BOT_SYSTEM.messages.correct_answer.msg, ANTI_BOT_SYSTEM.messages.correct_answer.type, ANTI_BOT_SYSTEM.config.channelId) end, 300) ANTI_BOT_SYSTEM.cache.players[player:getId()] = nil end return false end Pronto! O seu antibot foi instalado com sucesso!
O código foi totalmente feito por mim, então os créditos são meus.
Qualquer sugestão para melhorias, por favor poste para que eu possa fazer
Abraços!