• 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!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

RevScripts [npc] converter for canary

amoxicilina

Member
Joined
Jun 25, 2010
Messages
65
Reaction score
7
Could someone convert this npc to canary?

I even tried but it gave me a lot of error and I decided to resort to the community, but I'll keep trying in case I sonsiga before the solution here I post it here



XML:
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)

    if not npcHandler:isFocused(cid) then return false end

    local player = Player(cid)

    local msg = msg:lower()

    ------------------------------------------------------------------

    if npcHandler.topic[cid] == 0 and (msgcontains(msg, "task") or msgcontains(msg, 'mission') or msgcontains(msg, 'tasks')) then

    if getPlayerStorageValue(cid, Storage.TheShatteredIsles.TheErrand) <= 0 then

return npcHandler:say("Come back when you finish Raphael's tasks.", cid)

end

        if player:getTask() then

            local task = player:getTask()

            if player:getStorageValue(task.storage) == task.amount then

                player:taskReward(task.pointsTask, task.items, task.exp, task.storage, task_current)

                player:getPosition():sendMagicEffect(67)

                player:getPosition():sendMagicEffect(9)

                npcHandler:say(" * Reward *\n[*] Experience[*]: "..task.exp..".\n[*] Task points [*]: "..task.pointsTask..".\n[*] Item [*]: "..getItemsFromTable(task.items)..".", cid) -- problema

                npcHandler:releaseFocus(cid)

            end

        elseif player:getDailyTask() then

            local task = player:getDailyTask()

            if player:getStorageValue(task.storage) == task.amount then

                player:taskReward(task.pointsTask, task.items, task.exp, task.storage, task_daily_current)

                player:setStorageValue(task_daily_time, 1 * 60 * 60 * 24 + os.time())

                npcHandler:say(" * Reward Daily*\n[*]Experience[*]: "..task.exp..".\n[*] task points [*]: "..task.pointsTask..".\n[*] Item[*]:"..getItemsFromTable(task.items)..".",cid) -- problema

                player:getPosition():sendMagicEffect(50)

                player:getPosition():sendMagicEffect(28)

                npcHandler:releaseFocus(cid)

            end

        end


        npcHandler:say("Very well, would you like to make a {task} or {daily} task? or would you like to {quit} a task you are doing?", cid)

        npcHandler.topic[cid] = 1

    ------------------------------------------------------------------

    elseif npcHandler.topic[cid] == 1 and msgcontains(msg, "task") then

        if player:getStorageValue(task_delay) < os.time() then

            if player:getStorageValue(task_current) <= 0 then

                local text = "You can choose between tasks:"

                for _, task in pairs(task_monsters) do

                    text = text .." {"..task.name.."},"

                end

                npcHandler:say(text.." tell me which one do you want to do?", cid)

                npcHandler.topic[cid] = 2

            else

                npcHandler:say("You are already doing a task. You can only do one at a time. Say {!task} to view information about your current task. Or use {quit} to cancel the task.", cid)

            npcHandler.topic[cid] = 0

            end

        else

            npcHandler:say("You abandoned the previous task. Wait until the 2 hours of punishment is over. Time:", cid)

        end

    elseif npcHandler.topic[cid] == 2 then

        for task_number, task in pairs(task_monsters) do

            if msg == task.name then

                npcHandler:say("Okay, now you're doing the homework {"..task.name:gsub("^%l", string.upper).."}, you need to kill "..task.amount .." their. Good luck!", cid)

                player:setStorageValue(task_current, task_number)

                player:setStorageValue(task.storage, 0)

                npcHandler:releaseFocus(cid)

            else

          --      npcHandler:say("Sorry, we don't have this task.", cid)

            end

        end

    ------------------------------------------------------------------

    elseif msgcontains(msg, "daily") then

        if player:getStorageValue(task_daily_time) < os.time() then

            if player:getStorageValue(task_delay) < os.time() then

                if player:getStorageValue(task_daily_current) <= 0 then

                    local text = "You can choose between daily tasks:"

                    for _, task in pairs(task_daily) do

                        text = text .." {"..task.name.."},"

                    end

                    npcHandler:say(text.."tell me which one do you want to do?", cid)

                    npcHandler.topic[cid] = 3

                else

                    npcHandler:say("You are already doing a daily task. You can only do one a day. Say {!Task} to view information about your current task. Or use {quit} to cancel the daily task.", cid)

                end

            else

                npcHandler:say("I'm not allowed to assign tasks because you abandoned the previous task. Wait until the 2 hours of punishment is over.", cid)

            end

        else

            npcHandler:say("You have completed today's daily task. Expect to spend 24 hours to do it again.", cid)

        end

    elseif npcHandler.topic[cid] == 3 then

        for task_number, task in pairs(task_daily) do

            if msg == task.name then

                npcHandler:say("Okay, now you're doing the daily chore of  {"..task.name:gsub("^%l", string.upper).."}, you need to kill "..task.amount.."their. Good luck! ",cid)

                player:setStorageValue(task_daily_current, task_number)

                player:setStorageValue(task.storage, 0)

                npcHandler:releaseFocus(cid)

            else

                npcHandler:say("Sorry we don't have this daily task.", cid)

            end

        end

    ------------------------------------------------------------------

    elseif msgcontains(msg, "quit") then

        if npcHandler.topic[cid] == 0 then

            npcHandler:say("What kind of task do you want to finish, {task} or{daily}?", cid)

            npcHandler.topic[cid] = 4

        end

    elseif npcHandler.topic[cid] == 4 and msgcontains(msg, "task") then

        if player:getTask() then

            npcHandler:say("Unhappy with this situation, I had faith that you would bring me this mission done, but I was wrong. As a punishment, he had been unable to perform any task for 2 hours.", cid)

            player:setStorageValue(task_delay, os.time() + task_time * 60 * 60)

            player:setStorageValue(player:getTask().storage, 0)

            player:setStorageValue(task_current, 0)

            npcHandler:releaseFocus(cid)

        else

            npcHandler:say("You are not performing any task to be able to abandon it.", cid)

        end

    elseif npcHandler.topic[cid] == 4 and msgcontains(msg, "daily") then

        if player:getDailyTask() then

            npcHandler:say("Unfortunate for this situation, I had faith that you would bring me this mission done, but I was wrong. As punishment will be 2 hours without being able to perform any task.", cid)

            player:setStorageValue(task_delay, os.time() + task_time * 60 * 60)

            player:setStorageValue(player:getDailyTask().storage, 0)

            player:setStorageValue(task_daily_current, 0)

            npcHandler:releaseFocus(cid)

        else

            npcHandler:say("You are not doing any daily task to be able to abandon it.", cid)

        end

    end

