Ir para conteúdo
  • Cadastre-se

Monster%252FNPC [NPC] Mount Seller Por Items [8.7+]


Posts Recomendados

lib/functions.lua

function getItemsFromList(items) -- by vodka

local str = ''

if table.maxn(items) > 0 then

for i = 1, table.maxn(items) do

str = str .. items[i][2] .. ' ' .. getItemNameById(items[i][1])

if i ~= table.maxn(items) then str = str .. ', ' end end end

return str

end

function doRemoveItemsFromList(cid,items) -- by vodka

local count = 0

if table.maxn(items) > 0 then

for i = 1, table.maxn(items) do

if getPlayerItemCount(cid,items[i][1]) >= items[i][2] then

count = count + 1 end  end  end

if count == table.maxn(items) then

for i = 1, table.maxn(items) do doPlayerRemoveItem(cid,items[i][1],items[i][2]) end

else return false end

return true end
Data/NPC Mount Seller.xml
<?xml version="1.0"?>

<npc name="Mount Seller" script="data/npc/scripts/buymount.lua" walkinterval="50000" floorchange="0">

<health now="100" max="100"/>

<look type="129" head="95" body="116" legs="121" feet="115" addons="3"/>

<parameters>

<parameter key="message_greet" value="Hello |PLAYERNAME|.I have many {mounts} to sell for you!" />

</parameters>

</npc>
Data/Npc/script buymount.lua
local keywordHandler = KeywordHandler:new()

local npcHandler = NpcHandler:new(keywordHandler)

NpcSystem.parseParameters(npcHandler)

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 AddMount(cid, message, keywords, parameters, node) --by vodka

if(not npcHandler:isFocused(cid)) then

return false

end

if (isPlayerPremiumCallback == nil or isPlayerPremiumCallback(cid) == true or parameters.premium == false) then

if(parameters.level ~= nil and getPlayerLevel(cid) < parameters.level) then

npcHandler:say('You must reach level ' .. parameters.level .. ' to buy this mount.', cid)

elseif canPlayerRideMount(cid, parameters.mountid) then

npcHandler:say('you already have this mount!', cid)

elseif not doRemoveItemsFromList(cid,parameters.items) then

npcHandler:say('Sorry You need '..getItemsFromList(parameters.items)..' to buy this mount!', cid)

else

doPlayerAddMount(cid, parameters.mountid)

npcHandler:say('Here is your mount!', cid)

npcHandler:resetNpc()

end

else

npcHandler:say('I can only allow premium players to buy this mount.', cid)

end

npcHandler:resetNpc()

return true

end

local mounts = {

{"widow queen", items = {{2124,1},{2393,2}}, mountid = 1, level = 10, premium = false},

{"racing bird", items = {{2494,1},{2393,2}}, mountid = 2, level = 15, premium = true},

{"mounts", text = "I sell these mounts: {widow queen},{racing bird},{war Bear},{black sheep},{midnight panther},{draptor},{titanica},{tin lizzard}.{blazebringer},{rapid boar},{stampor} or {undead cavebear}!"}

}

for i = 1, #mounts do local get = mounts[i] if type(get.items) == "table" then

local node = keywordHandler:addKeyword({get[1]}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "You want to buy the mount " .. get[1] .. " for "..getItemsFromList(get.items).." ?"})

node:addChildKeyword({"yes"}, AddMount, {items = get.items,mountid = get.mountid, level = get.level, premium = get.premium})

node:addChildKeyword({"no"}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Ok, then.", reset = true})

else keywordHandler:addKeyword({get[1]}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = get.text}) end end

mounts = nil npcHandler:addModule(FocusModule:new())

configuração:
local mounts = {

{"widow queen", items = {{2124,1},{2393,2}}, mountid = 1, level = 10, premium = false},

{"racing bird", items = {{2494,1},{2393,2}}, mountid = 2, level = 15, premium = true},

{"mounts", text = "I sell these mounts: {widow queen},{racing bird},{war Bear},{black sheep},{midnight panther},{draptor},{titanica},{tin lizzard}.{blazebringer},{rapid boar},{stampor} or {undead cavebear}!"}

}
"nome da montaria" items = {} -- é os items que precisa ter trocar pela mount mountid -- é o id da montaria level -- level necessario para comprar premium -- se precisa ser premium para comprar text -- n precisa mexer,é para saber que montaria ele pode comprar,pode adicionar + nome na lista se quiser adicionando mount então por exemplo war bear:
local mounts = {

{"widow queen", items = {{2124,1},{2393,2}}, mountid = 1, level = 10, premium = false},

{"racing bird", items = {{2494,1},{2393,2}}, mountid = 2, level = 15, premium = true},

{"war bear", items = {{2123,2},{2124,1},{2173,1}}, mountid = 3, level = 20, premium = false},

{"mounts", text = "I sell these mounts: {widow queen},{racing bird},{war Bear},{black sheep},{midnight panther},{draptor},{titanica},{tin lizzard}.{blazebringer},{rapid boar},{stampor} or {undead cavebear}!"}

}

vodkart_logo.png

[*Ninguém será digno do sucesso se não usar suas derrotas para conquistá-lo.*]

 

DISCORDvodkart#6090

 

Link para o post
Compartilhar em outros sites

Ui ;D

Script Incrível !

Parabéns !

 http://baiakuza.com/
IP: baiakuza.com
TIBIA: 10.96
Baiak Custom [ High Exp Rate ]

 

 

 

 

Link para o post
Compartilhar em outros sites
  • 2 months later...
  • 1 year later...

Vim só agora testar esse script. Testei numa versão 9.10. Copiei exatamente os scripts e colei, sem fazer qualquer alteração prévia.

Quando, in-game, tento sumonar o NPC, aparece uma msg de erro e o NPC não é sumonado. Vejam:

 

1luh.png

 

Gostaria de saber o que posso fazer pra arrumar (se é que dá).

Abraço,

 

Inthus :)

 

--------------------- EDIT ------------------------

 

Já consegui resolver o problema, pessoal, ignorem! :)

Editado por Inthus (veja o histórico de edições)
Link para o post
Compartilhar em outros sites

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.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo