• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua [1.X] Pythius the Rotten

ralke

(҂ ͠❛ ෴ ͡❛)ᕤ
Joined
Dec 17, 2011
Messages
1,470
Solutions
27
Reaction score
844
Location
Santiago - Chile
GitHub
ralke23
Twitch
ralke23
Hi! I use TFS 1.4 downgraded by nekiro (8.60) and need some help :) . Trying to make the Firewalker Quest with a little editions, but the NPC Pythius the Rotten is not working well, I took it from ORTS datapack.
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 treasureKeyword = keywordHandler:addKeyword({"treasure"}, StdModule.say, {npcHandler = npcHandler, text = "LIKE MY TREASURE? WANNA PICK SOMETHING OUT OF IT?"})
    treasureKeyword:addChildKeyword({"yes"}, StdModule.say, {npcHandler = npcHandler, text = "ALRIGHT. BUT FIRST OF ALL I WANT YOU TO BRING ME SOMETHING IN EXCHANGE. SURPRISE ME....AND IF I LIKE IT, YOU MAY GET WHAT YOU DESERVE.", reset = true})
    treasureKeyword:addChildKeyword({"no"}, StdModule.say, {npcHandler = npcHandler, text = "HAVE YOU SEEN THESE LEGENDARY ITEMS BACK THERE? WHO COULD REFUSE THE CHANCE OF OBTAINING ONE?!? SO WHAT IS YOUR ANSWER?"})

local offerKeyword = keywordHandler:addKeyword({"offer"}, StdModule.say, {npcHandler = npcHandler, text = "I GRANT YOU ACCESS TO THE DUNGEON IN THE NORTH. YOU'LL FIND SOME OF MY LIVING BROTHERS THERE....BUT.....EVERY TIME YOU WANT TO ENTER YOU HAVE TO GIVE ME SOMETHING PRECIOUS. ALRIGHT?"}, function(player) return player:getLevel() > 99 end)
    local mugKeyword = offerKeyword:addChildKeyword({"yes"}, StdModule.say, {npcHandler = npcHandler, text = "AS YOU WISH. WHAT DO YOU HAVE TO OFFER?"})
        mugKeyword:addChildKeyword({"maxilla maximus"}, StdModule.say, {npcHandler = npcHandler, text = "I LIKE THAT AND GRANT YOU ACCESS TO THE DUNGEON IN THE NORTH FOR THE NEXT FEW MINUTES. COME BACK ANYTIME AND BRING ME MORE TREASURES.", reset = true},
            function(player) return player:getItemCount(12742) > 0 end,
            function(player)
                player:removeItem(12742, 1)
                player:setStorageValue(Storage.HiddenCityOfBeregar.PythiusTheRotten, os.time() + 180)
            end
        )
        mugKeyword:addChildKeyword({"maxilla maximus"}, StdModule.say, {npcHandler = npcHandler, text = "THIS IS NOT WORTH BEING PART OF MY TREASURE! BRING ME SOMETHING ELSE.", reset = true})
        mugKeyword:addChildKeyword({""}, StdModule.say, {npcHandler = npcHandler, text = "THIS IS NOT WORTH BEING PART OF MY TREASURE! BRING ME SOMETHING ELSE", reset = true})
    offerKeyword:addChildKeyword({""}, StdModule.say, {npcHandler = npcHandler, text = "TELL ME IF YOU CHANGE YOUR MIND. MY TREASURE THIRSTS FOR GOLD.", reset = true})
keywordHandler:addKeyword({"offer"}, StdModule.say, {npcHandler = npcHandler, text = "YOU LITTLE MAGGOT. COME BACK TO ME WHEN YOU CAN HANDLE A FIGHT AGAINST MY KIND."})

