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

Collection TFS 1.4.2

OTcreator

Well-Known Member
Joined
Feb 14, 2022
Messages
483
Solutions
1
Reaction score
53
Hello!
I need re-write this code to TFS 1.4.2.
I found this code for TFS 1.X but on 1.4.2 not working.

LUA:
-- Collecting items missions by Limos
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local talkState = {}

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 missions = {
   [1] = {items = {
     {id = 2413, count = 1} -- broad sword
     },
     message = "Now bring me those",
     level = 20,
     rewardexp = 20000
   },
   [2] = {items = {
     {id = 2430, count = 1} -- knight axe
     },
     message = "Thank you! Now bring me those",
     level = 30,
     rewardexp = 50000
   },
   [3] = {items = {
     {id = 3961, count = 1} -- lich staff
     },
     message = "Awesome, bring me those",
     level = 40,
     rewardexp = 70000
   },
   [4] = {items = {
     {id = 2438, count = 1} -- epee
     },
     message = "Thanks, now bring me those",
     level = 60,
     rewardexp = 90000
   },
   [5] = {items = {
     {id = 7427, count = 1} -- chaos mace
     },
     message = "Awesome, now bring me those",
     level = 80,
     rewardexp = 150000
   },
      [6] = {items = {
     {id = 2414, count = 1} -- dragon lance
     },
     message = "Extra, bring me those",
     level = 100,
     rewardexp = 200000
   },
      [7] = {items = {
     {id = 2393, count = 1} -- giant sword
     },
     message = "Great, now bring me those",
     level = 110,
     rewardexp = 230000
   },
      [8] = {items = {
     {id = 2454, count = 1} -- war axe
     },
     message = "Awesome! Bring me those",
     level = 120,
     rewardexp = 250000
   },
      [9] = {items = {
     {id = 2452, count = 1} -- heavy mace
     },
     message = "Nice! This is last mission from me. I upgrade your weapons if you bring me ",
     level = 150,
     rewarditem = {id = 8717, count = 5},
     rewardexp = 350000
   }
}

local storage = 45552

local function getItemsFromTable(itemtable)
     local text = ""
     for v = 1, #itemtable do
         count, info = itemtable[v].count, getItemInfo(itemtable[v].id)
         local ret = ", "
         if v == 1 then
             ret = ""
         elseif v == #itemtable then
             ret = " and "
         end
         text = text .. ret
         text = text .. (count > 1 and count or info.article).." "..(count > 1 and info.plural or info.name)
     end
     return text
end

