Estou meio que sem tempo, então vou te passar um rápido aqui !
Em data/actions/scripts crie um arquivo chamado boox.lua e cole isso:
local a = {
[iDDABOX] = {pokemons = {"Shiny Charizard"}}
local happy = 1000
function onUse(cid, item, frompos, item2, topos)
local b = a[item.itemid]
if not b then return true end
local pokemon = b.pokemons[math.random(#b.pokemons)]
if not pokes[pokemon] then return true end
doPlayerSendTextMessage(cid, 27, "You opened a pokemon prize box +"..item.itemid - (11637).."!")
doPlayerSendTextMessage(cid, 27, "The prize pokemon was a "..pokemon..", congratulations!")
doSendMagicEffect(getThingPos(cid), 29)
addPokeToPlayer(cid, pokemon, 0, nil, btype) --alterado v1.9
doRemoveItem(item.uid, 1)
if useOTClient then
doCreatureExecuteTalkAction(cid, "/salvar")
end
return true
end
Em data/actions/actions.xml cole essa tag:
<action itemid="IDDABOX" event="script" value="boox.lua"/>
Data/npc: Crie um arquivo com o nome do NPC que quiser, vou usar Ruby como exemplo, e dentro do arquivo cole isso:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Ruby" script="RUBYTRADE.lua" walkinterval="350000" floorchange="0" speed="0">
<health now="100" max="100"/>
<look type="2335" head="20" body="100" legs="50" feet="0"/>
<parameters>
<parameter key="message_greet" value="Hello |PLAYERNAME|.I need {help}...you help me?"/> </parameters>
</npc>
Em data/npc/scripts crie um arquivo chamado RUBYTRADE.lua e cole isso dentro:
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
msg = string.lower(msg)
---------
local need = {
{id = ID DAS ESSENCES, qt = 50}, --ID DAS ESSENCES ZARD, QUANTIDADE
}
local rewards = {
{id = IDDABOX, qt = 1}, --charizard BOX
}
local stoFinish = 92120 -- USE ESSA OU A STORAGE QUE QUISER
---------
if msgcontains(msg, 'help') or msgcontains(msg, 'ajuda') then
if getPlayerStorageValue(cid, stoFinish) >= 500 then
selfSay("Sorry, you already had done this quest.", cid)
talkState[talkUser] = 0
return true
end
selfSay("Olá meu amigo, sou o NPC de trocas de Essences, me dê 50 Essences e lhe darei 1 Box que virá seu Pokemon! Diga YES para trocarmos.",cid)
talkState[talkUser] = 1
return true
elseif msgcontains(msg, 'yes') or msgcontains(msg, 'sim') and talkState[talkUser] == 1 then
if getPlayerItemCount(cid, need[1].id) < need[1].qt then
selfSay("Você não me trouxe todas as Essences...", cid)
selfSay("Lembre-se, eu preciso de 50 Essences...", cid)
talkState[talkUser] = 0
return true
end
for i = 1, #need do
doPlayerRemoveItem(cid, need.id, need.qt)
end
for i = 1, #rewards do
doPlayerAddItem(cid, rewards.id, rewards.qt)
doPlayerAddExperience(cid, 0)
end
selfSay("Obrigado, tchau!", cid)
setPlayerStorageValue(cid, stoFinish, 1)
talkState[talkUser] = 0
return true
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
OBS: Não testei