-- Basic keywords
keywordHandler:addKeyword({"awaited"}, StdModule.say, {npcHandler = npcHandler, text = "I HAVE A MISSION FOR YOU BUT YOU NEED TO DIE FIRST AND RETURN AS AN {UNDEAD} CREATURE. COME BACK TO ME WHEN YOU ACHIEVED THIS GOAL."})
keywordHandler:addKeyword({"exchange"}, StdModule.say, {npcHandler = npcHandler, text = "EVERYTHING YOU CARRY WITH YOU CAN ALSO BE FOUND IN MY {TREASURE}. BRING ME SOMETHING I DON'T OWN!!!"})
keywordHandler:addKeyword({"mission"}, StdModule.say, {npcHandler = npcHandler, text = "I HAVE A MISSION FOR YOU BUT YOU NEED TO DIE FIRST AND RETURN AS AN {UNDEAD} CREATURE. COME BACK TO ME WHEN YOU ACHIEVED THIS GOAL."})
keywordHandler:addKeyword({"undead"}, StdModule.say, {npcHandler = npcHandler, text = "BOON AND BANE. I HAVE CHOSEN THIS LIFE VOLUNTARILLY AND I NEVER REGRET IT. MY {TREASURE} IS GROWING BIGGER EACH DAY."})

npcHandler:setMessage(MESSAGE_GREET, "I {AWAITED} YOU!")
npcHandler:setMessage(MESSAGE_FAREWELL, "COME BACK ANYTIME AND BRING ME TREASURES.")
npcHandler:setMessage(MESSAGE_WALKAWAY, "COME BACK ANYTIME AND BRING ME TREASURES.")

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

The thing is, it is not taking the item from the inventory or giving the time.oz storage declared. What is wrong? Since there's no errors i'm not sure where to print something, or how to fix the NPC.

I would also like to request some editions into it.
  1. Send some kind of message when the storage is given, to be aware of the time.oz. With this I mean, the player must know somehow that he has "x" minutes to enter to the dungeon or he will lost the chance.
  2. Have a message response if the player doesn't have the item. (This way they will know that they need to find the item to enter).
If someone can help me with this I'll appreciate it a lot!! :)
Here's the NPC testings from ORTS

pythius_1.png

pythius_2.png

Regards!!
 
Solution
Ok so I commented out a few other lines, and it seems my logic does indeed work. Apparently some of those other lines were being called first instead. Maybe you can move them to after and they will work fine? Not sure. All I know is that it is indeed working with the golden mug (the script version I am sharing), and it sets the players storage value. Here is the thing though, when I tried to create the item you have set "12742" I end up getting a half a bench on the ground or something... its weird. So I just altered the item back to golden mug for testing purposes. Here is a video clip of me demonstrating it working, and the console printing a storage value saved to the player...


And here is the...
Ok looks to me like you are missing some of the other parts that belong with this script. I'm not familiar with orts datapack so I will try to help but you will have to do some digging.

You say that its supposed to work by storage, and it does, according to line 28 it goes by a global storage value stored somewhere in the orts datapack I assume, its called

Lua:
Storage.HiddenCityOfBeregar.PythiusTheRotten,

Also, you mention by time.oz , im assuming was supposed to be time.os, or os.time, also found on line 28.

But the real problem is that this script only registers messages and changes storage value of player, it does nothing else with that information, I am also not familiar with the quest you speak of, but I would assume the logic is written elsewhere for the quest, and is based off the players storage value. Movements, actions, creaturescripts, ect, those are the places im assuming you will find the rest of the logic written for this quest.
 
Thanks for notice the storage thing, I registered it wrong since it belongs to PlayerStorageKeys and I just wrote Storage. Did the change but it still doesn't work. Here's how it is registered at lib/core/storages.lua

1642994488950.png

Here's the moveevent for the teleport, where the player enters to the dungeon if Pythius gave the storage.

Lua:
function onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if not player then
        return true
    end

    if player:getStorageValue(PlayerStorageKeys.PythiusTheRotten) < os.time() then
        position.y = position.y + 3
        player:teleportTo(position)
        player:say("OFFER ME SOMETHING IF YOU WANT TO PASS!", TALKTYPE_MONSTER_YELL, false, player, Position(981, 995, 13))
        position:sendMagicEffect(CONST_ME_FIREAREA)
        return true
    end

    local destination = Position(972, 992, 13)
    player:teleportTo(destination)
    position:sendMagicEffect(CONST_ME_TELEPORT)
    destination:sendMagicEffect(CONST_ME_TELEPORT)
    return true
end

About the NPC speech you can see it here

And here on video, check from minute 3:50

This video also says that to be "death and reborn" for Pythius you must have done Banshee quest before, but that's not really necessary for what I need :)

About the item, normally it should request a golden mug but I changed it for the maxilla maximus id 12742

Thanks for the help,
Regards!
 