function creatureSayCallback(cid, type, msg)

    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
    if(msgcontains(msg, 'upgradable bags')) then
        selfSay('Do you want to give me {50 demonic essence} for 1 upgradable bags?', cid)
        talkState[talkUser] = 10
    elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 10) then
    if getPlayerStorageValue(cid,storage) >= 9 then
        if(getPlayerItemCount(cid, 6500) >= 50) then
            if(doPlayerRemoveItem(cid, 6500, 50)) then
                doPlayerAddItem(cid, 8717, 1)
                selfSay('Here you are. Good luck in upgrade!', cid)
            else
                selfSay('Sorry, you don\'t have done weapons mission.', cid)
            end

        else
            selfSay('Sorry, you don\'t have {50 demonic essence} to exchange.', cid)
        end
        else
        selfSay('Sorry, you don\'t have done {weapons missions}.', cid)
        end

        talkState[talkUser] = 0
    elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser])) then
        talkState[talkUser] = 0
        selfSay('Ok then.', cid)
    end

     local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

     local xstorage = getPlayerStorageValue(cid, storage)
     local x = missions[xstorage]

     if not npcHandler:isFocused(cid) then
         return false
     end
    
     if msgcontains(msg, 'help') then
         if xstorage == -1 then
             selfSay("I need a lot of weapons to upgrade. Can you help me? If you done all mission I upgrade your weapons. Say {yes}!", cid)
             talkState[talkUser] = 1
         elseif x then
             if getPlayerLevel(cid) >= x.level then
                 selfSay("You are bring me this {weapons}? Great! talk to me {yes}.", cid)
                 talkState[talkUser] = 1
             else
                 selfSay("You don't have "..x.level.." level, come back later.", cid)
             end
         else
             selfSay("Thanks, but you already give me all weapons.", cid)
             npcHandler:releaseFocus(cid)
         end
     elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
         if xstorage == -1 then
             setPlayerStorageValue(cid, storage, 1)
             local x = missions[getPlayerStorageValue(cid, storage)]
             selfSay(x.message.." {"..getItemsFromTable(x.items).."}.", cid)
         elseif x then
             local amount = 0
             for i = 1, #x.items do
                 if getPlayerItemCount(cid, x.items[i].id) >= x.items[i].count then
                     amount = amount + 1
                 end
             end
             if amount == #x.items then
                 for i = 1, #x.items do
                     doPlayerRemoveItem(cid, x.items[i].id, x.items[i].count)
                 end
                 if x.rewarditem then
                     local count, info = x.rewarditem.count, getItemInfo(x.rewarditem.id)
                     doPlayerAddItem(cid, x.rewarditem.id, count)
                     selfSay("You received {"..(count > 1 and count or info.article).." "..(count > 1 and info.plural or info.name).."}.",cid)
                 end
                 if x.rewardexp then
                     doPlayerAddExp(cid, x.rewardexp)
                     selfSay("You received {"..x.rewardexp.." experience}.",cid)
                 end
                 setPlayerStorageValue(cid, storage, xstorage + 1)
                 local x = missions[getPlayerStorageValue(cid, storage)]
                 if x then
                     selfSay(x.message.." {"..getItemsFromTable(x.items).."}.", cid)
                 else
                     selfSay("Thanks alot! I can finish upgrade! Take 3 upgradable bags. Use on your weapons.", cid)
                 end
             else
                 local n = 0
                 for i = 1, #x.items do
                     if getPlayerItemCount(cid, x.items[i].id) < x.items[i].count then
                         n = n + 1
                     end
                 end
                 local text = ""
                 local c = 0
                 for v = 1, #x.items do
                     count, info = x.items[v].count - getPlayerItemCount(cid, x.items[v].id), getItemInfo(x.items[v].id)
                     if getPlayerItemCount(cid, x.items[v].id) < x.items[v].count then
                         c = c + 1
                         local ret = ", "
                         if c == 1 then
                             ret = ""
                         elseif c == n then
                             ret = " and "
                         end
                         text = text .. ret
                         text = text .. (count > 1 and count or info.article).." "..(count > 1 and info.plural or info.name)
                     end
                 end
                 selfSay("You don't have all items, you still need to get {"..text.."}.", cid)
             end
         end
         talkState[talkUser] = 0
     elseif msgcontains(msg, 'weapons') and x then
         selfSay("Now I need this weapons: {"..getItemsFromTable(x.items).."}.", cid)
     elseif msgcontains(msg, 'no') and talkState[talkUser] == 1 then
         selfSay("Oh well...", cid)
     end
     return true
end

npcHandler:setMessage(MESSAGE_FAREWELL, "Bye!")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Come back, help me.")
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
tested and functional ok, but I liked this NPC more... I'm sure I'll use it on my server...

LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local talkState = {}


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 missions = {
    [1] = {
        items = {
            {id = 2413, count = 1} -- broad sword
        },
        message = "Now bring me a broad sword.",
        level = 20,
        rewardexp = 20000
    },
    [2] = {
        items = {
            {id = 2430, count = 1} -- knight axe
        },
        message = "Thank you! Now bring me a knight axe.",
        level = 30,
        rewardexp = 50000
    },
    [3] = {
        items = {
            {id = 3961, count = 1} -- lich staff
        },
        message = "Awesome, bring me a lich staff.",
        level = 40,
        rewardexp = 70000
    },
    [4] = {
        items = {
            {id = 2438, count = 1} -- epee
        },
        message = "Thanks, now bring me an epee.",
        level = 60,
        rewardexp = 90000
    },
    [5] = {
        items = {
            {id = 7427, count = 1} -- chaos mace
        },
        message = "Awesome, now bring me a chaos mace.",
        level = 80,
        rewardexp = 150000
    },
    [6] = {
        items = {
            {id = 2414, count = 1} -- dragon lance
        },
        message = "Extra, bring me a dragon lance.",
        level = 100,
        rewardexp = 200000
    },
    [7] = {
        items = {
            {id = 2393, count = 1} -- giant sword
        },
        message = "Great, now bring me a giant sword.",
        level = 110,
        rewardexp = 230000
    },
    [8] = {
        items = {
            {id = 2454, count = 1} -- war axe
        },
        message = "Awesome! Bring me a war axe.",
        level = 120,
        rewardexp = 250000
    },
    [9] = {
        items = {
            {id = 2452, count = 1} -- heavy mace
        },
        message = "Nice! This is the last mission from me. I will upgrade your weapons if you bring me a heavy mace.",
        level = 150,
        rewarditem = {id = 8717, count = 5},
        rewardexp = 350000
    }
}

local storage = 45552


local itemInfo = {
    [2413] = {name = "broad sword", plural = "broad swords"},
    [2430] = {name = "knight axe", plural = "knight axes"},
    [3961] = {name = "lich staff", plural = "lich staffs"},
    [2438] = {name = "epee", plural = "epees"},
    [7427] = {name = "chaos mace", plural = "chaos maces"},
    [2414] = {name = "dragon lance", plural = "dragon lances"},
    [2393] = {name = "giant sword", plural = "giant swords"},
    [2454] = {name = "war axe", plural = "war axes"},
    [2452] = {name = "heavy mace", plural = "heavy maces"},
}

local function getItemName(id, count)
    local info = itemInfo[id]
    if info then
        return count > 1 and info.plural or info.name
    else
        return "unknown item"
    end
end

local function getItemsFromTable(itemtable)
    local text = ""
    for v = 1, #itemtable do
        local count, itemName = itemtable[v].count, getItemName(itemtable[v].id, itemtable[v].count)
        local ret = ", "
        if v == 1 then
            ret = ""
        elseif v == #itemtable then
            ret = " and "
        end
        text = text .. ret
        text = text .. (count > 1 and count .. " " .. itemName or itemName)
    end
    return text
end