end

npcHandler:setMessage(MESSAGE_GREET, "hi |PLAYERNAME|.")

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)npcHandler:setMessage(MESSAGE_FAREWELL, 'Happy hunting, old man!')

npcHandler:setCallback(CALLBACK_GREET, greetCallback)

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())
 

Farlavor

Member
Joined
Jun 20, 2009
Messages
66
Reaction score
8
DAMMIT... Isn't there any kind of NPC CONVERTER from XML to LUA for Canary????
There's only a monster converter... and it's NOT for NPC... Just for monsters and bosses... >:V
 

EduardoDantas

Intermediate OT User
Joined
Sep 25, 2013
Messages
189
Solutions
5
Reaction score
135
Location
Brazil
Could someone convert this npc to canary?

I even tried but it gave me a lot of error and I decided to resort to the community, but I'll keep trying in case I sonsiga before the solution here I post it here



XML:
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)

    if not npcHandler:isFocused(cid) then return false end

    local player = Player(cid)

    local msg = msg:lower()

    ------------------------------------------------------------------

    if npcHandler.topic[cid] == 0 and (msgcontains(msg, "task") or msgcontains(msg, 'mission') or msgcontains(msg, 'tasks')) then

    if getPlayerStorageValue(cid, Storage.TheShatteredIsles.TheErrand) <= 0 then