Last edited:
Ok thats a lot of information, i didn't watch the video, but I will if needed. First a couple questions...

Does the script take the item now? What happens when you try to teleport? You said you updated the script with the storage value can you share the updated version, I may make some adjustments, such as prints to see if it is doing anything at all to help along with finding the problem.

Also , have you attempted to just put the actual number in both places you are using the storage to see if it would work that way? I imagine though, if its not even taking the item, then its not doing anything in lines 26-29. Its been a long time since I dabbled with npc's but it does look like a funny bit of logic anyways. I'm assuming none of that is called, if you could answer those questions and reshare your current script, I'll alter it and see if we can get it working properly
 
Ok thats a lot of information, i didn't watch the video, but I will if needed. First a couple questions...

Does the script take the item now? What happens when you try to teleport? You said you updated the script with the storage value can you share the updated version, I may make some adjustments, such as prints to see if it is doing anything at all to help along with finding the problem.

Also , have you attempted to just put the actual number in both places you are using the storage to see if it would work that way? I imagine though, if its not even taking the item, then its not doing anything in lines 26-29. Its been a long time since I dabbled with npc's but it does look like a funny bit of logic anyways. I'm assuming none of that is called, if you could answer those questions and reshare your current script, I'll alter it and see if we can get it working properly
Nope it doesn't take the item 12742, when I try to teleport it sends me OFFER ME SOMETHING IF YOU WANT TO PASS!, all this after updating the storage (tried with the correct PlayerStorageKey and number storage), it didn't make any difference. Thanks again!! :)

Here's the last try for the NPC.

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 treasureKeyword = keywordHandler:addKeyword({"treasure"}, StdModule.say, {npcHandler = npcHandler, text = "LIKE MY TREASURE? WANNA PICK SOMETHING OUT OF IT?"})
    treasureKeyword:addChildKeyword({"yes"}, StdModule.say, {npcHandler = npcHandler, text = "ALRIGHT. BUT FIRST OF ALL I WANT YOU TO BRING ME SOMETHING IN EXCHANGE. SURPRISE ME....AND IF I LIKE IT, YOU MAY GET WHAT YOU DESERVE.", reset = true})
    treasureKeyword:addChildKeyword({"no"}, StdModule.say, {npcHandler = npcHandler, text = "HAVE YOU SEEN THESE LEGENDARY ITEMS BACK THERE? WHO COULD REFUSE THE CHANCE OF OBTAINING ONE?!? SO WHAT IS YOUR ANSWER?"})

local offerKeyword = keywordHandler:addKeyword({"offer"}, StdModule.say, {npcHandler = npcHandler, text = "I GRANT YOU ACCESS TO THE DUNGEON IN THE NORTH. YOU'LL FIND SOME OF MY LIVING BROTHERS THERE....BUT.....EVERY TIME YOU WANT TO ENTER YOU HAVE TO GIVE ME SOMETHING PRECIOUS. ALRIGHT?"}, function(player) return player:getLevel() > 99 end)
    local mugKeyword = offerKeyword:addChildKeyword({"yes"}, StdModule.say, {npcHandler = npcHandler, text = "AS YOU WISH. WHAT DO YOU HAVE TO OFFER?"})
        mugKeyword:addChildKeyword({"golden mug"}, StdModule.say, {npcHandler = npcHandler, text = "I LIKE THAT AND GRANT YOU ACCESS TO THE DUNGEON IN THE NORTH FOR THE NEXT FEW MINUTES. COME BACK ANYTIME AND BRING ME MORE TREASURES.", reset = true},
            function(player) return player:getItemCount(12742) > 0 end,
            function(player)
                player:removeItem(12742, 1)
                player:setStorageValue(PlayerStorageKeys.PythiusTheRotten, os.time() + 180)
            end
        )
        mugKeyword:addChildKeyword({"golden mug"}, StdModule.say, {npcHandler = npcHandler, text = "THIS IS NOT WORTH BEING PART OF MY TREASURE! BRING ME SOMETHING ELSE.", reset = true})
        mugKeyword:addChildKeyword({""}, StdModule.say, {npcHandler = npcHandler, text = "THIS IS NOT WORTH BEING PART OF MY TREASURE! BRING ME SOMETHING ELSE", reset = true})
    offerKeyword:addChildKeyword({""}, StdModule.say, {npcHandler = npcHandler, text = "TELL ME IF YOU CHANGE YOUR MIND. MY TREASURE THIRSTS FOR GOLD.", reset = true})
