• 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!

Solved Use talkaction more then once, and stops working

  • Thread starter Thread starter Xikini
  • Start date Start date
X

Xikini

Guest
0.3.7

I say: /quest test
shows expected dialogue.
I say it again: /quest test
shows 'Quest name test is not an existing quest.'

First time trying to work with strings and talkactions, but it's driving me crazy.

Can someone tell me why it's doing this, or show me where my mistake is?
Code:
local quest = {
     ["test"] = {storage = 45001},
     ["test two"] = {storage = 45002},
}

function onSay(cid, words, param, channel)
     param = param:lower()
     quest_exists = quest[param]
     local str = ""
  
     if param == "" or not param then
         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Quest name blank is not an existing quest.")
         return true
     end
  
     if quest_exists then
         quest = quest_exists
         storage = quest.storage
         for _, pid in ipairs(getPlayersOnline()) do
             str = str .. "" .. getPlayerStorageValue(pid, storage) .." | " .. getCreatureName(pid ).. "\n"
         end
         doShowTextDialog(cid, 1956, "Showing online player status of " .. param ..":\n\n" .. str .. "")
     else
         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Quest name " .. param .. " is not an existing quest.")
     end

     return true
end
 
0.3.7

I say: /quest test
shows expected dialogue.
I say it again: /quest test
shows 'Quest name test is not an existing quest.'

First time trying to work with strings and talkactions, but it's driving me crazy.

Can someone tell me why it's doing this, or show me where my mistake is?
Code:
local quest = {
     ["test"] = {storage = 45001},
     ["test two"] = {storage = 45002},
}

function onSay(cid, words, param, channel)
     param = param:lower()
     quest_exists = quest[param]
     local str = ""

     if param == "" or not param then
         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Quest name blank is not an existing quest.")
         return true
     end

     if quest_exists then
         quest = quest_exists
         storage = quest.storage
         for _, pid in ipairs(getPlayersOnline()) do
             str = str .. "" .. getPlayerStorageValue(pid, storage) .." | " .. getCreatureName(pid ).. "\n"
         end
         doShowTextDialog(cid, 1956, "Showing online player status of " .. param ..":\n\n" .. str .. "")
     else
         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Quest name " .. param .. " is not an existing quest.")
     end

     return true
end
quest = quest_exists
Here is the problem, you are setting the "local quest" outside the function to that thing. change the name or change it to "local quest = quest_exists"
 
quest = quest_exists
Here is the problem, you are setting the "local quest" outside the function to that thing. change the name or change it to "local quest = quest_exists"
I had run the same train of thought at one point, but missed the random one's I had put down there. :P
Thank you!
 
Back
Top