viking
Member
- Joined
- Aug 20, 2015
- Messages
- 323
- Reaction score
- 22

Code:
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 coins = {[2148] = 1, [2152] = 100, [2160] = 10000}
function countMoneyOnPos(pos)
local money = 0
for stack = 1, 255 do
pos.stackpos = stack
local item = getThingFromPos(pos)
if item and item.uid > 0 then
if coins[item.itemid] then
money = money + coins[item.itemid] * item.type
end
end
end
return money
end
local posCoal = {x = 32000, y = 31899, z = 7} -- POSIÇÃO DO COAL, ONDE O GOLD DEVE ESTAR
local posNpc = {x = 32000, y = 31898, z = 7} -- POSIÇÃO DO NPC
local pos = getPosByDir(getThingPos(cid), Creature(cid):getDirection(), 1) -- Creature(cid):getDirection()NÃO ALTERAR
if msgcontains(msg, 'l') or msgcontains(msg, 'L') or msgcontains(msg, 'low') or msgcontains(msg, 'Low') then
if countMoneyOnPos(pos) > 0 then
if math.random(1, 6) <= 3 then
doPlayerAddMoney(cid, countMoneyOnPos(pos)*1)
doSendMagicEffect(posNpc, 26)
doSendMagicEffect(posNpc, 28)
doCreatureSay(getNpcId(), getCreatureName(cid)..' tirou o numero '..math.random(1, 3)..', parabéns!', TALKTYPE_ORANGE_1)
else
doSendMagicEffect(posNpc, 2)
doSendMagicEffect(posNpc, 26)
doCreatureSay(getNpcId(), getCreatureName(cid)..' tirou o numero '..math.random(4, 6)..', tente novamente!', TALKTYPE_ORANGE_1)
end
for stack = 1, 255 do
pos.stackpos = stack
local item = getThingFromPos(pos)
if item and item.uid > 0 then
if coins[item.itemid] then
doRemoveItem(item.uid)
end
end
end
else
doCreatureSay(getNpcId(), getCreatureName(cid)..', coloque uma quantia de gold no recipiente para começar a apostar!', TALKTYPE_ORANGE_1)
end
elseif msgcontains(msg, 'h') or msgcontains(msg, 'H') or msgcontains(msg, 'high') or msgcontains(msg, 'High') then
if countMoneyOnPos(pos) > 0 then
if math.random(1, 6) <= 3 then
doPlayerAddMoney(cid, countMoneyOnPos(pos)*1)
doSendMagicEffect(posNpc, 26)
doSendMagicEffect(posNpc, 28)
doCreatureSay(getNpcId(), getCreatureName(cid)..' tirou o numero '..math.random(4, 6)..', parabéns!', TALKTYPE_ORANGE_1)
else
doSendMagicEffect(posNpc, 2)
doSendMagicEffect(posNpc, 26)
doCreatureSay(getNpcId(), getCreatureName(cid)..' tirou o numero '..math.random(1, 3)..', tente novamente!', TALKTYPE_ORANGE_1)
end
for stack = 1, 255 do
pos.stackpos = stack
local item = getThingFromPos(pos)
if item and item.uid > 0 then
if coins[item.itemid] then
doRemoveItem(item.uid)
end
end
end
else
doCreatureSay(getNpcId(), getCreatureName(cid)..', coloque uma quantia de gold no recipiente para começar a apostar!', TALKTYPE_ORANGE_1)
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
local posCoal = {x = 32000, y = 31899, z = 7} -- POSIÇÃO DO COAL, ONDE O GOLD DEVE ESTAR
local posNpc = {x = 32000, y = 31898, z = 7} -- POSIÇÃO DO NPC
local pos = getPosByDir(getThingPos(cid), Creature(cid):getDirection(), 1)