keywordHandler:addKeyword({"offer"}, StdModule.say, {npcHandler = npcHandler, text = "YOU LITTLE MAGGOT. COME BACK TO ME WHEN YOU CAN HANDLE A FIGHT AGAINST MY KIND."})

-- Basic keywords
keywordHandler:addKeyword({"awaited"}, StdModule.say, {npcHandler = npcHandler, text = "I HAVE A MISSION FOR YOU BUT YOU NEED TO DIE FIRST AND RETURN AS AN {UNDEAD} CREATURE. COME BACK TO ME WHEN YOU ACHIEVED THIS GOAL."})
keywordHandler:addKeyword({"exchange"}, StdModule.say, {npcHandler = npcHandler, text = "EVERYTHING YOU CARRY WITH YOU CAN ALSO BE FOUND IN MY {TREASURE}. BRING ME SOMETHING I DON'T OWN!!!"})
keywordHandler:addKeyword({"mission"}, StdModule.say, {npcHandler = npcHandler, text = "I HAVE A MISSION FOR YOU BUT YOU NEED TO DIE FIRST AND RETURN AS AN {UNDEAD} CREATURE. COME BACK TO ME WHEN YOU ACHIEVED THIS GOAL."})
keywordHandler:addKeyword({"undead"}, StdModule.say, {npcHandler = npcHandler, text = "BOON AND BANE. I HAVE CHOSEN THIS LIFE VOLUNTARILLY AND I NEVER REGRET IT. MY {TREASURE} IS GROWING BIGGER EACH DAY."})

npcHandler:setMessage(MESSAGE_GREET, "I {AWAITED} YOU!")
npcHandler:setMessage(MESSAGE_FAREWELL, "COME BACK ANYTIME AND BRING ME TREASURES.")
npcHandler:setMessage(MESSAGE_WALKAWAY, "COME BACK ANYTIME AND BRING ME TREASURES.")

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Ok so I copied it all to a script in sublime so I could get a better look at it, and the first thing I noticed is that player isn't defined at all... which is weird, because you should get some kind of console error for that, so maybe, just maybe, you can change every instance of "player" (lines 25-28) to cid and maybe it will function, but I'm having a hard time believing that code is even called at all, being as its just extra added after adding the keyword.. I have looked over some other npc scripts, and they usually have something like this

Lua:
if msgcontains(msg, 'golden mug') then

This really makes no sense to me as how the creator of this script expected it to work... I'll give it a try though, I share with you my edits, you should be able to spot them easily enough and change to your own liking if it works, please let me know if this does or doesn't work for you, or if you receive any error from the console. Here you go

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 treasureKeyword = keywordHandler:addKeyword({"treasure"}, StdModule.say, {npcHandler = npcHandler, text = "LIKE MY TREASURE? WANNA PICK SOMETHING OUT OF IT?"})
    treasureKeyword:addChildKeyword({"yes"}, StdModule.say, {npcHandler = npcHandler, text = "ALRIGHT. BUT FIRST OF ALL I WANT YOU TO BRING ME SOMETHING IN EXCHANGE. SURPRISE ME....AND IF I LIKE IT, YOU MAY GET WHAT YOU DESERVE.", reset = true})
    treasureKeyword:addChildKeyword({"no"}, StdModule.say, {npcHandler = npcHandler, text = "HAVE YOU SEEN THESE LEGENDARY ITEMS BACK THERE? WHO COULD REFUSE THE CHANCE OF OBTAINING ONE?!? SO WHAT IS YOUR ANSWER?"})