return npcHandler:say("Come back when you finish Raphael's tasks.", cid)

end

        if player:getTask() then

            local task = player:getTask()

            if player:getStorageValue(task.storage) == task.amount then

                player:taskReward(task.pointsTask, task.items, task.exp, task.storage, task_current)

                player:getPosition():sendMagicEffect(67)

                player:getPosition():sendMagicEffect(9)

                npcHandler:say(" * Reward *\n[*] Experience[*]: "..task.exp..".\n[*] Task points [*]: "..task.pointsTask..".\n[*] Item [*]: "..getItemsFromTable(task.items)..".", cid) -- problema

                npcHandler:releaseFocus(cid)

            end

        elseif player:getDailyTask() then

            local task = player:getDailyTask()

            if player:getStorageValue(task.storage) == task.amount then

                player:taskReward(task.pointsTask, task.items, task.exp, task.storage, task_daily_current)

                player:setStorageValue(task_daily_time, 1 * 60 * 60 * 24 + os.time())

                npcHandler:say(" * Reward Daily*\n[*]Experience[*]: "..task.exp..".\n[*] task points [*]: "..task.pointsTask..".\n[*] Item[*]:"..getItemsFromTable(task.items)..".",cid) -- problema

                player:getPosition():sendMagicEffect(50)

                player:getPosition():sendMagicEffect(28)

                npcHandler:releaseFocus(cid)

            end

        end


        npcHandler:say("Very well, would you like to make a {task} or {daily} task? or would you like to {quit} a task you are doing?", cid)

        npcHandler.topic[cid] = 1

    ------------------------------------------------------------------

    elseif npcHandler.topic[cid] == 1 and msgcontains(msg, "task") then

        if player:getStorageValue(task_delay) < os.time() then

            if player:getStorageValue(task_current) <= 0 then

                local text = "You can choose between tasks:"

                for _, task in pairs(task_monsters) do

                    text = text .." {"..task.name.."},"

                end

                npcHandler:say(text.." tell me which one do you want to do?", cid)

                npcHandler.topic[cid] = 2

            else

                npcHandler:say("You are already doing a task. You can only do one at a time. Say {!task} to view information about your current task. Or use {quit} to cancel the task.", cid)

            npcHandler.topic[cid] = 0

            end

        else

            npcHandler:say("You abandoned the previous task. Wait until the 2 hours of punishment is over. Time:", cid)

        end

    elseif npcHandler.topic[cid] == 2 then

        for task_number, task in pairs(task_monsters) do

            if msg == task.name then

                npcHandler:say("Okay, now you're doing the homework {"..task.name:gsub("^%l", string.upper).."}, you need to kill "..task.amount .." their. Good luck!", cid)

                player:setStorageValue(task_current, task_number)

                player:setStorageValue(task.storage, 0)

                npcHandler:releaseFocus(cid)

            else

          --      npcHandler:say("Sorry, we don't have this task.", cid)

            end

        end

    ------------------------------------------------------------------

    elseif msgcontains(msg, "daily") then

        if player:getStorageValue(task_daily_time) < os.time() then

            if player:getStorageValue(task_delay) < os.time() then

                if player:getStorageValue(task_daily_current) <= 0 then

                    local text = "You can choose between daily tasks:"

                    for _, task in pairs(task_daily) do

                        text = text .." {"..task.name.."},"

                    end

                    npcHandler:say(text.."tell me which one do you want to do?", cid)

                    npcHandler.topic[cid] = 3

                else

                    npcHandler:say("You are already doing a daily task. You can only do one a day. Say {!Task} to view information about your current task. Or use {quit} to cancel the daily task.", cid)

                end

            else

                npcHandler:say("I'm not allowed to assign tasks because you abandoned the previous task. Wait until the 2 hours of punishment is over.", cid)

            end

        else

            npcHandler:say("You have completed today's daily task. Expect to spend 24 hours to do it again.", cid)

        end

    elseif npcHandler.topic[cid] == 3 then

        for task_number, task in pairs(task_daily) do

            if msg == task.name then

                npcHandler:say("Okay, now you're doing the daily chore of  {"..task.name:gsub("^%l", string.upper).."}, you need to kill "..task.amount.."their. Good luck! ",cid)

                player:setStorageValue(task_daily_current, task_number)

                player:setStorageValue(task.storage, 0)

                npcHandler:releaseFocus(cid)

            else

                npcHandler:say("Sorry we don't have this daily task.", cid)

            end

        end

    ------------------------------------------------------------------

    elseif msgcontains(msg, "quit") then

        if npcHandler.topic[cid] == 0 then

            npcHandler:say("What kind of task do you want to finish, {task} or{daily}?", cid)

            npcHandler.topic[cid] = 4

        end

    elseif npcHandler.topic[cid] == 4 and msgcontains(msg, "task") then

        if player:getTask() then

            npcHandler:say("Unhappy with this situation, I had faith that you would bring me this mission done, but I was wrong. As a punishment, he had been unable to perform any task for 2 hours.", cid)

            player:setStorageValue(task_delay, os.time() + task_time * 60 * 60)

            player:setStorageValue(player:getTask().storage, 0)

            player:setStorageValue(task_current, 0)

            npcHandler:releaseFocus(cid)

        else

            npcHandler:say("You are not performing any task to be able to abandon it.", cid)

        end

    elseif npcHandler.topic[cid] == 4 and msgcontains(msg, "daily") then

        if player:getDailyTask() then

            npcHandler:say("Unfortunate for this situation, I had faith that you would bring me this mission done, but I was wrong. As punishment will be 2 hours without being able to perform any task.", cid)

            player:setStorageValue(task_delay, os.time() + task_time * 60 * 60)

            player:setStorageValue(player:getDailyTask().storage, 0)

            player:setStorageValue(task_daily_current, 0)

            npcHandler:releaseFocus(cid)

        else

            npcHandler:say("You are not doing any daily task to be able to abandon it.", cid)

        end

    end

