Ir para conteúdo

Wise

Membro
  • Registro em

  • Última visita

Histórico de Curtidas

  1. Gostei
    Wise recebeu reputação de premii em [Storage] Por dia   
    function onUse(cid)     local t = {item = {5432, 1}, stor = {50040, 50041}} -- {item = {itemID, amount}, stor = {storage, globalstorage}}     if getGlobalStorageValue(t.stor[2]) - os.time() < 1 then         if getPlayerStorageValue(cid, t.stor[1]) < 1 then             setPlayerStorageValue(cid, t.stor[1], 1)             setGlobalStorageValue(t.stor[2], os.time() + (24 * 3600))             doPlayerAddItem(cid, t.item[1], t.item[2])             doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You received '..t.item[2]..' '..t.item[1])         else             return doPlayerSendCancel(cid, 'You already have completed this quest.')         end     else         return doPlayerSendCancel(cid, 'Someone already has done this quest today, try tomorrow.')     end          return true end No caso, começará a valer o tempo de 24 horas, a partir do momento em que o player der use no item que contém o actionID/uniqueID estipulado na tag desse script.
  2. Obrigado
    Wise recebeu reputação de FeeTads em Npc que muda vocação por storage   
    exchanger.lua (data/npc/scripts):
     
    local tab = { [1] = {voc = 5, item = {1234, 5}, sto = {12345, 1}, -- [paraqualvocID] = {voc = novavocID, item {itemID, count}, sto = {storage, valordastorage}}, [2] = {voc = 6, item = {1234, 5}, sto = {12345, 1}, [3] = {voc = 7, item = {1234, 5}, sto = {12345, 1}, [4] = {voc = 8, item = {1234, 5}, sto = {12345, 1} } local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} function onCreatureAppear(cid)              npcHandler:onCreatureAppear(cid) end function onCreatureDisappear(cid)           npcHandler:onCreatureDisappear(cid) end function onCreatureSay(cid, type, msg)  npcHandler:onCreatureSay(cid, type, msg) end function onThink()                      npcHandler:onThink() end function creatureSayCallback(cid, type, msg)     if (not npcHandler:isFocused(cid)) then         return false     end          local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid     if(msgcontains(msg, 'favor')) then         talkState[talkUser] = 1         selfSay('You need to bring me '..tab[getPlayerVocation].item[2]..' '..getItemNameById(tab[getPlayerVocation].item[1])..' and then I can {change} your vocation.', cid)     elseif(msgcontains(msg, 'change') and talkState[talkUser] == 1) then         talkState[talkUser] = 2         selfSay('Are you sure you want to do this change?', cid)     elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2) then         if(getPlayerVocation(cid) ~= tab[getPlayerVocation(cid)].voc) then             if(tab[getPlayerVocation(cid)] and getPlayerStorageValue(cid, tab[getPlayerVocation(cid)].sto[1]) > tab[getPlayerVocation(cid)].sto[2]) then                 if(doPlayerRemoveItem(cid, tab[getPlayerVocation(cid)].item[1], tab[getPlayerVocation(cid)].item[2]) == true) then                     talkState[talkUser] = 0                     doPlayerSetVocation(cid, tab[getPlayerVocation(cid)].voc)                     doSendMagicEffect(getThingPos(cid), CONST_ME_GIFT_WRAPS)                 else                     talkState[talkUser] = 0                     selfSay('You do not have the required items.', cid)                 end             else                 talkState[talkUser] = 0                 selfSay('You can not change your vocation.', cid)             end         else             talkState[talkUser] = 0             selfSay('You already have changed your vocation.', cid)         end     elseif(msgcontains(msg, 'no')) then         talkState[talkUser] = 0         selfSay('Sure. Goodbye!', cid)     end     return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())


    Exchanger.xml (data/npc):
    <npc name="Exchanger" script="data/npc/scripts/exchanger.lua" access="5" lookdir="1"> <health now="1000" max="1000"/> <look type="133" head="39" body="113" legs="38" feet="0" addons="3"/> <parameters> <parameter key="message_greet" value="Hello |PLAYERNAME|. I can change your vocation but before I need a {favor}." /> </parameters> </npc>
  3. Gostei
    Wise recebeu reputação de Orientalz em Item para o last hit / mais dano   
    Ambos (lasthitkiller / mostdamagekiller) recebem um item?
    Se for:

    bossreward.lua (data\creaturescripts\scripts):
    local lasthit = {5432, 1} -- lasthitkiller = {itemid, amount} local mostdmg = {5432, 1} -- mostdamagekiller = {itemid, amount} function doPlayerAddDepotItems(pid, item, count) -- function by magus - modified by vodkart     local item, count = {item}, {(count or 1)}          for k, v in ipairs(item) do         local ls = db.getResult("SELECT `sid` FROM `player_depotitems` WHERE `player_id` = "..pid.." ORDER BY `sid` DESC LIMIT 1")         return db.executeQuery("INSERT INTO `player_depotitems` (`player_id`, `sid`, `pid`, `itemtype`, `count`, `attributes`) VALUES ("..pid..", "..(ls:getDataInt("sid")+1)..", 101, "..v..", "..count[k]..", '')") or false     end      end function onDeath(cid, corpse, deathList)     local last, most = deathList[1], deathList[2]          if isPlayer(last) then         if getPlayerFreeCap(last) > getItemWeightById(lasthit[1], lasthit[2]) then             doPlayerAddItem(last, lasthit[1], lasthit[2])             doPlayerSendTextMessage(last, MESSAGE_INFO_DESCR, 'You have received a reward for being the player that gave the last hit on the BOSS.')         else             doPlayerAddDepotItems(last, lasthit[1], lasthit[2])             doPlayerSendTextMessage(last, MESSAGE_STATUS_CONSOLE_BLUE, 'You have received a reward for being the player that gave the last hit on the BOSS. But you don\'t have enought cap, so it was sent to your depot.')         end     end          if isPlayer(most) then         if getPlayerFreeCap(most) > getItemWeightById(mostdmg[1], mostdmg[2]) then             doPlayerAddItem(most, mostdmg[1], mostdmg[2])             doPlayerSendTextMessage(most, MESSAGE_INFO_DESCR, 'You have received a reward for being the player that gave the most damage on the BOSS.')         else             doPlayerAddDepotItems(most, mostdmg[1], mostdmg[2])             doPlayerSendTextMessage(most, MESSAGE_STATUS_CONSOLE_BLUE, 'You have received a reward for being the player that gave the most damage on the BOSS. But you don\'t have enought cap, so it was sent to your depot.')         end     end          return true end

     
    Tag - creaturescripts.xml (data\creaturescripts):
    <event type="death" name="BOSSReward" event="script" value="bossreward.lua"/>

     
    Registre o creature event no XML do monster:
    <script> <event name="BOSSReward"/> </script>
  4. Obrigado
    Wise recebeu reputação de maiconmnt em (Resolvido)Outfit e addon quest   
    outfits.xml (data/XML):

    Altere os parâmetros do outfit assassin (geralmente sendo o outfit ID 13) para como sendo:
    <outfit id="13" quest="31013">     <list gender="0" lookType="156" name="Assassin"/>     <list gender="1" lookType="152" name="Assassin"/> </outfit>

    ou
    <outfit id="13" storageId="31013" storageValue="1">     <list gender="0" lookType="156" name="Assassin"/>     <list gender="1" lookType="152" name="Assassin"/> </outfit>
     
    assassinquest.lua (data/actions/scripts):
    function onUse(cid, item, fromPos, item2, toPos)     local stor = 31013 -- storage     if getPlayerStorageValue(cid, stor) < 1 then         setPlayerStorageValue(cid, stor, 1)         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! Now you can wear your new outfit.")     else         doPlayerSendCancel(cid, "You already have picked up your outfit, it's empty.")     end     return true end


    Tag - actions.xml (data/actions):
    <action actionid="ACTIONID" script="assassinquest.lua"/>
    Basta fazer o mesmo processo com os outros outfits.
  5. Gostei
    Wise recebeu reputação de Cat em onMoveItem(cid, item, count, toContainer, fromContainer, ...)   
    Notei que alguns membros precisavam desse creature event pra desenvolver alguns sistemas, então eu resolvi compartilhá-lo com vocês.



    Na source, em creatureevent.cpp



    Abaixo de:
    else if(tmpStr == "preparedeath") m_type = CREATURE_EVENT_PREPAREDEATH;
     
    Adicione:
    else if(tmpStr == "moveitem") m_type = CREATURE_EVENT_MOVEITEM;
     
    Abaixo de:
    case CREATURE_EVENT_PREPAREDEATH: return "onPrepareDeath";
     
    Adicione:
    case CREATURE_EVENT_MOVEITEM: return "onMoveItem";
     
    Abaixo de:
    case CREATURE_EVENT_PREPAREDEATH: return "cid, deathList";
     
    Adicione:
    case CREATURE_EVENT_MOVEITEM: return "cid, item, count, toContainer, fromContainer, fromPos, toPos";
     
    Antes de:
    bool CreatureEvents::playerLogout(Player* player, bool forceLogout)
     
    Adicione:
    uint32_t CreatureEvent::executeMoveItem(Player* player, Item* item, uint8_t count, const Position& fromPos, const Position& toPos, Item* toContainer, Item* fromContainer, int16_t fstack) { //onMoveItem(cid, item, count, toContainer, fromContainer, fromPos, toPos) if(m_interface->reserveEnv()) { ScriptEnviroment* env = m_interface->getEnv(); if(m_scripted == EVENT_SCRIPT_BUFFER) { env->setRealPos(player->getPosition()); std::stringstream scriptstream; scriptstream << "local cid = " << env->addThing(player) << std::endl; env->streamThing(scriptstream, "item", item, env->addThing(item)); scriptstream << "local count = " << count << std::endl; env->streamThing(scriptstream, "toContainer", toContainer, env->addThing(toContainer)); env->streamThing(scriptstream, "fromContainer", fromContainer, env->addThing(fromContainer)); env->streamPosition(scriptstream, "fromPos", fromPos, fstack); env->streamPosition(scriptstream, "toPos", toPos, 0); scriptstream << m_scriptData; bool result = true; if(m_interface->loadBuffer(scriptstream.str())) { lua_State* L = m_interface->getState(); result = m_interface->getGlobalBool(L, "_result", true); } m_interface->releaseEnv(); return result; } else { #ifdef __DEBUG_LUASCRIPTS__ char desc[30]; sprintf(desc, "%s", player->getName().c_str()); env->setEvent(desc); #endif env->setScriptId(m_scriptId, m_interface); env->setRealPos(player->getPosition()); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(player)); LuaInterface::pushThing(L, item, env->addThing(item)); lua_pushnumber(L, count); LuaInterface::pushThing(L, toContainer, env->addThing(toContainer)); LuaInterface::pushThing(L, fromContainer, env->addThing(fromContainer)); LuaInterface::pushPosition(L, fromPos, fstack); LuaInterface::pushPosition(L, toPos, 0); bool result = m_interface->callFunction(7); m_interface->releaseEnv(); return result; } } else { std::clog << "[Error - CreatureEvent::executeMoveItem] Call stack overflow." << std::endl; return 0; } }

     
    Agora, em creatureevent.h


    Abaixo de:
    uint32_t executePrepareDeath(Creature* creature, DeathList deathList);
     
    Adicione:
    uint32_t executeMoveItem(Player* player, Item* item, uint8_t count, const Position& fromPos, const Position& toPos, Item* toContainer, Item* fromContainer, int16_t fstack);
     
    Procure por:
    CREATURE_EVENT_PREPAREDEATH
     
    Substitua por:
    CREATURE_EVENT_PREPAREDEATH, CREATURE_EVENT_MOVEITEM

     
    E em game.cpp


    Depois de:
    if(!canThrowObjectTo(mapFromPos, mapToPos) && !player->hasCustomFlag(PlayerCustomFlag_CanThrowAnywhere)) { player->sendCancelMessage(RET_CANNOTTHROW); return false; }
     
    Adicione:
    bool success = true; CreatureEventList moveitemEvents = player->getCreatureEvents(CREATURE_EVENT_MOVEITEM); for(CreatureEventList::iterator it = moveitemEvents.begin(); it != moveitemEvents.end(); ++it) { Item* toContainer = toCylinder->getItem(); Item* fromContainer = fromCylinder->getItem(); if(!(*it)->executeMoveItem(player, item, count, fromPos, toPos, (toContainer ? toContainer : 0), (fromContainer ? fromContainer : 0), fromStackpos) && success) success = false; } if(!success) return false;

     
    Um exemplo BEM simples do uso desse creature event:



    Tag:
    <event type="moveitem" name="MoveItem" event="script" value="moveitem.lua"/>

     
    moveitem.lua
    function onMoveItem(cid, item, count, toContainer, fromContainer, fromPos, toPos) local item = 12345 if item.itemid == item and getPlayerAccess(cid) < 4 then return doPlayerSendCancel(cid, 'You are not allowed to move this item.') and false end return true end Nessa estrutura de controle, se o item for o de ID 12345 e o cid tiver acesso menor do que 4, retornará false e ele não poderá mover o item.
    Se não for o caso, a checagem feita será false e retornará true, então o cid poderá mover o item.




    Esse callback registra creature event?
    Sim:
    registerCreatureEvent(cid, "MoveItem")  
    Créditos: Summ.
  6. Curtir
    Wise recebeu reputação de L3K0T em onMoveItem(cid, item, count, toContainer, fromContainer, ...)   
    Notei que alguns membros precisavam desse creature event pra desenvolver alguns sistemas, então eu resolvi compartilhá-lo com vocês.



    Na source, em creatureevent.cpp



    Abaixo de:
    else if(tmpStr == "preparedeath") m_type = CREATURE_EVENT_PREPAREDEATH;
     
    Adicione:
    else if(tmpStr == "moveitem") m_type = CREATURE_EVENT_MOVEITEM;
     
    Abaixo de:
    case CREATURE_EVENT_PREPAREDEATH: return "onPrepareDeath";
     
    Adicione:
    case CREATURE_EVENT_MOVEITEM: return "onMoveItem";
     
    Abaixo de:
    case CREATURE_EVENT_PREPAREDEATH: return "cid, deathList";
     
    Adicione:
    case CREATURE_EVENT_MOVEITEM: return "cid, item, count, toContainer, fromContainer, fromPos, toPos";
     
    Antes de:
    bool CreatureEvents::playerLogout(Player* player, bool forceLogout)
     
    Adicione:
    uint32_t CreatureEvent::executeMoveItem(Player* player, Item* item, uint8_t count, const Position& fromPos, const Position& toPos, Item* toContainer, Item* fromContainer, int16_t fstack) { //onMoveItem(cid, item, count, toContainer, fromContainer, fromPos, toPos) if(m_interface->reserveEnv()) { ScriptEnviroment* env = m_interface->getEnv(); if(m_scripted == EVENT_SCRIPT_BUFFER) { env->setRealPos(player->getPosition()); std::stringstream scriptstream; scriptstream << "local cid = " << env->addThing(player) << std::endl; env->streamThing(scriptstream, "item", item, env->addThing(item)); scriptstream << "local count = " << count << std::endl; env->streamThing(scriptstream, "toContainer", toContainer, env->addThing(toContainer)); env->streamThing(scriptstream, "fromContainer", fromContainer, env->addThing(fromContainer)); env->streamPosition(scriptstream, "fromPos", fromPos, fstack); env->streamPosition(scriptstream, "toPos", toPos, 0); scriptstream << m_scriptData; bool result = true; if(m_interface->loadBuffer(scriptstream.str())) { lua_State* L = m_interface->getState(); result = m_interface->getGlobalBool(L, "_result", true); } m_interface->releaseEnv(); return result; } else { #ifdef __DEBUG_LUASCRIPTS__ char desc[30]; sprintf(desc, "%s", player->getName().c_str()); env->setEvent(desc); #endif env->setScriptId(m_scriptId, m_interface); env->setRealPos(player->getPosition()); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(player)); LuaInterface::pushThing(L, item, env->addThing(item)); lua_pushnumber(L, count); LuaInterface::pushThing(L, toContainer, env->addThing(toContainer)); LuaInterface::pushThing(L, fromContainer, env->addThing(fromContainer)); LuaInterface::pushPosition(L, fromPos, fstack); LuaInterface::pushPosition(L, toPos, 0); bool result = m_interface->callFunction(7); m_interface->releaseEnv(); return result; } } else { std::clog << "[Error - CreatureEvent::executeMoveItem] Call stack overflow." << std::endl; return 0; } }

     
    Agora, em creatureevent.h


    Abaixo de:
    uint32_t executePrepareDeath(Creature* creature, DeathList deathList);
     
    Adicione:
    uint32_t executeMoveItem(Player* player, Item* item, uint8_t count, const Position& fromPos, const Position& toPos, Item* toContainer, Item* fromContainer, int16_t fstack);
     
    Procure por:
    CREATURE_EVENT_PREPAREDEATH
     
    Substitua por:
    CREATURE_EVENT_PREPAREDEATH, CREATURE_EVENT_MOVEITEM

     
    E em game.cpp


    Depois de:
    if(!canThrowObjectTo(mapFromPos, mapToPos) && !player->hasCustomFlag(PlayerCustomFlag_CanThrowAnywhere)) { player->sendCancelMessage(RET_CANNOTTHROW); return false; }
     
    Adicione:
    bool success = true; CreatureEventList moveitemEvents = player->getCreatureEvents(CREATURE_EVENT_MOVEITEM); for(CreatureEventList::iterator it = moveitemEvents.begin(); it != moveitemEvents.end(); ++it) { Item* toContainer = toCylinder->getItem(); Item* fromContainer = fromCylinder->getItem(); if(!(*it)->executeMoveItem(player, item, count, fromPos, toPos, (toContainer ? toContainer : 0), (fromContainer ? fromContainer : 0), fromStackpos) && success) success = false; } if(!success) return false;

     
    Um exemplo BEM simples do uso desse creature event:



    Tag:
    <event type="moveitem" name="MoveItem" event="script" value="moveitem.lua"/>

     
    moveitem.lua
    function onMoveItem(cid, item, count, toContainer, fromContainer, fromPos, toPos) local item = 12345 if item.itemid == item and getPlayerAccess(cid) < 4 then return doPlayerSendCancel(cid, 'You are not allowed to move this item.') and false end return true end Nessa estrutura de controle, se o item for o de ID 12345 e o cid tiver acesso menor do que 4, retornará false e ele não poderá mover o item.
    Se não for o caso, a checagem feita será false e retornará true, então o cid poderá mover o item.




    Esse callback registra creature event?
    Sim:
    registerCreatureEvent(cid, "MoveItem")  
    Créditos: Summ.
  7. Gostei
    Wise recebeu reputação de Sotten em Como coloca level para entrar na porta?   
    leveldoor.lua (data\actions\scripts)
    local level = 12000 function onUse(cid, fromPos, toPos) return getPlayerLevel(cid) >= level and doTeleportThing(cid, toPos) or doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Only players level '..level..' or higher can open this door.') and false end


    actions.xml (data\actions)
    <action actionid="XXXXX" event="script" value="leveldoor.lua"/>
    Basta adicionar à porta, o actionId estipulado na tag.
  8. Gostei
    Wise recebeu reputação de Ekr em Problema com os "Teleportes Falantes"?   
    REMOVIDO!
     
    Ops..aqui não havia carregado a mensagem do membro acima e.e
  9. Gostei
    Wise recebeu reputação de GM Kinagon em (Resolvido)Ao equipar um item X no meu slot serta vocartion mudara a outfit   
    Desatenção minha, estou um tanto quanto ocupado:
    local tab = { [1] = {outfit = 123}, -- [vocID] = {outfit = lookTypeNumber} [300] = {outfit = 456} } local condition = createConditionObject(CONDITION_ATTRIBUTES) setConditionParam(condition, CONDITION_PARAM_TICKS, -1) setConditionParam(condition, CONDITION_PARAM_STAT_MAGICLEVEL, 50) function onEquip(cid, item, slot) doSetCreatureOutfit(cid, {lookType = tab[getPlayerVocation(cid)].outfit}, -1) doChangeSpeed(cid, getCreatureSpeed(cid) + 50) doAddCondition(cid, condition) return true end function onDeEquip(cid, item, slot) doChangeSpeed(cid, getCreatureSpeed(cid) - 50) doRemoveCondition(cid, CONDITION_ATTRIBUTES) doRemoveCondition(cid, CONDITION_OUTFIT) return true end
  10. Gostei
    Wise recebeu reputação de GM Kinagon em (Resolvido)Ao equipar um item X no meu slot serta vocartion mudara a outfit   
    local tab = {     [1] = {outfit = 123}, -- [vocID] = {outfit = lookTypeNumber}     [300] = {outfit = 456} } local h, m = {50, 3}, {25, 3} -- {amount, seconds to regenerate} local regain = createConditionObject(CONDITION_REGENERATION) setConditionParam(regain, CONDITION_PARAM_TICKS, -1) setConditionParam(regain, CONDITION_PARAM_HEALTHGAIN, h[1]) setConditionParam(regain, CONDITION_PARAM_HEALTHTICKS, h[2] * 1000) setConditionParam(regain, CONDITION_PARAM_MANAGAIN, m[1]) setConditionParam(regain, CONDITION_PARAM_MANATICKS, m[2] * 1000) function onEquip(cid, item, slot)     doSetCreatureOutfit(cid, {lookType = tab[getPlayerVocation(cid)].outfit}, -1)     doChangeSpeed(cid, getCreatureSpeed(cid) + 50)     doAddCondition(cid, regain)     return true end function onDeEquip(cid, item, slot)     doChangeSpeed(cid, getCreatureSpeed(cid) - 50)     doRemoveCondition(cid, CONDITION_REGENERATION)     doRemoveCondition(cid, CONDITION_OUTFIT)     return true end Nesse caso, vai regenerar 50 de hp e 25 de mana a cada 3 segundos.
  11. Curtir
    Wise recebeu reputação de TiuoDrog em como adicionar portas com LEVEL ALTO   
    Action script local level = 450000 function onUse(cid, fromPos, toPos)     return getPlayerLevel(cid) >= level and doTeleportThing(cid, toPos) or doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Only players level '..level..' or higher can open this door.') and false end
  12. Gostei
    Wise recebeu reputação de joaobenhur em (Resolvido)Annihilator Quest   
    function isOnSameFloor(fromPos, toPos)     return fromPos.z == toPos.z and true or false end function isEven(arg)     return arg % 2 == 0 and true or false end function getMiddlePos(fromPos, toPos)     if not isOnSameFloor(fromPos, toPos) then         return false     end          local middle = {x = 0, y = 0, z = 0}             middle.x = isEven(fromPos.x + toPos.x) and (fromPos.x + toPos.x)/2 or math.floor((fromPos.x + toPos.x)/2) + 1         middle.y = isEven(fromPos.y + toPos.y) and (fromPos.y + toPos.y)/2 or math.floor((fromPos.y + toPos.y)/2) + 1         middle.z = fromPos.z or toPos.z     return middle end function getDistanceRadius(fromPos, toPos)     if not isOnSameFloor(fromPos, toPos) then         return false     end          local distance = getDistanceBetween(fromPos, toPos)     return isEven(distance) and (distance/2) or math.floor(distance/2) + 1 end function clearArea(middlePos, rangex, rangey)     local final = {x=1126, y=1152, z=7} -- Posição onde será teleportado quando acabar o tempo          for i = -rangex, rangex do         for j = -rangey, rangey do             pos = {x = middlePos.x + i, y = middlePos.y + j, z = middlePos.z}             creature = getTopCreature(pos).uid                          if isMonster(creature) then                 doSendMagicEffect(getThingPos(creature), 14)                 doRemoveCreature(creature)             elseif isPlayer(creature) then                 doSendMagicEffect(getThingPos(creature), 10)                 doTeleportThing(creature, final)             end         end     end          setGlobalStorageValue(sto, -1)     return true end      local t = {     lvl = 100,     entrada = {         {x = 1125, y = 1152, z = 7} -- pos players     },     saida = {         {x = 1125, y = 1153, z = 8} -- pos para onde eles irão     },     monstros = {         {{x = 1121, y = 1153, z = 8}, "Demon"} -- defina pos dos montros e nomes     } } function onUse(cid, item, fromPosition, itemEx, toPosition)     local configure = {         fromPos = {x=1121, y=1150, z=8}, -- posição superior esquerda do mapa, da area em que esta mapeado a area.         toPos = {x=1129, y=1156, z=8}, -- posição inferior direita do mapa, da area em que esta mapeado a area.         boss = "Demon" -- Aqui você bota o nome do monstro que você quer remover     }          local config = {         position = {x=1126, y=1152, z=7}, -- Contagem         position1 = {x=1121, y=1150, z=8}, -- Contagem         position2 = {x=1121, y=1156, z=8}, -- Contagem         position3 = {x=1129, y=1150, z=8}, -- Contagem         position4 = {x=1129, y=1156, z=8}, -- Contagem         fromPosition = {x=1121, y=1150, z=8},         toPosition = {x=1129, y=1156, z=8},         id = 1498,         time = 1 -- tempo que o teleport ira sumir em minutos     }     local time = 60     local sto = 5973     local check = {}          for _, k in ipairs(t.entrada) do         local x = getTopCreature(k).uid         if(x == 0 or isPlayer(x) and getPlayerLevel(x) < t.lvl) then             doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Não tem 5 jogadores para quest ou os jogadores nos sqms não tem o level mínimo para a quest.")             return true         end                      if getGlobalStorageValue(sto) == 1 then                 doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Annihilaton está bloqueada. Aguarde até que seja liberada.")                 return true             end                      table.insert(check, x)     end                      for _, summon in pairs(t.monstros) do                     local creature = getTopCreature(summon[1]).uid                     doCreateMonster(summon[2], summon[1])                 end                                      for i, tid in ipairs(check) do                         doTeleportThing(tid, t.saida[i], false)                         doSendMagicEffect(t.saida[i], 10)                         doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)                     end                                  for i = 1,time do                 formula = time - 1*i                 addEvent(doSendAnimatedText, i*1000, config.position, formula, TEXTCOLOR_RED)                 addEvent(doSendAnimatedText, i*1000, config.position1, formula, TEXTCOLOR_RED)                 addEvent(doSendAnimatedText, i*1000, config.position2, formula, TEXTCOLOR_RED)                 addEvent(doSendAnimatedText, i*1000, config.position3, formula, TEXTCOLOR_RED)                 addEvent(doSendAnimatedText, i*1000, config.position4, formula, TEXTCOLOR_RED)             end          setGlobalStorageValue(sto, 1)     local rx = getDistanceRadius(configure.fromPos, configure.toPos)     addEvent(clearArea, config.time * 60 * 1000, getMiddlePos(configure.fromPos, configure.toPos), rx, rx)     return true end
  13. Gostei
    Wise recebeu reputação de Igorzerah em Como coloca level para entrar na porta?   
    leveldoor.lua (data\actions\scripts)
    local level = 12000 function onUse(cid, fromPos, toPos) return getPlayerLevel(cid) >= level and doTeleportThing(cid, toPos) or doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Only players level '..level..' or higher can open this door.') and false end


    actions.xml (data\actions)
    <action actionid="XXXXX" event="script" value="leveldoor.lua"/>
    Basta adicionar à porta, o actionId estipulado na tag.
  14. Curtir
    Wise recebeu reputação de Victoriso em scripting maximo skill   
    maxclub.lua (data\creaturescripts\scripts):
    function onAdvance(cid, skill, oldLevel, newLevel)     local maxlevel = 50          if skill == SKILL_CLUB and newLevel > maxlevel then return false end     return true end


    Tag - creaturescripts.xml (data\creaturescripts):
    <event type="advance" name="MaxClub" event="script" value="maxclub.lua"/>


    Registre o creature event em login.lua (data\creaturescripts\scripts):
    registerCreatureEvent(cid, "MaxClub")
  15. Gostei
    E como o player adquirirá o efeito?
    Especifique.
  16. Gostei
    Wise recebeu reputação de Milbradt em math.percent {Cálculo Percentual}   
    Eis que trago mais uma função à biblioteca matemática de Lua, a math.percent.
    Sendo objetivo, ela calcula o percentual de um valor numérico, independentemente desse valor ser um inteiro ou decimal.
    math.percent = function (value, percentage) -- Developed by Wise ~ TibiaKing.com return tonumber(value) and tonumber(percentage) and math.abs(tonumber(string.format('%.f', tostring(percentage * (value/100))))) or nil end

    Exemplo de um cálculo:
    Mensagem maldita
    "Você atingiu 80% da sua franquia diária de 30MB. Ao atingir 100%, sua navegação será bloqueada."

    E agora, brother? Quantos MB eu usei?
    math.percent(30, 80) -- (valor númerico, %) 24

    Enfim, se for disponibilizar este script em outro meio, deixe meu nick nos créditos.
    ;]
  17. Gostei
    Wise recebeu reputação de tiroleivi em [Ajuda] Bless   
    blessedplayer.lua (data\creaturescripts\scripts):
    function onDeath(cid)     for b = 1, 5 do         if isPlayer(cid) and getPlayerBlessing(cid, b) and getCreatureSkullType(cid) < 4 then             doCreatureSetDropLoot(cid, false)         end     end     return true end


    creaturescripts.xml (data\creaturescripts):
    <event type="death" name="BlessedPlayer" event="script" value="blessedplayer.lua"/>


    Registre o creature event em login.lua (data\creaturescripts\scripts):
    registerCreatureEvent(cid, "BlessedPlayer")
  18. Gostei
    Wise recebeu reputação de Daywen em [ DUVIDA RAPIDA ] Texto Animado   
    local pos = { {x=153, y=47, z=7}, } function onThink() for i = 1, #pos do doSendAnimatedText(pos[i], "CasteGuild", TEXTCOLOR_DARKRED) end return true end

    Altere onde está TEXTCOLOR_DARKRED pela cor desejada, sendo uma variável ou algarismo.
    Algumas opções:
    TEXTCOLOR_BLACK = 0 TEXTCOLOR_BLUE = 5 TEXTCOLOR_GREEN = 18 TEXTCOLOR_TEAL = 35 TEXTCOLOR_LIGHTGREEN = 66 TEXTCOLOR_DARKBROWN = 78 TEXTCOLOR_LIGHTBLUE = 89 TEXTCOLOR_DARKPURPLE = 112 TEXTCOLOR_BROWN = 120 TEXTCOLOR_GREY = 129 TEXTCOLOR_DARKRED = 144 TEXTCOLOR_DARKPINK = 152 TEXTCOLOR_PURPLE = 154 TEXTCOLOR_DARKORANGE = 156 TEXTCOLOR_RED = 180 TEXTCOLOR_PINK = 190 TEXTCOLOR_ORANGE = 192 TEXTCOLOR_DARKYELLOW = 205 TEXTCOLOR_YELLOW = 210 TEXTCOLOR_WHITE = 215 TEXTCOLOR_NONE = 255
     
    Se preferir optar por textos animados com cores aleatórias (na minha opinião, fica mais simples):
    local pos = { {x=153, y=47, z=7}, } function onThink() for i = 1, #pos do doSendAnimatedText(pos[i], "CasteGuild", math.random(1, 255)) end return true end
  19. Gostei
    Wise recebeu reputação de Adventure em (Resolvido)Ao equipar um item X no meu slot serta vocartion mudara a outfit   
    Desatenção minha, estou um tanto quanto ocupado:
    local tab = { [1] = {outfit = 123}, -- [vocID] = {outfit = lookTypeNumber} [300] = {outfit = 456} } local condition = createConditionObject(CONDITION_ATTRIBUTES) setConditionParam(condition, CONDITION_PARAM_TICKS, -1) setConditionParam(condition, CONDITION_PARAM_STAT_MAGICLEVEL, 50) function onEquip(cid, item, slot) doSetCreatureOutfit(cid, {lookType = tab[getPlayerVocation(cid)].outfit}, -1) doChangeSpeed(cid, getCreatureSpeed(cid) + 50) doAddCondition(cid, condition) return true end function onDeEquip(cid, item, slot) doChangeSpeed(cid, getCreatureSpeed(cid) - 50) doRemoveCondition(cid, CONDITION_ATTRIBUTES) doRemoveCondition(cid, CONDITION_OUTFIT) return true end
  20. Gostei
    Wise recebeu reputação de eliasferro em ITEM QUE DA ADDON   
    Tenta aí:

    addonitem.lua (data\movements\scripts):
    local addon = {432, 1} -- {lookType, addon} function onEquip(cid)     return doPlayerAddOutfit(cid, addon[1], addon[2]) end function onDeEquip(cid)     return doPlayerRemoveOutfit(cid, addon[1], addon[2]) end

     
    movements.xml (data\movements):
    <movevent type="Equip" itemid="XXXX" slot="SLOTTYPE" event="script" value="addonitem.lua"/> <movevent type="DeEquip" itemid="XXXX" slot="SLOTTYPE" event="script" value="addonitem.lua"/>

     
    Slot Types:
    head necklace backpack armor right-hand left-hand hand shield legs feet ring ammo
  21. Gostei
    Wise recebeu reputação de loukeira em Lua Function Library {:No Metamethods:}   
    Notei que ainda não haviam feito uma lista dessa versão, então eu a fiz.
     
    Eis todas as funções, sem metamétodos e em ordem alfabética, do The Forgotten Server 1.2
    broadcastMessage(message, messageType) canPlayerLearnInstantSpell(cid, name) canPlayerWearOutfit(cid, lookType, addons) doAddCondition(cid, conditionId) doAddContainerItemEx(uid, virtualId) doAddMapMark(cid, pos, type, description) doChangeSpeed(cid, delta) doChangeTypeItem(uid, newType) doCombat(cid, combat, var) doConvinceCreature(cid, target) doCreateNpc(name, pos, ...) doCreateTeleport(itemId, destination, position) doCreatureAddHealth(cid, health) doCreatureChangeOutfit(cid, outfit) doCreatureSay(cid, text, type, ...) doCreatureSetLookDir(cid, direction) doDecayItem(uid) doMonsterChangeTarget(cid) doPlayeJoinParty(cid, leaderId) doPlayerAddBlessing(cid, blessing) doPlayerAddExp(cid, exp, useMult, ...) doPlayerAddItemEx(cid, uid, ...) doPlayerAddMana(cid, mana, ...) doPlayerAddManaSpent(cid, mana) doPlayerAddMoney(cid, money) doPlayerAddMount(cid, mountId) doPlayerAddOutfit(cid, lookType, addons) doPlayerAddPremiumDays(cid, days) doPlayerAddSkillTry(cid, skillId, n) doPlayerAddSoul(cid, soul) doPlayerFeed(cid, food) doPlayerPopupFYI(cid, message) doPlayerRemOutfit(cid, lookType, addons) doPlayerRemoveItem(cid, itemId, count, ...) doPlayerRemoveMoney(cid, money) doPlayerRemoveMount(cid, mountId) doPlayerRemovePremiumDays(cid, days) doPlayerSendCancel(cid, text) doPlayerSendTextMessage(cid, type, text, ...) doPlayerSetBalance(cid, balance) doPlayerSetGuildLevel(cid, level) doPlayerSetGuildNick(cid, nick) doPlayerSetOfflineTrainingSkill(cid, skillId) doPlayerSetSex(cid, sex) doPlayerSetTown(cid, town) doPlayerSetVocation(cid, vocation) doRelocate(fromPos, toPos) doRemoveCondition(cid, conditionType, subId) doRemoveCreature(cid) doRemoveItem(uid, ...) doSendDistanceShoot(fromPos, toPos, distanceEffect, ...) doSendMagicEffect(pos, magicEffect, ...) doSendTutorial(cid, tutorialId) doSetCreatureDropLoot(cid, doDrop) doSetItemActionId(uid, actionId) doSetItemSpecialDescription(uid, desc) doSetItemText(uid, text) doSetMonsterTarget(cid, target) doShowTextDialog(cid, itemId, text) doSummonCreature(name, pos ...) doTeleportThing(uid, dest, pushMovement) doTransformItem(uid, newItemId, ...) getAccountNumberByPlayerName(name) getConfigInfo(info) getContainerCap(uid) getContainerCapById(itemId) getContainerItem(uid, slot) getContainerSize(uid) getCreatureBaseSpeed(cid) getCreatureHealth(cid) getCreatureMaster(cid) getCreatureMaxHealth(cid) getCreatureName(cid) getCreatureOutfit(cid) getCreaturePosition(cid) getCreatureSpeed(cid) getCreatureSummons(cid) getCreatureTarget(cid) getFluidSourceType(itemId) getGlobalStorageValue(key) getGuildId(guildName) getHouseAccessList(id, listId) getHouseByPlayerGUID(playerGUID) getHouseEntry(houseId) getHouseName(houseId) getHouseOwner(houseId) getHouseRent(id) getHouseTilesSize(houseId) getHouseTown(houseId) getIPByPlayerName(name) getItemDescriptions(itemId) getItemIdByName(name) getItemName(itemId) getItemRWInfo(uid) getItemWeight(itemId, ...) getItemWeightByUID(uid, ...) getMonsterFriendList(cid) getMonsterTargetList(cid) getOnlinePlayers() getPartyMembers(cid) getPlayerAccess(cid) getPlayerAccountType(cid) getPlayerBalance(cid) getPlayerBlessing(cid, blessing) getPlayerByIPAddress(ip, mask) getPlayerByName(name) getPlayerDepotItems(cid, depotId) getPlayerFood(cid) getPlayerFreeCap(cid) getPlayerGroupId(cid) getPlayerGUID(cid) getPlayerGUIDByName(name) getPlayerGuildId(cid) getPlayerGuildLevel(cid) getPlayerGuildName(cid) getPlayerGuildNick(cid) getPlayerGuildRank(cid) getPlayerIp(cid) getPlayerItemById(cid, deepSearch, itemId, ...) getPlayerItemCount(cid, itemId, ...) getPlayerLastLoginSaved(cid) getPlayerLearnedInstantSpell(cid, name) getPlayerLevel(cid) getPlayerLight(cid) getPlayerLookDir(cid) getPlayerLossPercent(cid) getPlayerMagLevel(cid) getPlayerMana(cid) getPlayerMasterPos(cid) getPlayerMaxMana(cid) getPlayerMoney(cid) getPlayerMount(cid, mountId) getPlayerName(cid) getPlayerParty(cid) getPlayerPosition(cid) getPlayerPremiumDays(cid) getPlayersByAccountNumber(accountNumber) getPlayerSex(cid) getPlayerSkill(cid, skillId) getPlayerSkullType(cid) getPlayerSlotItem(cid, slot) getPlayerSoul(cid) getPlayerStorageValue(cid, key) getPlayerTown(cid) getPlayerVocation(cid) getPromotedVocation(vocationId) getSpectators(centerPos, rangex, rangey, multiFloor, onlyPlayers) getThing(uid) getThingFromPos(pos) getThingPos(uid) getTileHouseInfo(pos) getTileInfo(position) getTileItemById(position, itemId, ...) getTileItemByType(position, itemType) getTilePzInfo(position) getTileThingByPos(position) getTileThingByTopOrder(position, topOrder) getTopCreature(position) getTownId(townName) getTownName(townId) getTownTemplePosition(townId) getWorldCreatures(type) Guild.addMember(self, player) Guild.removeMember(self, player) hasProperty(uid, prop) isContainer(uid) isCorpse(uid) isCreature(cid) isItem(uid) isItemContainer(itemId) isItemDoor(itemId) isItemFluidContainer(itemId) isItemMovable(itemId) isItemRune(itemId) isItemStackable(itemId) isMonster(cid) isNpc(cid) isPlayer(cid) isPlayerGhost(cid) isPlayerPzLocked(cid) isPremium(cid) isSightClear(fromPos, toPos, floorCheck) isSummon(cid) playerLearnInstantSpell(cid, name) pushThing(thing) queryTileAddThing(thing, position, ...) registerCreatureEvent(cid, name) setGlobalStorageValue(key, value) setHouseAccessList(id, listId, listText) setHouseOwner(id, guid) setPlayerGroupId(cid, groupId) setPlayerStorageValue(cid, key, value) targetPositionToVariant(position) unregisterCreatureEvent(cid, name)

    Já que fui eu quem listei e organizei a biblioteca por conta própria, se você for disponibilizar em outro meio, ao menos deixe o meu nick nos créditos.
     
    Bom uso ;]
  22. Gostei
    Wise recebeu reputação de Game Fox em (Resolvido)[Pedido] Script de porta! Alguem poderia me ajudar!   
    lvldoor.lua (data/actions/scripts):
    function onUse(cid, item, fromPos, item2, toPos)     lvl = 1000          if getPlayerLevel(cid) >= lvl then         doTeleportThing(cid, toPos)         doSendMagicEffect(fromPos, CONST_ME_MAGIC_BLUE)     else         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Você precisa de level '..lvl..' para poder abrir a porta.')         doSendMagicEffect(fromPos, CONST_ME_POFF)     end     return true end

     
    Adicione a tag ao arquivo actions.xml (data/actions):
    <action actionid="ACTIONID" event="script" value="lvldoor.lua"/>  
  23. Gostei
    Wise recebeu reputação de Game Fox em Como coloca level para entrar na porta?   
    leveldoor.lua (data\actions\scripts)
    local level = 12000 function onUse(cid, fromPos, toPos) return getPlayerLevel(cid) >= level and doTeleportThing(cid, toPos) or doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Only players level '..level..' or higher can open this door.') and false end


    actions.xml (data\actions)
    <action actionid="XXXXX" event="script" value="leveldoor.lua"/>
    Basta adicionar à porta, o actionId estipulado na tag.
  24. Gostei
    Wise deu reputação a Kemmlly em Npc Blacksmith   
    Esquece esse script, tenta esse:
     
    data/npc/scripts/blacksmith.lua
    local tab = { item = {2349, 1}, -- {ID do item, Quantidade} mude para os itens que voce quer, pois esses sao itens de teste que usei item2 = {2346, 1}, item3 = {2156, 1}, recompensa = {5791, 1}, -- Armadura que vai ganhar se tiver todos os itens price = 10 -- quantidade em crystal coins } local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end function onThink() npcHandler:onThink() end function creatureSayCallback(cid, type, msg) if (not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid if (msgcontains(msg, 'forge armor')) then talkState[talkUser] = 1 selfSay('Lembre-se.. Voce precisa de '..tab.item[2]..' '..getItemNameById(tab.item[1])..', '..tab.item2[2]..' '..getItemNameById(tab.item2[1])..', '..tab.item3[2]..' '..getItemNameById(tab.item3[1])..' e 10k. Ja possui todos?', cid) elseif (msgcontains(msg, 'yes') and talkState[talkUser] == 1) then if (getPlayerItemCount(cid, tab.item[1]) >= tab.item[2] and getPlayerItemCount(cid, tab.item2[1]) >= tab.item2[2] and getPlayerItemCount(cid, tab.item3[1]) >= tab.item3[2] and doPlayerRemoveMoney(cid, tab.price * 1000)) then doPlayerRemoveItem(cid, tab.item[1], tab.item[2]) doPlayerRemoveItem(cid, tab.item2[1], tab.item2[2]) doPlayerRemoveItem(cid, tab.item3[1], tab.item3[2]) doPlayerAddItem(cid,tab.recompensa[1],tab.recompensa[2]) doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT) selfSay('Veja so, voce tem todos os itens, parabens, aproveite sua nova armadura!.', cid) else talkState[talkUser] = 0 selfSay('Perdao, mas voce nao tem os itens necessarios ainda, volte quando estiver com todos.', cid) end elseif (msgcontains(msg, 'no') and talkState[talkUser] == 1) then talkState[talkUser] = 0 selfSay('Pois bem, pegue os itens e retorne.', cid) end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) data/npc/blacksmith.xml
    <npc name="Blacksmith" script="data/npc/scripts/blacksmith.lua" access="5" lookdir="1"> <health now="1000" max="1000"/> <look type="54" head="45" body="67" legs="79" feet="10" addons="1"/> <parameters> <parameter key="message_greet" value="Ola, |PLAYERNAME|. Se voce tiver os itens certos diga {forge armor} e ganhe uma armadura nova." /> </parameters> </npc>  
    Script de @Wise , adaptei para sua necessidade.
  25. Gostei
    Wise recebeu reputação de Kemmlly em PK ao Atacar Summon de Outro Player   
    Serei breve, já que o próprio título já diz sobre o sistema.
    É um creaturescript bem simples, porém pode ser útil.



    onattacksummon.lua (data/creaturescripts/scripts):
    local stime = 10 -- tempo de pk (minutos) local condition_infight = createConditionObject(CONDITION_INFIGHT) setConditionParam(condition_infight, CONDITION_PARAM_TICKS, stime * 60 * 1000) function onAttack(cid, target)     if getCreatureSkullType(cid) < 3 and isPlayer(getCreatureMaster(target)) then         doCreatureSetSkullType(cid, SKULL_WHITE)         doAddCondition(cid, condition_infight)         doPlayerSetPzLocked(cid, true)     end     return true end


    No mesmo diretório, adicione o registro ao arquivo login.lua (data/creaturescripts/scripts):
    registerCreatureEvent(cid, "onAttackSummon")

     
    Adicione a tag - creaturescripts.xml (data/creaturescripts):
    <event type="attack" name="onAttackSummon" event="script" value="onattacksummon.lua"/>
    Créditos: Suicide (aprendiz de xWhiteWolf).

Informação Importante

Confirmação de Termo