local offerKeyword = keywordHandler:addKeyword({"offer"}, StdModule.say, {npcHandler = npcHandler, text = "I GRANT YOU ACCESS TO THE DUNGEON IN THE NORTH. YOU'LL FIND SOME OF MY LIVING BROTHERS THERE....BUT.....EVERY TIME YOU WANT TO ENTER YOU HAVE TO GIVE ME SOMETHING PRECIOUS. ALRIGHT?"}, function(player) return player:getLevel() > 99 end)
    local mugKeyword = offerKeyword:addChildKeyword({"yes"}, StdModule.say, {npcHandler = npcHandler, text = "AS YOU WISH. WHAT DO YOU HAVE TO OFFER?"})
        -- mugKeyword:addChildKeyword({"golden mug"}, StdModule.say, {npcHandler = npcHandler, text = "I LIKE THAT AND GRANT YOU ACCESS TO THE DUNGEON IN THE NORTH FOR THE NEXT FEW MINUTES. COME BACK ANYTIME AND BRING ME MORE TREASURES.", reset = true},
        --     function(player) return player:getItemCount(12742) > 0 end,
        --     function(player)
        --         player:removeItem(12742, 1)
        --         player:setStorageValue(PlayerStorageKeys.PythiusTheRotten, os.time() + 180)
        --     end
        -- )
        mugKeyword:addChildKeyword({"golden mug"}, StdModule.say, {npcHandler = npcHandler, text = "THIS IS NOT WORTH BEING PART OF MY TREASURE! BRING ME SOMETHING ELSE.", reset = true})
        mugKeyword:addChildKeyword({""}, StdModule.say, {npcHandler = npcHandler, text = "THIS IS NOT WORTH BEING PART OF MY TREASURE! BRING ME SOMETHING ELSE", reset = true})
    offerKeyword:addChildKeyword({""}, StdModule.say, {npcHandler = npcHandler, text = "TELL ME IF YOU CHANGE YOUR MIND. MY TREASURE THIRSTS FOR GOLD.", reset = true})
keywordHandler:addKeyword({"offer"}, StdModule.say, {npcHandler = npcHandler, text = "YOU LITTLE MAGGOT. COME BACK TO ME WHEN YOU CAN HANDLE A FIGHT AGAINST MY KIND."})

-- Basic keywords
keywordHandler:addKeyword({"awaited"}, StdModule.say, {npcHandler = npcHandler, text = "I HAVE A MISSION FOR YOU BUT YOU NEED TO DIE FIRST AND RETURN AS AN {UNDEAD} CREATURE. COME BACK TO ME WHEN YOU ACHIEVED THIS GOAL."})
keywordHandler:addKeyword({"exchange"}, StdModule.say, {npcHandler = npcHandler, text = "EVERYTHING YOU CARRY WITH YOU CAN ALSO BE FOUND IN MY {TREASURE}. BRING ME SOMETHING I DON'T OWN!!!"})
keywordHandler:addKeyword({"mission"}, StdModule.say, {npcHandler = npcHandler, text = "I HAVE A MISSION FOR YOU BUT YOU NEED TO DIE FIRST AND RETURN AS AN {UNDEAD} CREATURE. COME BACK TO ME WHEN YOU ACHIEVED THIS GOAL."})
keywordHandler:addKeyword({"undead"}, StdModule.say, {npcHandler = npcHandler, text = "BOON AND BANE. I HAVE CHOSEN THIS LIFE VOLUNTARILLY AND I NEVER REGRET IT. MY {TREASURE} IS GROWING BIGGER EACH DAY."})

function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end

    if msgcontains(msg, 'golden mug') then
        local player = Player(cid)
        if player:getItemCount(12742) > 0 then
            player:removeItem(12742, 1)
            player:setStorageValue(PlayerStorageKeys.PythiusTheRotten, os.time() + 180)
        else
            selfSay('Sorry, you don\'t seem to have the treasure I seek', cid)
        end
    end
end

npcHandler:setMessage(MESSAGE_GREET, "I {AWAITED} YOU!")
npcHandler:setMessage(MESSAGE_FAREWELL, "COME BACK ANYTIME AND BRING ME TREASURES.")
npcHandler:setMessage(MESSAGE_WALKAWAY, "COME BACK ANYTIME AND BRING ME TREASURES.")

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())


And if it does work, then you can just delete the commented out portion of the script.

42-56 are the added lines
 
@Codinablack it didn't worked. Here's the test results, no errors in console at all.

a) hi, offer, yes, golden mug, while the player have maxilla maximus on inventory.
test_1.png

b) hi, offer, yes, golden mug, while the player doesn't have maxilla maximus on inventory.
test_2.png

c) teleport, didn't worked on both cases
teleport_test.png

Btw, as a detail I should replace "golden mug" message for "maxilla maximus" before, but that really won't affect the script at all, is just the keyword ;P Thanks for the reply, i'll be attentive to test again. Regards!
 
