NPC.xml
Copie e cole qualquer qualquer arquivo e dentro coloque isso:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Mark Bonus" script="bonus.lua" walkinterval="1000" floorchange="0">
<health now="150" max="150"/>
<look type="263" head="119" body="88" legs="119" feet="0" corpse="2212"/>
<parameters>
<parameter key="module_travel" value="1"/>
<parameter key="message_greet" value="Hello PLAYERNAME. Eu vendo |poke balls| e |potions| com uma surpresa. Vale a pena conferir."/>
</parameters>
</npc>
Dentro da pasta scripts copie e cole qualquer arquivo renomeie para bonus.lua e adicione
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
function getPlayerMoney(cid)
gold = getPlayerItemCount(cid,2148)
plat = getPlayerItemCount(cid,2152)
crys = getPlayerItemCount(cid,2160)*10000
thou = getPlayerItemCount(cid,2387)*10000
money = gold + plat + crys + thou
return money
end
if getPlayerMoney(cid) >= 50000 then
doPlayerRemoveMoney(cid, 50000)
talk_start = 0
focus = 0
else
selfSay('Sorry, you don\'t have enough money.')
end
end
talk_start = 0
if msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 and talk_start >= 1 then
selfSay('Good bye, ' .. getPlayerName(cid) .. '!')
focus = 0
talk_start = 0
tempo = 0
end
end
if (msgcontains(msg, 'poke ball') or msgcontains(msg, 'poke balls')) and talkState[cid] == 1 then
selfSay("Are you sure you want to buy 10 Poke Balls + 1 Great Ball (bonus)?", cid)
talkState[cid] = 4
elseif (msgcontains(msg, 'nao') or msgcontains(msg, 'no')) and talkState[cid] == 4 then
selfSay("Well, How may I help you?", cid)
talkState[cid] = 1
elseif (msgcontains(msg, 'sim') or msgcontains(msg, 'yes')) and talkState[cid] == 4 then
if getPlayerMoney(cid) >= 100 then
doPlayerRemoveMoney(cid, 100)
talk_start = 0
focus = 0
else
selfSay('Sorry, you don\'t have enough money.')
end
end
talk_start = 0
selfSay("Here it is your bonus pack", cid)
local bags = getPlayerSlotItem(cid, 3)
local ball = 2147
local ball2 = 11437
doAddContainerItem(bags.uid, ball , 10)
doAddContainerItem(bags.uid, ball2 , 1)
talkState[cid] = 0
end
if (msgcontains(msg, 'potion') or msgcontains(msg, 'potions')) and talkState[cid] == 1 then
selfSay("Are you sure you want to buy 10 Small potions + 1 Great Potion (bonus)?", cid)
talkState[cid] = 4
elseif (msgcontains(msg, 'nao') or msgcontains(msg, 'no')) and talkState[cid] == 4 then
selfSay("Well, How may I help you?", cid)
talkState[cid] = 1
elseif (msgcontains(msg, 'sim') or msgcontains(msg, 'yes')) and talkState[cid] == 4 then
if getPlayerMoney(cid) >= 150 then
doPlayerRemoveMoney(cid, 150)
talk_start = 0
focus = 0
else
selfSay('Sorry, you don\'t have enough money.')
end
end
talk_start = 0
selfSay("Here it is your bonus pack", cid)
local bags = getPlayerSlotItem(cid, 3)
local potion = 2272
local potion2 = 2275
doAddContainerItem(bags.uid, potion , 10)
doAddContainerItem(bags.uid, potion2 , 1)
talkState[cid] = 0
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
NPC não é o meu forte, espero que de certo, estou viajando e não pude testar qualquer erro poste aqui, para eu ou outro usuário podermos corrigir.
Abraço.






info
Grupo: Campones
Registrado: 08/05/09
Posts: 9
Reputação: 0
Char no Tibia: Azura
olá,bem eu queria um npc Mark que tpw,qndo comprar algum item ganhar 1 outro,
ex:
compro 10small Pot ganho 1 Great Pot,compro 10Pokeball Ganho 1Greatball...
espero que ajudem ae,Uso Pokemon Flash!