Tbol
Well-Known Member
- Joined
- Apr 7, 2019
- Messages
- 592
- Reaction score
- 64
Idk whats wrong with it but it doesnt remove defined item, because if they teleport to cave it shouldnt remove anything but if he choses second condition it should remove it, but it doesnt
LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
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
local function creatureSayCallback(cid, type, msg)
local player = Player(cid)
local prisonPos = {x = 1648, y = 119, z = 7}
local penitentiaryPos = {x = 1700, y = 130, z = 7}
if not npcHandler:isFocused(cid) then
if msg == "hi" or msg == "hello" then
npcHandler:addFocus(cid)
npcHandler:say("Hello! If you want to teleport, just say {cave} or {testsecond}.", cid)
npcHandler.topic[cid] = 1
else
return false
end
elseif msgcontains(msg, "test") then
if player:getItemCount(15682) >= 5 then
doTeleportThing(cid, prisonPos)
npcHandler:say("Teleported to the cave.", cid)
else
npcHandler:say("You don't have enough crystals.", cid)
end
elseif msgcontains(msg, "testsecond") then
npcHandler:say("Do you want to teleport to the testsecond?", cid)
npcHandler.topic[cid] = 2
elseif msgcontains(msg, "yes") and npcHandler.topic[cid] == 2 then
if player:getItemCount(2160) >= 50 then
player:removeItem(2160, 50) //this exact code doesnt work it doesnt remove them
doTeleportThing(cid, penitentiaryPos)
npcHandler:say("Teleported to the test.", cid)
else
npcHandler:say("You don't have enough crystal coins.", cid)
end
npcHandler.topic[cid] = 0
elseif msgcontains(msg, "bye") then
npcHandler:say("Bye.", cid)
npcHandler:releaseFocus(cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())