Matheus Vieira
Member
- Joined
- Apr 11, 2015
- Messages
- 102
- Reaction score
- 6
0.4
Hello guys, I'm here to ask for a favor.
To start, I have this npc's script, where it gives the player a task to do, like killing some amount of monsters, and it works perfectly, BUT i want something more.
I was trying to do something like: If the player has a specific storage, the npc will give them the task, but if the player do not have the specific storage, the npc will not give the task and will tell the player about it.
But in this order, where i put the getPlayerStorage it does not work, and i don't know why, the npc gives the task anyway and does not appear any error in the console
Hello guys, I'm here to ask for a favor.
To start, I have this npc's script, where it gives the player a task to do, like killing some amount of monsters, and it works perfectly, BUT i want something more.
I was trying to do something like: If the player has a specific storage, the npc will give them the task, but if the player do not have the specific storage, the npc will not give the task and will tell the player about it.
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local quest = 11475
local reward = 70000
local markTable = {
-- {markPos = Coordenadas da marcação, markType = Tipo de marcação, markDescription = Descrição da marcação}
{markPos = {x = , y = , z = }, markType = MAPMARK_SWORD, markDescription = ""}
}
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 func_addMark = doPlayerAddMapMark
if(not func_addMark) then
func_addMark = doAddMapMark
end
if(msgcontains(msg, "location")) then
for mark, x in pairs(markTable) do
func_addMark(cid, x.markPos, x.markType, x.markDescription ~= nil and x.markDescription or "")
end
selfSay("", cid)
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if(not npcHandler:isFocused(cid)) then
return false
elseif msgcontains(msg, "") and talkState[talkUser] == 1 then
npcHandler:say("", cid)
talkState[talkUser] = 2
elseif msgcontains(msg, "") and talkState[talkUser] == 2 then
if(getPlayerStorageValue(cid,11476) < 4) then <!--- Here's the storage that the player need to start this quest --->
npcHandler:say("", cid)
setPlayerStorageValue(cid, quest, 2)
talkState[talkUser] = 0
else
npcHandler:say('', cid)
end
elseif msgcontains(msg, "") then
local str = getPlayerStorageValue(cid, quest)
if(str < 2) then
npcHandler:say("", cid)
talkState[talkUser] = 1
return true
elseif(str == 2) then
npcHandler:say("", cid)
elseif(str == 3) then
npcHandler:say("", cid)
setPlayerStorageValue(cid, quest, 4)
elseif(str == 4) then
npcHandler:say("", cid)
talkState[talkUser] = 0
end
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
But in this order, where i put the getPlayerStorage it does not work, and i don't know why, the npc gives the task anyway and does not appear any error in the console