Ir para conteúdo

Pesquisar na Comunidade

Mostrando resultados para as tags ''merchant''.



Mais opções de pesquisa

  • Pesquisar por Tags

    Digite tags separadas por vírgulas
  • Pesquisar por Autor

Tipo de Conteúdo


Fóruns

  • A Cidade OTBR
    • OTServ Brasil
    • Atendimento
    • Taverna
  • Projetos Open Source
    • Canary
    • OTServBR-Global
    • Mehah OTClient
    • MyAAC
  • OpenTibia
    • Notícias e Discussões
    • Suporte - Dúvidas, Bugs, Erros
    • Downloads
    • Tutoriais
    • Show-Off
  • Outros
    • Design

Encontrado 1 registro

  1. npc The Merchant - O viajante

    É um NPC que vende itens ( que você configurou ) mas de forma que o comprador tenha que esperar um tempo pra chegar a encomenda! Isto é útil em servers onde o RPG é prioridade. Instalação Crie um arquivo: data/npc/Merchant.xml <?xml version="1.0" encoding="UTF-8"?> <npc name="The Merchant" script="merchant.lua" walkinterval="2000" floorchange="0"> <health now="150" max="150"/> <look type="128" head="20" body="100" legs="50" feet="99" corpse="2212"/> <parameters> </parameters> </npc> Crie um arquivo: data/npc/scripts/merchant.lua --// Creditos: Rômulo Souza (Criação) Longhart (Ideia e Tradução) local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} local name --// Config Here// local min_hour = 2 -- Min hour of wait local max_hour = 12 -- Max hour of wait local items = {['katana']={itemid=2412, cust=100}, ['naginata']={itemid=2426, cust=200}} -- Items to Sell local config_str = {s_itemid=4251, s_comming=4241} -- Storage ( Dont change if you dont know ) --/////////////// function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) selfSay("Hey! Hey! I got some good stuff for you, come here!",cid) end function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid if(msgcontains(msg, 'hi') or msgcontains(msg, 'hello')) then if (getPlayerStorageValue(cid,config_str.s_comming) ~= -1) then local itemid = getPlayerStorageValue(cid,config_str.s_itemid) local time = getPlayerStorageValue(cid,config_str.s_comming) if (getPlayerStorageValue(cid,config_str.s_comming) <= os.time()) then selfSay('Hello! Your '..getItemNameById(itemid)..' is ready! You want get it now?', cid) talkState[talkUser] = 3 else min = math.floor((time-os.time())/60) hours = math.floor((time-os.time())/60/60) selfSay('Your '..getItemNameById(itemid)..' will take '.. min..' minutes (~'..hours..' hours) to come for me.', cid) end else local str = '' local cont = 1 for name,tab in pairs(items) do str = str.. name.. (cont >= count(items) and '.' or ',') cont = cont+1 end selfSay('Hello, i can bring some kind of itens for you, just say what you want. Items: '..str, cid) talkState[talkUser] = 1 end elseif (talkState[talkUser] == 1 and msg ~='bye') then if (items[msg] ~= nil) then selfSay('You want to request the '..msg..'? it will cost '..items[msg].cust..' gold coins, are you sure?', cid) talkState[talkUser] = 2 name = msg else selfSay('I\'m not selling the '..msg..'!', cid) talkState[talkUser] = 1 end elseif(msgcontains(msg, 'no') and talkState[talkUser] == 2) then selfSay("Don\'t worry, i can bring this anytime you want.",cid) talkState[talkUser] = 1 elseif(msgcontains(msg, 'yes') and isInArray({2,3}, talkState[talkUser])) then if (talkState[talkUser] == 2) then if (doPlayerRemoveMoney(cid,items[name].cust)) then hours = doStorage(cid, items[name].itemid) selfSay('Thanks for requesting '..name..', it will take '..hours..' hours before come.', cid) talkState[talkUser] = 0 else selfSay('You don\'t have enough money, you need '.. items[name].cust..' gold coins.', cid) talkState[talkUser] = 1 end elseif (talkState[talkUser] == 3) then local itemid = getPlayerStorageValue(cid,config_str.s_itemid) selfSay('Here you are, come back again!.', cid) doPlayerAddItem(cid,itemid,1) setPlayerStorageValue(cid,config_str.s_itemid,-1) setPlayerStorageValue(cid,config_str.s_comming,-1) talkState[talkUser] = 0 end end return true end function onThink() npcHandler:onThink() end function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) function doStorage(cid,itemid) str = getPlayerStorageValue(cid,config_str.s_comming) hours = math.random(min_hour,max_hour) local time = (os.time())+(1*60*60*hours) setPlayerStorageValue(cid,config_str.s_itemid,itemid) setPlayerStorageValue(cid,config_str.s_comming,time) return hours end function count(t) sum = 0 for k,v in pairs(t) do sum = sum + 1 end return sum end Outras Informações Este Script faz parte de um futuro projeto OpenSource que visa criar NPCS, Quests, Mapas, e Sistemas sempre inovadores. E estimular o desenvolvimento livre de otservers. Faça sua sugestão! Mais Trabalhos realizados em prol do Projeto: ShowOff do Mapa
×