end

npcHandler:setMessage(MESSAGE_GREET, "hi |PLAYERNAME|.")

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)npcHandler:setMessage(MESSAGE_FAREWELL, 'Happy hunting, old man!')

npcHandler:setCallback(CALLBACK_GREET, greetCallback)

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

First, you need to indent your script, because it was just awful... I'm uploading an auto indent and the script converted.

To be able to convert, you first need to understand the script, which is quite difficult given the clutter of your file. Few things have actually changed, the difference is that XML doesn't exist any more, so what used to be in XML is now in Lua, as you noticed in the first lines of the file I uploaded, converted. If you make a diff between the files, you will notice that the actual changes were small, just some functions that were renamed or had a few extra parameters.
 

Attachments

Last edited:
OP
OP
amoxicilina

amoxicilina

Member
Joined
Jun 25, 2010
Messages
65
Reaction score
7
First, you need to indent your script, because it was just awful... I'm uploading an auto indent and the script converted.

To be able to convert, you first need to understand the script, which is quite difficult given the clutter of your file. Few things have actually changed, the difference is that XML doesn't exist any more, so what used to be in XML is now in Lua, as you noticed in the first lines of the file I uploaded, converted. If you make a diff between the files, you will notice that the actual changes were small, just some functions that were renamed or had a few extra parameters.

payments, due to the delay in responding and that these days had passed.
Npc arrives at a part of the dialogue and doesn't respond anymore and doesn't deliver the task

1664050962863.png
 
Top