GU
poketibia

[Pk] Npc Task System Para Poketibia

Por GuhPk, 20 de out. de 2012 em NPCs, monsters e raids

otserv
23
9.7k
zipter98Z
15 de novembro de 2013 às 12:34

Foi mal, esse erro foi burrice minha ._.

 

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 t = {need_items = {2160, 2159, 2158}, remove_items = {1, 2, 3}}
local g = t.need_items
local h = t.remove_items
premio1 = x -- coloque aqui o id do dinheiro
quant1 = x -- quantidade de grana que vai ganhar
pexp = x -- experiencia que vai ganhar no premio
 
 
    if msgcontains(msg, 'mission') or msgcontains(msg, 'help') then
        selfSay("Você gostaria de me ajudar numa missão?", cid)
        doPlayerSendTextMessage(cid, 27, "Say yes or no.")
        talkState[talkUser] = 1
        return true           
    elseif msgcontains(msg 'yes') and talkState[talkUser] == 1 then
        if getPlayerStorageValue(cid, storage) < 1 then
            selfSay("Certo, vá pegar x qnt de x items!", cid) 
setPlayerStorageValue(cid, 222011, 1)
            doPlayerSendTextMessage(cid, 27, "If you alreay have the items, say complete.")
            talkState[talkUser] = 2
            return true
        else
            selfSay("Você já me ajudou.", cid)
            talkState[talkUser] = 0
            return true
        end
    elseif msgcontains(msg, 'no') and talkState[talkUser] == 1 then
        selfSay("Ok então...", cid)
        talkState[talkUser] = 0
        return true
    elseif msgcontains(msg, 'complete') and (talkState[talkUser] == 2 or getPlayerStorageValue(cid, 222011) >= 1) then
        for i = 1, #g do
            if getPlayerItemCount(cid, g[i]) >= h[i] then
                doPlayerRemoveItem(cid, g[i], h[i])
                selfSay("Obrigado! Aqui está seu prêmio.", cid)
                doPlayerAddItem(cid, premio1, quant1)
                setPlayerStorageValue(cid, storage, 1)
setPlayerStorageValue(cid, 222011, -1)
                talkState[talkUser] = 0
                return true
            else
                selfSay("Você não possui os items requisitados.", cid)
                talkState[talkUser] = 0
                return true
            end
        end
    end
    return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
SoulvilingS
15 de novembro de 2013 às 14:29

Quando falo hi, mission tudo certo, ai na hora do "yes" que não funciona e dar esse erro:

[15/11/2013 13:20:01] [Error - Npc interface] 
[15/11/2013 13:20:01] data/npc/scripts/task.lua:onCreatureSay
[15/11/2013 13:20:01] Description: 
[15/11/2013 13:20:01] data/npc/scripts/task.lua:29: attempt to call local 'msg' (a string value)
[15/11/2013 13:20:01] stack traceback:
[15/11/2013 13:20:01]  data/npc/scripts/task.lua:29: in function 'callback'
[15/11/2013 13:20:01]  data/npc/lib/npcsystem/npchandler.lua:391: in function 'onCreatureSay'
[15/11/2013 13:20:01]  data/npc/scripts/task.lua:7: in function <data/npc/scripts/task.lua:7>
zipter98Z
15 de novembro de 2013 às 21:12

Outra burrice, desculpe :c

 

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 t = {need_items = {2160, 2159, 2158}, remove_items = {1, 2, 3}}
local g = t.need_items
local h = t.remove_items
premio1 = x -- coloque aqui o id do dinheiro
quant1 = x -- quantidade de grana que vai ganhar
pexp = x -- experiencia que vai ganhar no premio
 
 
    if msgcontains(msg, 'mission') or msgcontains(msg, 'help') then
        selfSay("Você gostaria de me ajudar numa missão?", cid)
        doPlayerSendTextMessage(cid, 27, "Say yes or no.")
        talkState[talkUser] = 1
        return true           
    elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
        if getPlayerStorageValue(cid, storage) < 1 then
            selfSay("Certo, vá pegar x qnt de x items!", cid) 