Last edited:
Hey buddy, sorry to say but I believe you must have not swapped scripts correctly. Maybe you are saving in a similar directory? Maybe you have clones , or copies of the project and are saving in one, but running another? I only say this, because the line that you show in your screenshots

"I LIKE THAT AND GRANT YOU ACCESS TO THE DUNGEON IN THE NORTH FOR THE NEXT FEW MINUTES. COME BACK ANYTIME AND BRING ME MORE TREASURES"

Is commented out in the script I shared, which means, it can never be called or read from at all, and I did search to see if that line existed elsewhere in the script, it does not. So I'm sorry to say, the only way the npc could be calling that, is either you saved the script and tried to reload and it didn't reload the npcs or something, or you saved the script in the wrong location.. See if you can figure out whats up, maybe the problem is that you been editing the wrong one?
 
@Codinablack Very sorry, I must be asleep or something it's kinda late here :p. Here's the result, tried with and without the item on the inventory
test_1.png

After changing line 47 from
Lua:
    if msgcontains(msg, 'golden mug') then
To
Lua:
if msgcontains(msg, 'maxilla maximus') then

This happens
1643084825362.png
 
My mistake, its probable that line 31 is being called instead of my logic, try also commenting out that line too and see what happens
 
@Codinablack Thanks for the fast reply, yeah it was too early before I could edit the post xD Noticed line 31 too but commented it out and still didn't work. Also did the change on line 47 like I said on the post before. Here's the screenshot:

1643085151832.png1643085163864.png
 
Very peculiar! It calls a message that is registered to an empty string, quite odd I think. Ok, so now I'm pretty well hooked on trying to find the flaw here, and also , more-so, interested in tinkering with npc's again to figure out why its behaving the way it is, do you mind sharing with me the xml file for this npc too? I will want to start making small changes like prints and such to test on my own server and see the responses, so we don't flood this thread, and also so everytime you see a response you aren't getting your hopes up, I know how that sucks, will probably be faster for me to debug it this way, even though I'm not using the portal, in theory, if the storage value is properly saved to the player then ofc the teleporter is expected to work, and as of right now, the npc is just not doing that, or taking the item. If you share, I'll tinker, no promises on how soon I will have this fixed for ya, since it is nearing midnight where I am, but I shall have some news for you by tomorrow for sure, hopefully a full on fix as well
 
@Codinablack Sure!! No worries is much better if you print it locally so we can advance with it :)
XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Pythius The Rotten" script="Pythius The Rotten.lua" walkinterval="0">
    <health now="100" max="100" />
    <look type="231" />
    <parameters>
        <!--I GRANT YOU ACCESS TO THE DUNGEON IN THE NORTH. YOU'LL FIND SOME OF MY LIVING BROTHERS THERE-->
        <parameter key="message_greet" value="I AWAITED YOU!" />
        <parameter key="message_farewell" value="YOU ARE ALWAYS WELCOME HERE." />
        <parameter key="message_walkaway" value="YOU ARE ALWAYS WELCOME HERE." />
    </parameters>
</npc>

You can also msg me on discord if you think is necessary, felipe23#1113
Thanks again for the help, Regards!
 
Ok so I commented out a few other lines, and it seems my logic does indeed work. Apparently some of those other lines were being called first instead. Maybe you can move them to after and they will work fine? Not sure. All I know is that it is indeed working with the golden mug (the script version I am sharing), and it sets the players storage value. Here is the thing though, when I tried to create the item you have set "12742" I end up getting a half a bench on the ground or something... its weird. So I just altered the item back to golden mug for testing purposes. Here is a video clip of me demonstrating it working, and the console printing a storage value saved to the player...


And here is the script that worked for me, if you get the same results as me in the video, then I urge you to try the teleport and see if all is good. If for some reason this still doesn't work for you, please msg back here with details and we can keep trying to sort this out.


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 treasureKeyword = keywordHandler:addKeyword({"treasure"}, StdModule.say, {npcHandler = npcHandler, text = "LIKE MY TREASURE? WANNA PICK SOMETHING OUT OF IT?"})
    treasureKeyword:addChildKeyword({"yes"}, StdModule.say, {npcHandler = npcHandler, text = "ALRIGHT. BUT FIRST OF ALL I WANT YOU TO BRING ME SOMETHING IN EXCHANGE. SURPRISE ME....AND IF I LIKE IT, YOU MAY GET WHAT YOU DESERVE.", reset = true})
    treasureKeyword:addChildKeyword({"no"}, StdModule.say, {npcHandler = npcHandler, text = "HAVE YOU SEEN THESE LEGENDARY ITEMS BACK THERE? WHO COULD REFUSE THE CHANCE OF OBTAINING ONE?!? SO WHAT IS YOUR ANSWER?"})

