Postado Março 8, 2012 13 anos O script é simples, para quem quiser dar uma inovada no servidor.. chega de first item creaturescript , vamos utilizar um npc Em data/npcs/scripts crie um npc chamado firstitem.lua e cole o script a seguir 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 npcHandler:setMessage(MESSAGE_GREET, "Hello |PLAYERNAME| I am a very rich person, and I'm donating my items you want? say {first item}.") function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid local items = { [0] = { 8819, 8820}, [1] = { 8819, 8820}, [2] = { 8819, 8820}, [3] = { 2509, 2643}, [4] = { 2643, 2478 } } if msgcontains(msg, 'first item') or msgcontains (msg, 'first items') then if getPlayerStorageValue(cid,15003) < 1 then selfSay('You want the items? say {yes}', cid) talkState[talkUser] = 1 else selfSay('Sorry,I have given to you!', cid) end elseif talkState[talkUser] == 1 then if msgcontains(msg, 'yes') then selfSay('You receive your items.', cid) doPlayerAddItem(cid, 2554, 1) doPlayerAddItem(cid, 2120, 1) doPlayerAddItem(cid, 2160, 2) for voca, item in pairs(items) do if getPlayerVocation(cid) == voca then for i = 1, table.maxn(items) do doPlayerAddItem(cid, items[i], 1) end setPlayerStorageValue(cid, 15003, 1) end end talkState[talkUser] = 0 else selfSay('Sorry,I have given to you!', cid) end end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) agora data/nps crie um arquivo chamado Helper.xml(Formato XML, copie e cole se você não souber) <?xml version="1.0" encoding="UTF-8"?> <npc name="Helper" script="firstitem.lua" walkinterval="2000" floorchange="0"> <health now="100" max="100"/> <look type="133" head="78" body="92" legs="76" feet="0" addons="3"/> </npc> Editando os Items a Receber: [0] = { 8819, 8820}, [1] = { 8819, 8820}, [2] = { 8819, 8820}, [3] = { 2509, 2643}, [4] = { 2643, 2478 } Em [] são os ids das vocações Ex: [0] = None [1] = Sorcerer Entre {} são os ids dos items. Ex: {2160,2160,2160} Sempre coloque uma virgula após o outro id. Pronto, agora só ligar seu servidor ou dar /reload npc e rodar http://baiakuza.com/IP: baiakuza.com TIBIA: 10.96 Baiak Custom [ High Exp Rate ]
Postado Março 8, 2012 13 anos Legal, SkyDangerous. É um NPC simples, mas muito útil. Algumas observações: for i = 1, table.maxn(items) do doPlayerAddItem(cid, item[i], 1) doPlayerAddItem(cid, 2554, 1) doPlayerAddItem(cid, 2120, 1) doPlayerAddItem(cid, 2160, 2) end doPlayerAddItem(cid, item[i], 1) Você declarou a tabela com o nome items e nessa linha chama a tabela item que não existe doPlayerAddItem(cid, 2554, 1) doPlayerAddItem(cid, 2120, 1) doPlayerAddItem(cid, 2160, 2) E incluiu essas três linhas dentro do for, o que faz com que a função seja executada n vezes igual o tamanho da tabela. Ou seja, o jogador iria receber 8 crystal coins e não 2 apenas. E a função table.maxn pode ser chamada por # for i = 1, #tables do (...) end Editado Março 8, 2012 13 anos por Lpz (veja o histórico de edições)
Postado Março 8, 2012 13 anos Autor vlw Arrumei lá, mas pior que deu certo daquele jeito http://baiakuza.com/IP: baiakuza.com TIBIA: 10.96 Baiak Custom [ High Exp Rate ]
Postado Março 9, 2012 13 anos Interessante o NPC, eu gostei... REP+' Abraços e valeu ae. Gosta do meu trabalho? Curta e siga a página do meu projeto de 2016 e 2017 (Lab Z Games) que trará vários servidores OTServs. Atenciosamente,Adriano Swatt' Para ver meus tutoriais acesse meu perfil.
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.