Vendedor Pokemon.xml
<?xml version="1.0"?>
<npc name="Vendedor Pokemon" script="data/npc/scripts/pokesell.lua" walkinterval="5000" floorchange="0">
<health now="100" max="100"/>
<look type="134" head="78" body="88" legs="0" feet="88" addons="3"/>
<parameters>
<parameter key="message_greet" value="Como vai |PLAYERNAME|! Eu vendo Pokemons, Diga {lista} para saber quais eu vendo e o price deles." />
<parameter key="module_keywords" value="1" />
<parameter key="keywords" value="lista" />
<parameter key="keyword_reply1" value="Eu vendo {charmander} por 1000 gps, {squirtle} por 2000 gps, {bulbassauro} por 3000 gps, {tauros} por 4000 gps e {snorlax} por 5000 gps ." />
</parameters>
</npc>
NPC/SCRIPT
pokesell.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 poke = {
["charmander"] = {id_pokeball = 7840,price = 10000, action_id = 2046},
["squirtle"] = {id_pokeball = 7840,price = 20000, action_id = 2047},
["bulbassauro"] = {id_pokeball = 7840,price = 30000, action_id = 2048},
["tauros"] = {id_pokeball = 7840,price = 40000, action_id = 2049},
["snorlax"] = {id_pokeball = 7840,price = 50000, action_id = 2050}
}
local e = poke[msg]
if (not e) then
selfSay("Eu não vendo este pokemon ", cid)
return FALSE
end
if doPlayerRemoveMoney(cid, e.price) == TRUE then
a = doPlayerAddItem(cid,e.id_pokeball,1)
doItemSetAttribute(a, "aid", e.action_id)
selfSay("Obrigado,ai está seu pokemon !", cid)
talkState[talkUser] = 0
else
selfSay(" Você não tem ".. e.price.." gps para comprar ", cid)
talkState[talkUser] = 0
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())