function creatureSayCallback(cid, type, msg)
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

    if msgcontains(msg, 'upgradable bags') then
        selfSay('Do you want to give me {50 demonic essence} for 1 upgradable bag?', cid)
        talkState[talkUser] = 10
    elseif msgcontains(msg, 'yes') and talkState[talkUser] == 10 then
        if getPlayerStorageValue(cid, storage) >= 9 then
            if getPlayerItemCount(cid, 6500) >= 50 then
                if doPlayerRemoveItem(cid, 6500, 50) then
                    doPlayerAddItem(cid, 8717, 1)
                    selfSay('Here you are. Good luck with the upgrade!', cid)
                else
                    selfSay('Sorry, you haven\'t completed the weapons missions.', cid)
                end
            else
                selfSay('Sorry, you don\'t have {50 demonic essence} to exchange.', cid)
            end
        else
            selfSay('Sorry, you haven\'t completed the weapons missions.', cid)
        end

        talkState[talkUser] = 0
    elseif msgcontains(msg, 'no') and talkState[talkUser] == 10 then
        talkState[talkUser] = 0
        selfSay('Ok then.', cid)
    end

    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
    local xstorage = getPlayerStorageValue(cid, storage)
    local x = missions[xstorage]

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

    if msgcontains(msg, 'help') then
        if xstorage == -1 then
            selfSay("I need a lot of weapons to upgrade. Can you help me? If you complete all missions, I will upgrade your weapons. Say {yes}!", cid)
            talkState[talkUser] = 1
        elseif x then
            if getPlayerLevel(cid) >= x.level then
                selfSay("You brought me these {weapons}? Great! Talk to me {yes}.", cid)
                talkState[talkUser] = 1
            else
                selfSay("You don't have the required level of " .. x.level .. ". Come back later.", cid)
            end
        else
            selfSay("Thanks, but you have already given me all the weapons.", cid)
            npcHandler:releaseFocus(cid)
        end
    elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
        if xstorage == -1 then
            setPlayerStorageValue(cid, storage, 1)
            local x = missions[getPlayerStorageValue(cid, storage)]
            selfSay(x.message .. " {" .. getItemsFromTable(x.items) .. "}.", cid)
        elseif x then
            local amount = 0
            for i = 1, #x.items do
                if getPlayerItemCount(cid, x.items[i].id) >= x.items[i].count then
                    amount = amount + 1
                end
            end
            if amount == #x.items then
                for i = 1, #x.items do
                    doPlayerRemoveItem(cid, x.items[i].id, x.items[i].count)
                end
                if x.rewarditem then
                    local itemName = getItemName(x.rewarditem.id, x.rewarditem.count)
                    doPlayerAddItem(cid, x.rewarditem.id, x.rewarditem.count)
                    selfSay("You received {" .. (x.rewarditem.count > 1 and x.rewarditem.count .. " " .. itemName or itemName) .. "}.", cid)
                end
                if x.rewardexp then
                    doPlayerAddExp(cid, x.rewardexp)
                    selfSay("You received {" .. x.rewardexp .. " experience}.", cid)
                end
                setPlayerStorageValue(cid, storage, xstorage + 1)
                local x = missions[getPlayerStorageValue(cid, storage)]
                if x then
                    selfSay(x.message .. " {" .. getItemsFromTable(x.items) .. "}.", cid)
                else
                    selfSay("Thanks a lot! I can finish the upgrade! Take 3 upgradable bags. Use them on your weapons.", cid)
                end
            else
                local n = 0
                for i = 1, #x.items do
                    if getPlayerItemCount(cid, x.items[i].id) < x.items[i].count then
                        n = n + 1
                    end
                end
                local text = ""
                local c = 0
                for v = 1, #x.items do
                    local count = x.items[v].count - getPlayerItemCount(cid, x.items[v].id)
                    local itemName = getItemName(x.items[v].id, count)
                    if getPlayerItemCount(cid, x.items[v].id) < x.items[v].count then
                        c = c + 1
                        local ret = ", "
                        if c == 1 then
                            ret = ""
                        elseif c == n then
                            ret = " and "
                        end
                        text = text .. ret
                        text = text .. (count > 1 and count .. " " .. itemName or itemName)
                    end
                end
                selfSay("You don't have all the required items, you still need to get {" .. text .. "}.", cid)
            end
        end
        talkState[talkUser] = 0
    elseif msgcontains(msg, 'weapons') and x then
        selfSay("Now I need these weapons: {" .. getItemsFromTable(x.items) .. "}.", cid)
    elseif msgcontains(msg, 'no') and talkState[talkUser] == 1 then
        selfSay("Oh well...", cid)
    end
    return true
end


npcHandler:setMessage(MESSAGE_FAREWELL, "Bye!")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Come back and help me.")
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
😉
 
tested and functional ok, but I liked this NPC more... I'm sure I'll use it on my server...

LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local talkState = {}


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 missions = {
    [1] = {
        items = {
            {id = 2413, count = 1} -- broad sword
        },
        message = "Now bring me a broad sword.",
        level = 20,
        rewardexp = 20000
    },
    [2] = {
        items = {
            {id = 2430, count = 1} -- knight axe
        },
        message = "Thank you! Now bring me a knight axe.",
        level = 30,
        rewardexp = 50000
    },
    [3] = {
        items = {
            {id = 3961, count = 1} -- lich staff
        },
        message = "Awesome, bring me a lich staff.",
        level = 40,
        rewardexp = 70000
    },
    [4] = {
        items = {
            {id = 2438, count = 1} -- epee
        },
        message = "Thanks, now bring me an epee.",
        level = 60,
        rewardexp = 90000
    },
    [5] = {
        items = {
            {id = 7427, count = 1} -- chaos mace
        },
        message = "Awesome, now bring me a chaos mace.",
        level = 80,
        rewardexp = 150000
    },
    [6] = {
        items = {
            {id = 2414, count = 1} -- dragon lance
        },
        message = "Extra, bring me a dragon lance.",
        level = 100,
        rewardexp = 200000
    },
    [7] = {
        items = {
            {id = 2393, count = 1} -- giant sword
        },
        message = "Great, now bring me a giant sword.",
        level = 110,
        rewardexp = 230000
    },
    [8] = {
        items = {
            {id = 2454, count = 1} -- war axe
        },
        message = "Awesome! Bring me a war axe.",
        level = 120,
        rewardexp = 250000
    },
    [9] = {
        items = {
            {id = 2452, count = 1} -- heavy mace
        },
        message = "Nice! This is the last mission from me. I will upgrade your weapons if you bring me a heavy mace.",
        level = 150,
        rewarditem = {id = 8717, count = 5},
        rewardexp = 350000
    }
}

local storage = 45552


local itemInfo = {
    [2413] = {name = "broad sword", plural = "broad swords"},
    [2430] = {name = "knight axe", plural = "knight axes"},
    [3961] = {name = "lich staff", plural = "lich staffs"},
    [2438] = {name = "epee", plural = "epees"},
    [7427] = {name = "chaos mace", plural = "chaos maces"},
    [2414] = {name = "dragon lance", plural = "dragon lances"},
    [2393] = {name = "giant sword", plural = "giant swords"},
    [2454] = {name = "war axe", plural = "war axes"},
    [2452] = {name = "heavy mace", plural = "heavy maces"},
}

local function getItemName(id, count)
    local info = itemInfo[id]
    if info then
        return count > 1 and info.plural or info.name
    else
        return "unknown item"
    end
end

local function getItemsFromTable(itemtable)
    local text = ""
    for v = 1, #itemtable do
        local count, itemName = itemtable[v].count, getItemName(itemtable[v].id, itemtable[v].count)
        local ret = ", "
        if v == 1 then
            ret = ""
        elseif v == #itemtable then
            ret = " and "
        end
        text = text .. ret
        text = text .. (count > 1 and count .. " " .. itemName or itemName)
    end
    return text
end