local offerKeyword = keywordHandler:addKeyword({"offer"}, StdModule.say, {npcHandler = npcHandler, text = "I GRANT YOU ACCESS TO THE DUNGEON IN THE NORTH. YOU'LL FIND SOME OF MY LIVING BROTHERS THERE....BUT.....EVERY TIME YOU WANT TO ENTER YOU HAVE TO GIVE ME SOMETHING PRECIOUS. ALRIGHT?"}, function(player) return player:getLevel() > 99 end)
    local mugKeyword = offerKeyword:addChildKeyword({"yes"}, StdModule.say, {npcHandler = npcHandler, text = "AS YOU WISH. WHAT DO YOU HAVE TO OFFER?"})
        -- mugKeyword:addChildKeyword({"golden mug"}, StdModule.say, {npcHandler = npcHandler, text = "I LIKE THAT AND GRANT YOU ACCESS TO THE DUNGEON IN THE NORTH FOR THE NEXT FEW MINUTES. COME BACK ANYTIME AND BRING ME MORE TREASURES.", reset = true},
        --     function(player) return player:getItemCount(12742) > 0 end,
        --     function(player)
        --         player:removeItem(12742, 1)
        --         player:setStorageValue(PlayerStorageKeys.PythiusTheRotten, os.time() + 180)
        --     end
        -- )
        --mugKeyword:addChildKeyword({"golden mug"}, StdModule.say, {npcHandler = npcHandler, text = "THIS IS NOT WORTH BEING PART OF MY TREASURE! BRING ME SOMETHING ELSE.", reset = true})
        --mugKeyword:addChildKeyword({""}, StdModule.say, {npcHandler = npcHandler, text = "THIS IS NOT WORTH BEING PART OF MY TREASURE! BRING ME SOMETHING ELSE", reset = true})
    ---offerKeyword:addChildKeyword({""}, StdModule.say, {npcHandler = npcHandler, text = "TELL ME IF YOU CHANGE YOUR MIND. MY TREASURE THIRSTS FOR GOLD.", reset = true})
keywordHandler:addKeyword({"offer"}, StdModule.say, {npcHandler = npcHandler, text = "YOU LITTLE MAGGOT. COME BACK TO ME WHEN YOU CAN HANDLE A FIGHT AGAINST MY KIND."})

-- Basic keywords
keywordHandler:addKeyword({"awaited"}, StdModule.say, {npcHandler = npcHandler, text = "I HAVE A MISSION FOR YOU BUT YOU NEED TO DIE FIRST AND RETURN AS AN {UNDEAD} CREATURE. COME BACK TO ME WHEN YOU ACHIEVED THIS GOAL."})
keywordHandler:addKeyword({"exchange"}, StdModule.say, {npcHandler = npcHandler, text = "EVERYTHING YOU CARRY WITH YOU CAN ALSO BE FOUND IN MY {TREASURE}. BRING ME SOMETHING I DON'T OWN!!!"})
keywordHandler:addKeyword({"mission"}, StdModule.say, {npcHandler = npcHandler, text = "I HAVE A MISSION FOR YOU BUT YOU NEED TO DIE FIRST AND RETURN AS AN {UNDEAD} CREATURE. COME BACK TO ME WHEN YOU ACHIEVED THIS GOAL."})
keywordHandler:addKeyword({"undead"}, StdModule.say, {npcHandler = npcHandler, text = "BOON AND BANE. I HAVE CHOSEN THIS LIFE VOLUNTARILLY AND I NEVER REGRET IT. MY {TREASURE} IS GROWING BIGGER EACH DAY."})

