Olá galerinha do Xtibia,
Queria 1 NPC que o Player comprar 1 Spells.
Exemplo comprar a spells - Housenka por 15 vip coins. o id eu que ageito.
ai o player falar Housenka ai a magia vai , se não comprar não vai.
REP + Durante 1 semana.
VLW!
Olá galerinha do Xtibia,
Queria 1 NPC que o Player comprar 1 Spells.
Exemplo comprar a spells - Housenka por 15 vip coins. o id eu que ageito.
ai o player falar Housenka ai a magia vai , se não comprar não vai.
REP + Durante 1 semana.
VLW!
spell_seller.lua
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 local moeda = 2157 local t = { ["light healing"] = {price = 15,vocations = {1,2,3,4},level = 9}, ["find person"] = {price = 25,vocations = {3,4},level = 8}, ["light magic missile"] = {price =30,vocations = {1,5,7,8},level = 15}, ["energy strike"] = {price =20,vocations = {1,2,5,6},level = 12}, ["flame strike"] = {price =100,vocations = {1,2,5,6},level = 12} } if (msgcontains(msg, 'SPELLS') or msgcontains(msg, 'spells'))then local str = "" str = str .. "Eu vendo estas Magias: " for name, pos in pairs(t) do str = str.." {"..name.."} = "..pos.price.." Moedas /" end str = str .. "." npcHandler:say(str, cid) elseif t[msg] then if not getPlayerLearnedInstantSpell(cid, msg) then if getPlayerLevel(cid) >= t[msg].level then if isInArray(t[msg].vocations, getPlayerVocation(cid)) then if doPlayerRemoveItem(cid,moeda,t[msg].price) then doPlayerLearnInstantSpell(cid, msg) npcHandler:say("Você aprendeu uma nova magia chamada ".. msg .."!", cid) else npcHandler:say("você não tem "..t[msg].price.." ".. getItemNameById(moeda), cid) end else npcHandler:say("você não tem a vocação para comprar está spell.", cid) end else npcHandler:say("você precisa ter level "..t[msg].level.." ou mais para comprar essa magia.", cid) end else npcHandler:say("você já aprendeu essa magia.", cid) end end return TRUE end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
Você adiciona e configura as spells que serão vendidas aqui:
local t = { ["light Healing"] = {price = 15,vocations = {1,2,3,4},level = 9}, ["find person"] = {price = 25,vocations = {3,4},level = 8}, ["light magic missile"] = {price =30,vocations = {1,5,7,8},level = 15}, ["energy strike"] = {price =20,vocations = {1,2,5,6},level = 12}, ["flame strike"] = {price =100,vocations = {1,2,5,6},level = 12} }
["nome da spell"] ={price = Quantos Coins vão custar,vocations ={ID DAS VOC},level = level para aprender a magia}
NOME DO SEU NPC.xml
<?xml version="1.0"?> <npc name="NOME DO SEU NPC" script="data/npc/scripts/spell_seller.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|. Quer comprar algumas {spells} ?" /> </parameters> </npc>
e para usar a magia só quem comprou você faz o seguinte
vai em Spells.xml e na tag da sua magia vc coloca
needlearn="1"
needlearn="1" -- precisa aprender para usar a magia
needlearn="0" -- n precisa aprender para usar a magia
o price no caso quantas moedas(Vip coins) irão custar!
e o id da moeda você muda aqui:
local moeda = 2157
vc coloca o id da suas vips coins ali
?
Você coloca o id da sua vip coin ali certo?
digamos que seja o id 8762...
local moeda = 8762
e só vai dar para comprar a magia com essa coin(id 8762)
ou existe outros tipos de moeda?
tava assim : local moeda = 7460 ai eu troco para local moeda = 7598 funciona?
tipo se eu quiser vender por outro ID exemplo, tá vendendo por 7460 não sei que item é esse, mais é exemplo, ai os mlks axa 1 bixo qe dropa ,1 não 1 monte, ai irá da trabalho, para eu trocar botar 7598 ai
tava assim : local moeda = 7460 ai eu troco para local moeda = 7598 funciona?
tipo se eu quiser vender por outro ID exemplo, tá vendendo por 7460 não sei que item é esse, mais é exemplo, ai os mlks axa 1 bixo qe dropa ,1 não 1 monte, ai irá da trabalho, para eu trocar botar 7598 ai
Funciona.
mas você quer que as spells sejam vendidas por mais de um item?
que o npc aceite 2 tipos de moeda,exemplo: que aceite a moeda 7460 e 7598?
ok
qndo vc decidir me avisa
abraços
nem sei cara
nao mexo cm php
ta ai o npc que aceita 2 moedas:
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 local moedas = {2157,9020} local t = { ["light healing"] = {price = 15,vocations = {1,2,3,4},level = 9}, ["find person"] = {price = 25,vocations = {3,4},level = 8}, ["light magic missile"] = {price =30,vocations = {1,5,4,7,8},level = 15}, ["energy strike"] = {price =20,vocations = {1,2,5,6},level = 12}, ["flame strike"] = {price =100,vocations = {1,2,5,6},level = 12} } if (msgcontains(msg, 'SPELLS') or msgcontains(msg, 'spells'))then local str = "" str = str .. "Eu vendo estas Magias: " for name, pos in pairs(t) do str = str.." {"..name.."} = "..pos.price.." Moedas /" end str = str .. "." npcHandler:say(str, cid) elseif t[msg] then if not getPlayerLearnedInstantSpell(cid, msg) then if getPlayerLevel(cid) >= t[msg].level then if isInArray(t[msg].vocations, getPlayerVocation(cid)) then if doPlayerRemoveItem(cid,moedas[1],t[msg].price) or doPlayerRemoveItem(cid,moedas[2],t[msg].price) then doPlayerLearnInstantSpell(cid, msg) npcHandler:say("Você aprendeu uma nova magia chamada ".. msg .."!", cid) else npcHandler:say("você precisa de "..t[msg].price.." ".. getItemNameById(moedas[1]).." ou "..t[msg].price.." ".. getItemNameById(moedas[2]), cid) end else npcHandler:say("você não tem a vocação para comprar está spell.", cid) end else npcHandler:say("você precisa ter level "..t[msg].level.." ou mais para comprar essa magia.", cid) end else npcHandler:say("você já aprendeu essa magia.", cid) end end return TRUE end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
vod
Em 08/03/2012 em 21:35, Vodkart disse:nem sei cara
nao mexo cm php
ta ai o npc que aceita 2 moedas:
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 local moedas = {2157,9020} local t = { ["light healing"] = {price = 15,vocations = {1,2,3,4},level = 9}, ["find person"] = {price = 25,vocations = {3,4},level = 8}, ["light magic missile"] = {price =30,vocations = {1,5,4,7,8},level = 15}, ["energy strike"] = {price =20,vocations = {1,2,5,6},level = 12}, ["flame strike"] = {price =100,vocations = {1,2,5,6},level = 12} } if (msgcontains(msg, 'SPELLS') or msgcontains(msg, 'spells'))then local str = "" str = str .. "Eu vendo estas Magias: " for name, pos in pairs(t) do str = str.." {"..name.."} = "..pos.price.." Moedas /" end str = str .. "." npcHandler:say(str, cid) elseif t[msg] then if not getPlayerLearnedInstantSpell(cid, msg) then if getPlayerLevel(cid) >= t[msg].level then if isInArray(t[msg].vocations, getPlayerVocation(cid)) then if doPlayerRemoveItem(cid,moedas[1],t[msg].price) or doPlayerRemoveItem(cid,moedas[2],t[msg].price) then doPlayerLearnInstantSpell(cid, msg) npcHandler:say("Você aprendeu uma nova magia chamada ".. msg .."!", cid) else npcHandler:say("você precisa de "..t[msg].price.." ".. getItemNameById(moedas[1]).." ou "..t[msg].price.." ".. getItemNameById(moedas[2]), cid) end else npcHandler:say("você não tem a vocação para comprar está spell.", cid) end else npcHandler:say("você precisa ter level "..t[msg].level.." ou mais para comprar essa magia.", cid) end else npcHandler:say("você já aprendeu essa magia.", cid) end end return TRUE end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())vodkart estou com um problema poq quando vou abilitar a skill no npc ele diz a magia , e não compra como faço pra resolver isso?