GlobalEvent [TFS 1.x] Removendo House por Tempo OFF
-
Quem Está Navegando 0 membros estão online
Nenhum usuário registrado visualizando esta página.
-
Conteúdo Similar
-
Por FeeTads
salve rapaziada, estou fazendo uma quest no meu OT que é necessário faze-la durante 10 dias consecutivos, porém caso o player perca um dia, a storage da quest reseta.
Já tenho esses scripts prontos de 2 formas: global event que checa a storage de todos os player online no momento e caso ja tenha passado 24h ele tira a storage do player que está entre os 10 dias de quest.
E também tenho um creatureScript de onLogin() que quando o player loga, ele entra num loop de verificação a cada 60s
minha duvida: globalEvents vai checar todos os players online de uma só vez e fazer as alterações necessarias, isso pode lagar a distro, ou até mesmo crashar?
o creatureScript vai entrar num loop até o player deslogar, isso numa média de 250 pessoa são diversas verificações em momentos diferentes, pode acabar lagando ou crashando?
meu OT possui uma media de 300 pessoas online.
Script globalEvents é esse:
function onThink(interval, lastExecution)
local players = {}
local timer = os.time()
for _, pid in pairs (getPlayersOnline()) do
local storage = getPlayerStorageValue(pid, 1231234)
if getPlayerStorageValue(pid,888251) > 0 and getPlayerStorageValue(pid,888251) <= 9 then
if storage - timer <= 1 then
table.insert(players, pid)
end
end
end
if #players > 0 then
for i = 1, #players do
doPlayerSendTextMessage(players[i],22,"seu dano voltou ao normal por vc nao ter feito a quest!")
setPlayerStorageValue(players[i],888251,0)
end
end
return true
end
Script do Creature é esse:
local storage = getPlayerStorageValue(cid,1231234)
function checkStorage(cid) local timer = os.time()
if not isPlayer(cid) then return true end
if getPlayerStorageValue(cid,888251) > 0 and getPlayerStorageValue(cid, 888251) <= 9 then
if storage - timer <= 1 then
setPlayerStorageValue(cid,888251,0)
end
end
addEvent(function()
checkStorage(cid)
end, 60000)
end
function onLogin(cid)
checkStorage(cid)
return true
end
function onLogout(cid)
stopEvent(checkStorage[cid])
return true
end
caso os códigos nao estejam legiveis me avisem como arrumar em .lua pf
se quiserem usar os códigos podem usar a vontade kkkkkkk
-
Por Codex NG
Sorry I don't speak spanish so you will have to bare with me.
This is a new way for people to create npc's which use different types of currency, rather than a coming up with different items to trade with the npc or trying to edit the npc modules this method simplifies everything by providing the npc with a npc currency id.
All this npc currency id is, is a storage value.. pretty simple eh?
If the npc doesn't have a currency id then it will use the normal currency e.g. gold, plat, cc etc..
I originally posted this on otland, but fuck them xD
Using Lailene here you can see she has a currency attribute with id of 123456
<?xml version="1.0" encoding="UTF-8"?> <npc name="Lailene" currency="123456" script="lailene.lua" walkinterval="2000" floorchange="0" speechbubble="2"> <health now="100" max="100"/> <look type="279" head="114" body="94" legs="113" feet="114" addons="0"/> </npc>
Now any player who has a storage value of 123456 can purchase things from her shop provided they have enough value stored within the storage, similar to having money in the bank.
The money or in this case the storage value is added and removed from the player in real time.
Lets get to the code
game.cpp
Find this
bool Game::removeMoney(Cylinder* cylinder, uint64_t money, uint32_t flags /*= 0*/) Replace the whole function with this.
bool Game::removeMoney(Cylinder* cylinder, uint64_t money, uint32_t flags /*= 0*/) { if (cylinder == nullptr) { return false; } if (money == 0) { return true; } uint32_t currencyId = 0; Player* player; if (Creature* creature = cylinder->getCreature()) { if (Player* p = creature->getPlayer()) { currencyId = p->getNpcCurrencyId(); player = p; } } if (!currencyId) { std::vector<Container*> containers; std::multimap<uint32_t, Item*> moneyMap; uint64_t moneyCount = 0; for (size_t i = cylinder->getFirstIndex(), j = cylinder->getLastIndex(); i < j; ++i) { Thing* thing = cylinder->getThing(i); if (!thing) { continue; } Item* item = thing->getItem(); if (!item) { continue; } Container* container = item->getContainer(); if (container) { containers.push_back(container); } else { const uint32_t worth = item->getWorth(); if (worth != 0) { moneyCount += worth; moneyMap.emplace(worth, item); } } } size_t i = 0; while (i < containers.size()) { Container* container = containers[i++]; for (Item* item : container->getItemList()) { Container* tmpContainer = item->getContainer(); if (tmpContainer) { containers.push_back(tmpContainer); } else { const uint32_t worth = item->getWorth(); if (worth != 0) { moneyCount += worth; moneyMap.emplace(worth, item); } } } } if (moneyCount < money) { return false; } for (const auto& moneyEntry : moneyMap) { Item* item = moneyEntry.second; if (moneyEntry.first < money) { internalRemoveItem(item); money -= moneyEntry.first; } else if (moneyEntry.first > money) { const uint32_t worth = moneyEntry.first / item->getItemCount(); const uint32_t removeCount = (money / worth) + 1; addMoney(cylinder, (worth * removeCount) - money, flags); internalRemoveItem(item, removeCount); break; } else { internalRemoveItem(item); break; } } } else { int32_t value; player->getStorageValue(currencyId, value); if (value < money) { return false; } player->addStorageValue(currencyId, value - money); } return true; } Next find this
void Game::addMoney(Cylinder* cylinder, uint64_t money, uint32_t flags /*= 0*/) Replace the whole function with this
void Game::addMoney(Cylinder* cylinder, uint64_t money, uint32_t flags /*= 0*/) { if (money == 0) { return; } if (Creature* creature = cylinder->getCreature()) { if (Player* player = creature->getPlayer()) { if(uint32_t currencyId = player->getNpcCurrencyId()){ int32_t value; player->getStorageValue(currencyId, value); player->addStorageValue(currencyId, value + money); return; } } } uint32_t crystalCoins = money / 10000; money -= crystalCoins * 10000; while (crystalCoins > 0) { const uint16_t count = std::min<uint32_t>(100, crystalCoins); Item* remaindItem = Item::CreateItem(ITEM_CRYSTAL_COIN, count); ReturnValue ret = internalAddItem(cylinder, remaindItem, INDEX_WHEREEVER, flags); if (ret != RETURNVALUE_NOERROR) { internalAddItem(cylinder->getTile(), remaindItem, INDEX_WHEREEVER, FLAG_NOLIMIT); } crystalCoins -= count; } uint16_t platinumCoins = money / 100; if (platinumCoins != 0) { Item* remaindItem = Item::CreateItem(ITEM_PLATINUM_COIN, platinumCoins); ReturnValue ret = internalAddItem(cylinder, remaindItem, INDEX_WHEREEVER, flags); if (ret != RETURNVALUE_NOERROR) { internalAddItem(cylinder->getTile(), remaindItem, INDEX_WHEREEVER, FLAG_NOLIMIT); } money -= platinumCoins * 100; } if (money != 0) { Item* remaindItem = Item::CreateItem(ITEM_GOLD_COIN, money); ReturnValue ret = internalAddItem(cylinder, remaindItem, INDEX_WHEREEVER, flags); if (ret != RETURNVALUE_NOERROR) { internalAddItem(cylinder->getTile(), remaindItem, INDEX_WHEREEVER, FLAG_NOLIMIT); } } }
npc.cpp
Look for this
pugi::xml_attribute attr; if ((attr = npcNode.attribute("speed"))) { baseSpeed = pugi::cast<uint32_t>(attr.value()); } else { baseSpeed = 100; } Right underneath that you are going to place this.
if ((attr = npcNode.attribute("currency"))) { currency = pugi::cast<uint32_t>(attr.value()); }
npc.h
Look for this
bool isPushable() const final { return walkTicks > 0; } Place this right underneath
uint32_t getCurrencyId() const { return currency; } Look for this
uint32_t walkTicks; Place this right underneath
uint32_t currency;
player.cpp
Find this
void Player::openShopWindow(Npc* npc, const std::list<ShopInfo>& shop) Replace that function with this
void Player::openShopWindow(Npc* npc, const std::list<ShopInfo>& shop) { shopItemList = shop; sendShop(npc); sendSaleItemList(npc); } Next find this
bool Player::updateSaleShopList(const Item* item) Replace that function with this
bool Player::updateSaleShopList(const Item* item) { uint16_t itemId = item->getID(); if (itemId != ITEM_GOLD_COIN && itemId != ITEM_PLATINUM_COIN && itemId != ITEM_CRYSTAL_COIN) { auto it = std::find_if(shopItemList.begin(), shopItemList.end(), [itemId](const ShopInfo& shopInfo) { return shopInfo.itemId == itemId && shopInfo.sellPrice != 0; }); if (it == shopItemList.end()) { const Container* container = item->getContainer(); if (!container) { return false; } const auto& items = container->getItemList(); return std::any_of(items.begin(), items.end(), [this](const Item* containerItem) { return updateSaleShopList(containerItem); }); } } if (client) { client->sendSaleItemList(shopOwner, shopItemList); } return true; } Next you are going to look for
uint64_t Player::getMoney() const Now right underneath that function you are going to place these.
uint64_t Player::getMoney(Npc* npc) const { uint64_t cash; setNpcCurrencyId(npc); uint32_t currencyId = getNpcCurrencyId(); if (currencyId) { int32_t value; getStorageValue(currencyId, value); cash = (uint64_t)value; } else { cash = getMoney(); } return cash; } void Player::setNpcCurrencyId(Npc* npc) const{ currencyId = npc->getCurrencyId(); } uint32_t Player::getNpcCurrencyId() const { return currencyId; }
player.h
Look for this
uint64_t getMoney() const; Place this right underneath
uint64_t getMoney(Npc*) const; void setNpcCurrencyId(Npc*) const; uint32_t getNpcCurrencyId() const; Find this
void sendShop(Npc* npc) const { if (client) { client->sendShop(npc, shopItemList); } } Place this right underneath
void sendSaleItemList(Npc* npc) const { if (client) { client->sendSaleItemList(npc, shopItemList); } } Find this
uint32_t manaMax; Place this right underneath
mutable uint32_t currencyId;
protocolgame.cpp
Now find this function
void ProtocolGame::sendSaleItemList(const std::list<ShopInfo>& shop) Place this right underneath
void ProtocolGame::sendSaleItemList(Npc* npc, const std::list<ShopInfo>& shop) { NetworkMessage msg; msg.addByte(0x7B); msg.add<uint64_t>(player->getMoney(npc)); std::map<uint16_t, uint32_t> saleMap; if (shop.size() <= 5) { // For very small shops it's not worth it to create the complete map for (const ShopInfo& shopInfo : shop) { if (shopInfo.sellPrice == 0) { continue; } int8_t subtype = -1; const ItemType& itemType = Item::items[shopInfo.itemId]; if (itemType.hasSubType() && !itemType.stackable) { subtype = (shopInfo.subType == 0 ? -1 : shopInfo.subType); } uint32_t count = player->getItemTypeCount(shopInfo.itemId, subtype); if (count > 0) { saleMap[shopInfo.itemId] = count; } } } else { // Large shop, it's better to get a cached map of all item counts and use it // We need a temporary map since the finished map should only contain items // available in the shop std::map<uint32_t, uint32_t> tempSaleMap; player->getAllItemTypeCount(tempSaleMap); // We must still check manually for the special items that require subtype matches // (That is, fluids such as potions etc., actually these items are very few since // health potions now use their own ID) for (const ShopInfo& shopInfo : shop) { if (shopInfo.sellPrice == 0) { continue; } int8_t subtype = -1; const ItemType& itemType = Item::items[shopInfo.itemId]; if (itemType.hasSubType() && !itemType.stackable) { subtype = (shopInfo.subType == 0 ? -1 : shopInfo.subType); } if (subtype != -1) { uint32_t count; if (!itemType.isFluidContainer() && !itemType.isSplash()) { count = player->getItemTypeCount(shopInfo.itemId, subtype); // This shop item requires extra checks } else { count = subtype; } if (count > 0) { saleMap[shopInfo.itemId] = count; } } else { std::map<uint32_t, uint32_t>::const_iterator findIt = tempSaleMap.find(shopInfo.itemId); if (findIt != tempSaleMap.end() && findIt->second > 0) { saleMap[shopInfo.itemId] = findIt->second; } } } } uint8_t itemsToSend = std::min<size_t>(saleMap.size(), std::numeric_limits<uint8_t>::max()); msg.addByte(itemsToSend); uint8_t i = 0; for (std::map<uint16_t, uint32_t>::const_iterator it = saleMap.begin(); i < itemsToSend; ++it, ++i) { msg.addItemId(it->first); msg.addByte(std::min<uint32_t>(it->second, std::numeric_limits<uint8_t>::max())); } writeToOutputBuffer(msg); }
protocolgame.h
Find this
void sendSaleItemList(const std::list<ShopInfo>& shop); Place this right underneath
void sendSaleItemList(Npc* npc, const std::list<ShopInfo>& shop);
luascript.cpp
Find
int LuaScriptInterface::luaPlayerAddMoney(lua_State* L) Replace that whole function with this
int LuaScriptInterface::luaPlayerAddMoney(lua_State* L) { // player:addMoney(money[, currencyId]) uint64_t money = getNumber<uint64_t>(L, 2); uint32_t currencyId = getNumber<uint32_t>(L, 3); Player* player = getUserdata<Player>(L, 1); if (player) { if (currencyId) { int32_t value; player->getStorageValue(currencyId, value); player->addStorageValue(currencyId, value + money); } else { g_game.addMoney(player, money); } pushBoolean(L, true); } else { lua_pushnil(L); } return 1; } Next find this function which should be right below it.
int LuaScriptInterface::luaPlayerRemoveMoney(lua_State* L) Replace that whole function with this
int LuaScriptInterface::luaPlayerRemoveMoney(lua_State* L) { // player:removeMoney(money[, currencyId]) Player* player = getUserdata<Player>(L, 1); if (player) { uint64_t money = getNumber<uint64_t>(L, 2); uint32_t currencyId = getNumber<uint32_t>(L, 3); if (currencyId) { int32_t value; player->getStorageValue(currencyId, value); if (value < money) { pushBoolean(L, false); return 1; } player->addStorageValue(currencyId, value - money); pushBoolean(L, true); } else { pushBoolean(L, g_game.removeMoney(player, money)); } } else { lua_pushnil(L); } return 1; }
-
Por Guilherme.
Olá galera, vim trazer mais um maravilhoso e criativo script do Teckman.
*OBS; O Script não contém todos os items para todas as estações.
Funciona assim: Quando você abrir o server ele irá substituir os items de acordo com as estações do ano, por exemplo, vai substituir as árvores por árvores de neve, pedras por pedras de neve, e assim por diante.
O Script vai ser executado logo que o server ligar pois ocupa muito do CPU e da memória RAM, mas apenas para grandes mapas e por pouco tempo.
Entre em /globalevents/scripts/ e então crie o arquivo seasons.lua, coloque o código abaixo no arquivo, salve e feche.
local config = { areas = { [1] = { {x = 954, y = 1001, z = 7}, {x = 992, y = 1026, z = 7} } }, items = { ["winter"] = { [2700] = 2698, -- fir tree [2705] = 8139, -- pear tree [2703] = 2697, -- plum tree [2704] = 7020, -- red maple [2706] = 7071, -- yellow maple [2701] = 2698, -- sycamore [2707] = 7022, -- beech [2708] = 7020, -- poplar [2711] = 7021, -- dwarf tree [2712] = 7023, -- pine [4526] = 6580, -- grass [4527] = 6581, -- grass [4528] = 6582, -- grass [4529] = 6583, -- grass [4530] = 6584, -- grass [4531] = 6585, -- grass [4532] = 6586, -- grass [4533] = 6587, -- grass [4534] = 6588, -- grass [4535] = 6589, -- grass [4536] = 6590, -- grass [4537] = 6591, -- grass [4538] = 6592, -- grass [4539] = 6593, -- grass [4540] = 6580, -- grass [4541] = 6580, -- grass [6216] = 6715, -- grass tuffs [6217] = 6716, -- grass tuffs [6218] = 6717, -- grass tuffs [6219] = 6718, -- grass tuffs [387] = 6966, -- stalagmite [3610] = 6611, -- stones [3614] = 6610, -- stones [3666] = 6713, -- stone [3667] = 6714, -- stone [3668] = 6715, -- stone [468] = 483, -- hole [469] = 484, -- hole [3310] = 485, -- hole [3607] = 6999, -- medium stone [3609] = 7003, -- medium stone [3616] = 7002, -- medium stone [3663] = 7016, -- big stone [3664] = 7017, -- big stone [3615] = 7000, -- medium stone [3608] = 7001, -- medium stone [3659] = 7018, -- medium stone [3660] = 7019, -- medium stone [3617] = 7004, -- big stone [3618] = 7005, -- big stone [3619] = 7006, -- big stone [3620] = 7007, -- big stone [3624] = 7008, -- big stone [3625] = 7009, -- big stone [3626] = 7010, -- big stone [3627] = 7011, -- big stone [3628] = 7012, -- big stone [3629] = 7013, -- big stone [3630] = 7014, -- big stone [3631] = 7015, -- big stone [4470] = 6768, -- mountain [4471] = 6720, -- mountain [4472] = 6719, -- mountain [4476] = 6724, -- mountain [4477] = 6725, -- mountain [4478] = 6726, -- mountain [4479] = 6727, -- mountain [4473] = 6721, -- mountain [4474] = 6722, -- mountain [4475] = 6723, -- mountain [4468] = 6762, -- mountain [4469] = 6761, -- mountain [4542] = 4737, -- grass border [4543] = 4738, -- grass border [4544] = 4739, -- grass border [4545] = 4740, -- grass border [4546] = 4741, -- grass border [4547] = 4742, -- grass border [4548] = 4743, -- grass border [4549] = 4744, -- grass border [4550] = 4745, -- grass border [4551] = 4746, -- grass border [4552] = 4747, -- grass border [4553] = 4748, -- grass border } }, seasons = { ["monday"] = "winter", ["tuesday"] = "winter", ["wednesday"] = "autumn", ["thursday"] = "autumn", ["friday"] = "spring", ["saturday"] = "summer", ["sunday"] = "summer" } } function onStartup () doSetGameState(GAMESTATE_CLOSED) addEvent(doSetGameState, 1000 * 15, GAMESTATE_NORMAL) for i = 1, table.maxn(config.areas) do for x = ((config.areas)[i][1]).x, ((config.areas)[i][2]).x do for y = ((config.areas)[i][1]).y, ((config.areas)[i][2]).y do for z = ((config.areas)[i][1]).z, ((config.areas)[i][2]).z do for k, v in pairs(config.items[config.seasons[string.lower(os.date("%A"))]]) do pos = {x = x, y = y, z = z} if(getTileItemById(pos, k).uid > 0) then doTransformItem(getTileItemById(pos, k).uid, v) end end end end end end return true end Agora entre em /globalevents/globalevents.xml adicione a TAG abaixo, salve e feche. <globalevent name="seasons" type="start" event="script" value="seasons.lua"/>
E é isso galera, vocês estão livres para editar o código e adicionar/retirar items, para fazer isso use o map editor ou então o arquivo items.xml para verificar o ID dos items.
-
Por DeCarvalho
Bem procurei aqui na comunidade um VIP System mais informativo e nada, além de ter tido problema com os que estão aqui e acabei achando em outro lugar um que funcionou perfeitamente para mim.
Usando tfs disponibilizado neste tópico http://www.tibiaking.com/forum/topic/53099-1078-tfs-12-cast-system-novos-outfits-mounts/
Só estou trazendo o conteúdo e por não conhecer bem não posso dar suporte mas do jeito que está é só 'instalar' e vai funcionar.
Creditos.: Summ
Sistema Vip
Talkaction !checkvip para todos os players
Talkaction /vip para membros da staff
- /vip adddays, NomedoPlayer, 5 --> Adiciona 5 dias vip para o Player. - /vip removedays, NomedoPlayer, 5 --> Remove 5 dias vip do Player. - /vip remove, PlayerName --> Remove todos os dias vip do Player. - /vip check, NomedoPlayer --> Checa quantos dias vip o Player tem. - /vip addinfinite, NomedoPlayer --> Adiciona tempo vip infinito para o Player.
Tiles VIP
Portas VIP / Actions
Items que adicionam dias VIP
ItemId 10135 adiciona 10 dias vip. ItemId 10134 adiciona 30 dias vip. ItemId 10133 adiciona 90 dias vip.
Imagens
Comando !checkvip mas sem ter vip
Comando /vip adddays, dracoknight, 5
Comando !checkvip após adicionar 5 dias
Comando /vip addinfinite, dracoknight
Comando !checkvip após usar infinite
Comando /vip remove, dracoknight
-
Por Diego767
Boa tarde, nao sei se estou no lugar certo para fazer a pergunta, mas vamos tentar...
Meu ot esta rodando bem, porem os itens e monstros mais novos nao tem (cobra sword, terra helmet, e nem os monstros que dropam isso)
O que eu poderia fazer para add eles, os itens e os monstros?
-
Posts Recomendados
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.