function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        print("not focused")
        return false
    end

    if msgcontains(msg, 'golden mug') then
        local player = Player(cid)
        if player:getItemCount(2033) > 0 then
            selfSay('I LIKE THAT AND GRANT YOU ACCESS TO THE DUNGEON IN THE NORTH FOR THE NEXT FEW MINUTES. COME BACK ANYTIME AND BRING ME MORE TREASURES.', cid)
            player:removeItem(2033, 1)
            player:setStorageValue(PlayerStorageKeys.PythiusTheRotten, os.time() + 180)
            print(player:getStorageValue(PlayerStorageKeys.PythiusTheRotten))
        else
            selfSay('Sorry, you don\'t seem to have the treasure I seek', cid)
        end
    end
end

npcHandler:setMessage(MESSAGE_GREET, "I {AWAITED} YOU!")
npcHandler:setMessage(MESSAGE_FAREWELL, "COME BACK ANYTIME AND BRING ME TREASURES.")
npcHandler:setMessage(MESSAGE_WALKAWAY, "COME BACK ANYTIME AND BRING ME TREASURES.")

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Solution
Amazing!! Works perfectly
works.png

A last thing if I can ask, would you be able to make the teleport sends you a message of how many time left you have for enter, when the player steps in? With this I mean, when you enter to the "dungeon" like is shown in the picture I attached, a message appears and says "Pythius gave you "x" time left to enter here".

So if we leave the dungeon, then enter again, and we got the storage, we will know how many time left we have before having to offer maxilla maximus again. (This way, if the players dies in the quest he'll still have a chance limited by time, and he'll be noticed about it).

At this part of the moveevent
Lua:
local destination = Position(972, 992, 13)
    player:teleportTo(destination)
    position:sendMagicEffect(CONST_ME_TELEPORT)
    destination:sendMagicEffect(CONST_ME_TELEPORT)

Again, thanks for your help. I'm really happy with the result you helped me a lot with this one :D
Regards!
 
Amazing!! Works perfectly
View attachment 65094

A last thing if I can ask, would you be able to make the teleport sends you a message of how many time left you have for enter, when the player steps in? With this I mean, when you enter to the "dungeon" like is shown in the picture I attached, a message appears and says "Pythius gave you "x" time left to enter here".

So if we leave the dungeon, then enter again, and we got the storage, we will know how many time left we have before having to offer maxilla maximus again. (This way, if the players dies in the quest he'll still have a chance limited by time, and he'll be noticed about it).

At this part of the moveevent
Lua:
local destination = Position(972, 992, 13)
    player:teleportTo(destination)
    position:sendMagicEffect(CONST_ME_TELEPORT)
    destination:sendMagicEffect(CONST_ME_TELEPORT)

Again, thanks for your help. I'm really happy with the result you helped me a lot with this one :D
Regards!
Give this a try


Lua:
local destination = Position(972, 992, 13)
    local timeLeft = player:getStorageValue(PlayerStorageKeys.PythiusTheRotten) - os.time()
    player:teleportTo(destination)
    player:sendTextMessage(MESSAGE_INFO_DESCR,"Pythius gave you " ..timeLeft.. " to enter here")
    position:sendMagicEffect(CONST_ME_TELEPORT)
    destination:sendMagicEffect(CONST_ME_TELEPORT)

should pop up at the bottom, like the info when you try to use something you can't, or go somewhere not reachable.
 
Give this a try


Lua:
local destination = Position(972, 992, 13)
    local timeLeft = player:getStorageValue(PlayerStorageKeys.PythiusTheRotten) - os.time()
    player:teleportTo(destination)
    player:sendTextMessage(MESSAGE_INFO_DESCR,"Pythius gave you " ..timeLeft.. " to enter here")
    position:sendMagicEffect(CONST_ME_TELEPORT)
    destination:sendMagicEffect(CONST_ME_TELEPORT)

should pop up at the bottom, like the info when you try to use something you can't, or go somewhere not reachable.
Jajajajaja works perfect! Thanks a lot :D
Thread is solved now

timer.png

Regards!
 
You should know, that it has some flaws, such as missing the other two lines of text, also I don't think all the keywords are necessary, could probably just say hi, and then golden mug and still get same result, as well as , im pretty certain that it doesn't break the focus of the npc by giving you the mug, ofc it would once you walk so far away, but again, im unfamiliar with this quest and npc, so just thought I would let you know the problems/risks associated with this hack of a fix
 
Back
Top