Zarosiano
New Member
- Joined
- Dec 9, 2022
- Messages
- 21
- Reaction score
- 1
So friends, this is the code.lua of an npc. He recognizes the storage and the item, takes the item and says something.
I tested it, it works in relation to reading the item, removing it, but in the part
That text doesn't appear on the NPC, just an empty box. I'm learning how to create code so I might be doing something wrong that I didn't notice.
Script:
I tested it, it works in relation to reading the item, removing it, but in the part
selfSay("Obrigado! Ele se chama Azor e esta ao norte na entrada de Firmrock", cid)"
That text doesn't appear on the NPC, just an empty box. I'm learning how to create code so I might be doing something wrong that I didn't notice.
Script:
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 config = {
storage = 2803, -- Storage para acesso.
item = 7495 }
if msgcontains(msg, 'irmao') then
if setPlayerStorageValue(cid, config.storage) == 1 then
selfSay(cid, 'Opa! Ele mandou um humano trazer o Rum ? Parece que ele quer realmente morar fora de Firmrock. Ei, voce pode entrar quando quiser, um amigo do meu irmao e meu amigo.')
if doPlayerRemoveItem(cid, config.item, 1)
-- coloque entre ' ' oq o npc ira falar quando o player tiver a storage
end
else
selfSay(cid, 'Nao posso deixar voce passar sem motivo.')
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())