function creatureSayCallback(cid, type, msg)
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

    if msgcontains(msg, 'upgradable bags') then
        selfSay('Do you want to give me {50 demonic essence} for 1 upgradable bag?', cid)
        talkState[talkUser] = 10
    elseif msgcontains(msg, 'yes') and talkState[talkUser] == 10 then
        if getPlayerStorageValue(cid, storage) >= 9 then
            if getPlayerItemCount(cid, 6500) >= 50 then
                if doPlayerRemoveItem(cid, 6500, 50) then
                    doPlayerAddItem(cid, 8717, 1)
                    selfSay('Here you are. Good luck with the upgrade!', cid)
                else
                    selfSay('Sorry, you haven\'t completed the weapons missions.', cid)
                end
            else
                selfSay('Sorry, you don\'t have {50 demonic essence} to exchange.', cid)
            end
        else
            selfSay('Sorry, you haven\'t completed the weapons missions.', cid)
        end

        talkState[talkUser] = 0
    elseif msgcontains(msg, 'no') and talkState[talkUser] == 10 then
        talkState[talkUser] = 0
        selfSay('Ok then.', cid)
    end

    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
    local xstorage = getPlayerStorageValue(cid, storage)
    local x = missions[xstorage]

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

    if msgcontains(msg, 'help') then
        if xstorage == -1 then
            selfSay("I need a lot of weapons to upgrade. Can you help me? If you complete all missions, I will upgrade your weapons. Say {yes}!", cid)
            talkState[talkUser] = 1
        elseif x then
            if getPlayerLevel(cid) >= x.level then
                selfSay("You brought me these {weapons}? Great! Talk to me {yes}.", cid)
                talkState[talkUser] = 1
            else
                selfSay("You don't have the required level of " .. x.level .. ". Come back later.", cid)
            end
        else
            selfSay("Thanks, but you have already given me all the weapons.", cid)
            npcHandler:releaseFocus(cid)
        end
    elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
        if xstorage == -1 then
            setPlayerStorageValue(cid, storage, 1)
            local x = missions[getPlayerStorageValue(cid, storage)]
            selfSay(x.message .. " {" .. getItemsFromTable(x.items) .. "}.", cid)
        elseif x then
            local amount = 0
            for i = 1, #x.items do
                if getPlayerItemCount(cid, x.items[i].id) >= x.items[i].count then
                    amount = amount + 1
                end
            end
            if amount == #x.items then
                for i = 1, #x.items do
                    doPlayerRemoveItem(cid, x.items[i].id, x.items[i].count)
                end
                if x.rewarditem then
                    local itemName = getItemName(x.rewarditem.id, x.rewarditem.count)
                    doPlayerAddItem(cid, x.rewarditem.id, x.rewarditem.count)
                    selfSay("You received {" .. (x.rewarditem.count > 1 and x.rewarditem.count .. " " .. itemName or itemName) .. "}.", cid)
                end
                if x.rewardexp then
                    doPlayerAddExp(cid, x.rewardexp)
                    selfSay("You received {" .. x.rewardexp .. " experience}.", cid)
                end
                setPlayerStorageValue(cid, storage, xstorage + 1)
                local x = missions[getPlayerStorageValue(cid, storage)]
                if x then
                    selfSay(x.message .. " {" .. getItemsFromTable(x.items) .. "}.", cid)
                else
                    selfSay("Thanks a lot! I can finish the upgrade! Take 3 upgradable bags. Use them on your weapons.", cid)
                end
            else
                local n = 0
                for i = 1, #x.items do
                    if getPlayerItemCount(cid, x.items[i].id) < x.items[i].count then
                        n = n + 1
                    end
                end
                local text = ""
                local c = 0
                for v = 1, #x.items do
                    local count = x.items[v].count - getPlayerItemCount(cid, x.items[v].id)
                    local itemName = getItemName(x.items[v].id, count)
                    if getPlayerItemCount(cid, x.items[v].id) < x.items[v].count then
                        c = c + 1
                        local ret = ", "
                        if c == 1 then
                            ret = ""
                        elseif c == n then
                            ret = " and "
                        end
                        text = text .. ret
                        text = text .. (count > 1 and count .. " " .. itemName or itemName)
                    end
                end
                selfSay("You don't have all the required items, you still need to get {" .. text .. "}.", cid)
            end
        end
        talkState[talkUser] = 0
    elseif msgcontains(msg, 'weapons') and x then
        selfSay("Now I need these weapons: {" .. getItemsFromTable(x.items) .. "}.", cid)
    elseif msgcontains(msg, 'no') and talkState[talkUser] == 1 then
        selfSay("Oh well...", cid)
    end
    return true
end


npcHandler:setMessage(MESSAGE_FAREWELL, "Bye!")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Come back and help me.")
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
😉
Is it possible to do item rewards will come to store inbox?
 
Is it possible to do item rewards will come to store inbox?
that code includes < 1.x functions, better to rewrite it using classes.

Either way, just create a Player class via cid
LUA:
local player = Player(cid)
Construct the inbox:
LUA:
local inbox = player:getInbox()
Then just call addItem on the inbox container (instead of doPlayerAddItem()):
LUA:
if inbox then
    inbox:addItem(blah..)
    --or inbox:addItemEx(item)
end
 
Last edited by a moderator:

Similar threads

Back
Top