setPlayerStorageValue(cid, 222011, 1)
            doPlayerSendTextMessage(cid, 27, "If you alreay have the items, say complete.")
            talkState[talkUser] = 2
            return true
        else
            selfSay("Você já me ajudou.", cid)
            talkState[talkUser] = 0
            return true
        end
    elseif msgcontains(msg, 'no') and talkState[talkUser] == 1 then
        selfSay("Ok então...", cid)
        talkState[talkUser] = 0
        return true
    elseif msgcontains(msg, 'complete') and (talkState[talkUser] == 2 or getPlayerStorageValue(cid, 222011) >= 1) then
        for i = 1, #g do
            if getPlayerItemCount(cid, g[i]) >= h[i] then
                doPlayerRemoveItem(cid, g[i], h[i])
                selfSay("Obrigado! Aqui está seu prêmio.", cid)
                doPlayerAddItem(cid, premio1, quant1)
                setPlayerStorageValue(cid, storage, 1)
setPlayerStorageValue(cid, 222011, -1)
                talkState[talkUser] = 0
                return true
            else
                selfSay("Você não possui os items requisitados.", cid)
                talkState[talkUser] = 0
                return true
            end
        end
    end
    return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
SoulvilingS
15 de novembro de 2013 às 21:24

outro erro ´-´

[15/11/2013 20:22:12] [Error - TalkAction Interface] 
[15/11/2013 20:22:12] data/talkactions/scripts/createitem.lua:onSay
[15/11/2013 20:22:12] Description: 
[15/11/2013 20:22:12] (luaDoPlayerAddItemEx) Item not found
zipter98Z
15 de novembro de 2013 às 21:28

Vish, vou colocar esse NPC no meu server pra analisar melhor. Ai, quando eu corrigir os erros, posto aqui, ou se você preferir, mando por PM.

SoulvilingS
15 de novembro de 2013 às 21:30

Ajeitei aqui, era uma besteira. Obrigado!

zipter98Z
15 de novembro de 2013 às 21:53

Ah, de nada :D

6 anos depois...
KaboFlowK
04 de fevereiro de 2020 às 04:01
Em 15/11/2013 em 17:12, zipter98 disse:

Outra burrice, desculpe :c

 

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 t = {need_items = {2160, 2159, 2158}, remove_items = {1, 2, 3}}
local g = t.need_items
local h = t.remove_items
premio1 = x -- coloque aqui o id do dinheiro
quant1 = x -- quantidade de grana que vai ganhar
pexp = x -- experiencia que vai ganhar no premio
 
 
    if msgcontains(msg, 'mission') or msgcontains(msg, 'help') then
        selfSay("Você gostaria de me ajudar numa missão?", cid)
        doPlayerSendTextMessage(cid, 27, "Say yes or no.")
        talkState[talkUser] = 1
        return true           
    elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
        if getPlayerStorageValue(cid, storage) < 1 then
            selfSay("Certo, vá pegar x qnt de x items!", cid) 
setPlayerStorageValue(cid, 222011, 1)
            doPlayerSendTextMessage(cid, 27, "If you alreay have the items, say complete.")
            talkState[talkUser] = 2
            return true
        else
            selfSay("Você já me ajudou.", cid)
            talkState[talkUser] = 0
            return true
        end
    elseif msgcontains(msg, 'no') and talkState[talkUser] == 1 then
        selfSay("Ok então...", cid)
        talkState[talkUser] = 0
        return true
    elseif msgcontains(msg, 'complete') and (talkState[talkUser] == 2 or getPlayerStorageValue(cid, 222011) >= 1) then
        for i = 1, #g do
            if getPlayerItemCount(cid, g[i]) >= h[i] then
                doPlayerRemoveItem(cid, g[i], h[i])
                selfSay("Obrigado! Aqui está seu prêmio.", cid)
                doPlayerAddItem(cid, premio1, quant1)
                setPlayerStorageValue(cid, storage, 1)
setPlayerStorageValue(cid, 222011, -1)
                talkState[talkUser] = 0
                return true
            else
                selfSay("Você não possui os items requisitados.", cid)
                talkState[talkUser] = 0
                return true
            end
        end
    end
    return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

qe tire tp o npc?