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

Help Npc System 0.4

wesleyt10

Well-Known Member
Joined
Dec 15, 2012
Messages
73
Reaction score
71
Hello ! how are you? I hope well! I would like your help, I have a problem, when adding the following id 2006 in the script of my npc, Xodet.lua - id (Vial) he needs me to specify what type of fluid will be in the content of the vial, however I am trying sell manafluid and lifefluid, in this case the error is as follows, he only accepts 1 of the registered IDs, either mana or life! would someone help me put both? or would you tell me how?
otland.png
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 shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

shopModule:addBuyableItem({'spellbook'}, 2175, 150, 1, 'spellbook')
shopModule:addBuyableItem({'vial of blood'}, 2006, 50, 2, 'life fluid')

shopModule:addSellableItem({'wand of vortex', 'vortex'}, 2190, 250, 'wand of vortex')
shopModule:addSellableItem({'wand of dragonbreath', 'dragonbreath'}, 2191, 500, 'wand of dragonbreath')
shopModule:addSellableItem({'wand of decay', 'decay'}, 2188, 2500, 'wand of decay')
shopModule:addSellableItem({'wand of cosmic energy', 'cosmic energy'}, 2189, 5000, 'wand of cosmic energy')
shopModule:addSellableItem({'wand of inferno', 'inferno'},2187, 7500, 'wand of inferno')

shopModule:addSellableItem({'snakebite rod', 'snakebite'}, 2182, 250,'snakebite rod')
shopModule:addSellableItem({'moonlight rod', 'moonlight'}, 2186, 500,   'moonlight rod')
shopModule:addSellableItem({'necrotic rod', 'necrotic'}, 2185, 2500, 'necrotic rod')
shopModule:addSellableItem({'terra rod', 'terra'}, 2181, 5000, 'terra rod')
shopModule:addSellableItem({'hailstorm rod', 'hailstorm'}, 2183, 7500, 'hailstorm rod')

shopModule:addBuyableItem({'fire bomb'}, 2305, 117, 1, 'fire bomb')
shopModule:addBuyableItem({'destroy field'}, 2261, 15, 1, 'destroy field rune')
shopModule:addBuyableItem({'light magic missile'}, 2287, 4, 1, 'light magic missile rune')
shopModule:addBuyableItem({'heavy magic missile'}, 2311, 12, 1, 'heavy magic missile rune')
shopModule:addBuyableItem({'great fireball'}, 2304, 45, 1, 'great fireball rune')

shopModule:addBuyableItem({'convince creature'}, 2290, 80, 1, 'convince creature rune')
shopModule:addBuyableItem({'chameleon'}, 2291, 210, 1, 'chameleon rune')
shopModule:addBuyableItem({'desintegrate'}, 2310, 80,  1, 'desintegreate rune')
shopModule:addBuyableItem({'fire field'}, 2301, 28,  1, 'fire field rune')
shopModule:addBuyableItem({'fire wall'}, 2303, 61,  1, 'fire wall rune')
shopModule:addBuyableItem({'fire field'}, 2301, 38,  1, 'fire field rune')
shopModule:addBuyableItem({'antidote rune'}, 2266, 65,  1, 'antidote rune')
shopModule:addBuyableItem({'energy wall'}, 2279, 85,  1, 'energy wall rune')
shopModule:addBuyableItem({'fire ball'}, 2302, 30,  1, 'fire ball rune')
shopModule:addBuyableItem({'poison field'}, 2285, 21,  1, 'poison field rune')
shopModule:addBuyableItem({'poison wall'}, 2289, 52,  1, 'poison wall rune')
shopModule:addBuyableItem({'magic wall'}, 2293, 52,  1, 'magic wall rune')
shopModule:addBuyableItem({'wild growth rune'}, 2269, 52,  1, 'wild growth rune')
shopModule:addBuyableItem({'blank'}, 2260, 10,  1, 'blank rune')

shopModule:addBuyableItem({'vial of manafluid'}, 2006, 45, 7, 'mana fluid')
shopModule:addBuyableItem({'wand of dragonbreath', 'dragonbreath'}, 2191, 1000, 1, 'wand of dragonbreath')
shopModule:addBuyableItem({'wand of decay', 'decay'}, 2188, 5000, 1, 'wand of decay')
shopModule:addBuyableItem({'wand of cosmic energy', 'cosmic energy'}, 2189, 10000, 1, 'wand of cosmic energy')
shopModule:addBuyableItem({'wand of inferno', 'inferno'}, 2187, 15000, 1, 'wand of inferno')

shopModule:addBuyableItem({'snakebite rod', 'snakebite'}, 2182, 500, 1, 'snakebite rod')
shopModule:addBuyableItem({'moonlight rod', 'moonlight'}, 2186, 1000, 1, 'moonlight rod')
shopModule:addBuyableItem({'necrotic rod', 'necrotic'}, 2185, 5000, 1, 'necrotic rod')
shopModule:addBuyableItem({'terra rod', 'terra'}, 2181, 10000, 1, 'terra rod')
shopModule:addBuyableItem({'hailstorm rod', 'hailstorm'}, 2183, 15000, 1, 'hailstorm rod')


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

    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
    local items = {[1] = 2190, [2] = 2182, [5] = 2190, [6] = 2182}

    if(msgcontains(msg, 'first rod') or msgcontains(msg, 'first wand')) then
        if(isSorcerer(cid) or isDruid(cid)) then
            if(getPlayerStorageValue(cid, 30002) == -1) then
                selfSay('So you ask me for a {' .. getItemNameById(items[getPlayerVocation(cid)]) .. '} to begin your advanture?', cid)
                talkState[talkUser] = 1
            else
                selfSay('What? I have already gave you one {' .. getItemNameById(items[getPlayerVocation(cid)]) .. '}!', cid)
            end
        else
            selfSay('Sorry, you aren\'t a druid either a sorcerer.', cid)
        end
    elseif(msgcontains(msg, 'yes')) then
        if(talkState[talkUser] == 1) then
            doPlayerAddItem(cid, items[getPlayerVocation(cid)], 1)
            selfSay('Here you are young adept, take care yourself.', cid)
            setPlayerStorageValue(cid, 30002, 1)
        end
        talkState[talkUser] = 0
    elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
        selfSay('Ok then.', cid)
        talkState[talkUser] = 0
    end

    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Not sure what you're doing wrong, maybe its how you named them. So here you go these are the lines I use:
Lua:
shopModule:addBuyableItem({'lifefluid'}, 2006, 45, 10, 'vial of lifefluid')
shopModule:addBuyableItem({'manafluid'}, 2006, 50, 7, 'vial of manafluid')

Sincerely,
Ralumbi(Caleb)
 
Feel free to try my old tfs 0.4 module.lua
Module.lua
this error

[Error - NpcScript Interface]
data/npc/scripts/The Dream Master.lua
Description:
data/npc/lib/npcsystem/modules.lua:934: attempt to call global 'ItemType' (a nil value)
[Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scripts/The Dream Master.lua


ALL NPCS HAS BUG
my source is otx 2 based on tfs 0.4 :D
 
It was just a question if mine would work. I cannot believe it shouldn't work in first place.
You should reverse back to your own Module.lua

The edits I made now would be my final clue>
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 shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

shopModule:addBuyableItem({'mana fluid', 'manafluid'}, 2006, 100, 7,     'mana fluid')
shopModule:addBuyableItem({'life fluid', 'lifefluid'}, 2006, 80, 10,    'life fluid')

shopModule:addBuyableItem({'spellbook'}, 2175, 150, 1, 'spellbook')
shopModule:addSellableItem({'wand of vortex', 'vortex'}, 2190, 250, 'wand of vortex')
shopModule:addSellableItem({'wand of dragonbreath', 'dragonbreath'}, 2191, 500, 'wand of dragonbreath')
shopModule:addSellableItem({'wand of decay', 'decay'}, 2188, 2500, 'wand of decay')
shopModule:addSellableItem({'wand of cosmic energy', 'cosmic energy'}, 2189, 5000, 'wand of cosmic energy')
shopModule:addSellableItem({'wand of inferno', 'inferno'},2187, 7500, 'wand of inferno')

shopModule:addSellableItem({'snakebite rod', 'snakebite'}, 2182, 250,'snakebite rod')
shopModule:addSellableItem({'moonlight rod', 'moonlight'}, 2186, 500,   'moonlight rod')
shopModule:addSellableItem({'necrotic rod', 'necrotic'}, 2185, 2500, 'necrotic rod')
shopModule:addSellableItem({'terra rod', 'terra'}, 2181, 5000, 'terra rod')
shopModule:addSellableItem({'hailstorm rod', 'hailstorm'}, 2183, 7500, 'hailstorm rod')

shopModule:addBuyableItem({'fire bomb'}, 2305, 117, 1, 'fire bomb')
shopModule:addBuyableItem({'destroy field'}, 2261, 15, 1, 'destroy field rune')
shopModule:addBuyableItem({'light magic missile'}, 2287, 4, 1, 'light magic missile rune')
shopModule:addBuyableItem({'heavy magic missile'}, 2311, 12, 1, 'heavy magic missile rune')
shopModule:addBuyableItem({'great fireball'}, 2304, 45, 1, 'great fireball rune')

shopModule:addBuyableItem({'convince creature'}, 2290, 80, 1, 'convince creature rune')
shopModule:addBuyableItem({'chameleon'}, 2291, 210, 1, 'chameleon rune')
shopModule:addBuyableItem({'desintegrate'}, 2310, 80,  1, 'desintegreate rune')
shopModule:addBuyableItem({'fire field'}, 2301, 28,  1, 'fire field rune')
shopModule:addBuyableItem({'fire wall'}, 2303, 61,  1, 'fire wall rune')
shopModule:addBuyableItem({'fire field'}, 2301, 38,  1, 'fire field rune')
shopModule:addBuyableItem({'antidote rune'}, 2266, 65,  1, 'antidote rune')
shopModule:addBuyableItem({'energy wall'}, 2279, 85,  1, 'energy wall rune')
shopModule:addBuyableItem({'fire ball'}, 2302, 30,  1, 'fire ball rune')
shopModule:addBuyableItem({'poison field'}, 2285, 21,  1, 'poison field rune')
shopModule:addBuyableItem({'poison wall'}, 2289, 52,  1, 'poison wall rune')
shopModule:addBuyableItem({'magic wall'}, 2293, 52,  1, 'magic wall rune')
shopModule:addBuyableItem({'wild growth rune'}, 2269, 52,  1, 'wild growth rune')
shopModule:addBuyableItem({'blank'}, 2260, 10,  1, 'blank rune')

shopModule:addBuyableItem({'wand of dragonbreath', 'dragonbreath'}, 2191, 1000, 1, 'wand of dragonbreath')
shopModule:addBuyableItem({'wand of decay', 'decay'}, 2188, 5000, 1, 'wand of decay')
shopModule:addBuyableItem({'wand of cosmic energy', 'cosmic energy'}, 2189, 10000, 1, 'wand of cosmic energy')
shopModule:addBuyableItem({'wand of inferno', 'inferno'}, 2187, 15000, 1, 'wand of inferno')

shopModule:addBuyableItem({'snakebite rod', 'snakebite'}, 2182, 500, 1, 'snakebite rod')
shopModule:addBuyableItem({'moonlight rod', 'moonlight'}, 2186, 1000, 1, 'moonlight rod')
shopModule:addBuyableItem({'necrotic rod', 'necrotic'}, 2185, 5000, 1, 'necrotic rod')
shopModule:addBuyableItem({'terra rod', 'terra'}, 2181, 10000, 1, 'terra rod')
shopModule:addBuyableItem({'hailstorm rod', 'hailstorm'}, 2183, 15000, 1, 'hailstorm rod')


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

    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
    local items = {[1] = 2190, [2] = 2182, [5] = 2190, [6] = 2182}

    if(msgcontains(msg, 'first rod') or msgcontains(msg, 'first wand')) then
        if(isSorcerer(cid) or isDruid(cid)) then
            if(getPlayerStorageValue(cid, 30002) == -1) then
                selfSay('So you ask me for a {' .. getItemNameById(items[getPlayerVocation(cid)]) .. '} to begin your advanture?', cid)
                talkState[talkUser] = 1
            else
                selfSay('What? I have already gave you one {' .. getItemNameById(items[getPlayerVocation(cid)]) .. '}!', cid)
            end
        else
            selfSay('Sorry, you aren\'t a druid either a sorcerer.', cid)
        end
    elseif(msgcontains(msg, 'yes')) then
        if(talkState[talkUser] == 1) then
            doPlayerAddItem(cid, items[getPlayerVocation(cid)], 1)
            selfSay('Here you are young adept, take care yourself.', cid)
            setPlayerStorageValue(cid, 30002, 1)
        end
        talkState[talkUser] = 0
    elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
        selfSay('Ok then.', cid)
        talkState[talkUser] = 0
    end

    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
all nps has this bug
It was just a question if mine would work. I cannot believe it shouldn't work in first place.
You should reverse back to your own Module.lua

The edits I made now would be my final clue>
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 shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

shopModule:addBuyableItem({'mana fluid', 'manafluid'}, 2006, 100, 7,     'mana fluid')
shopModule:addBuyableItem({'life fluid', 'lifefluid'}, 2006, 80, 10,    'life fluid')

shopModule:addBuyableItem({'spellbook'}, 2175, 150, 1, 'spellbook')
shopModule:addSellableItem({'wand of vortex', 'vortex'}, 2190, 250, 'wand of vortex')
shopModule:addSellableItem({'wand of dragonbreath', 'dragonbreath'}, 2191, 500, 'wand of dragonbreath')
shopModule:addSellableItem({'wand of decay', 'decay'}, 2188, 2500, 'wand of decay')
shopModule:addSellableItem({'wand of cosmic energy', 'cosmic energy'}, 2189, 5000, 'wand of cosmic energy')
shopModule:addSellableItem({'wand of inferno', 'inferno'},2187, 7500, 'wand of inferno')

shopModule:addSellableItem({'snakebite rod', 'snakebite'}, 2182, 250,'snakebite rod')
shopModule:addSellableItem({'moonlight rod', 'moonlight'}, 2186, 500,   'moonlight rod')
shopModule:addSellableItem({'necrotic rod', 'necrotic'}, 2185, 2500, 'necrotic rod')
shopModule:addSellableItem({'terra rod', 'terra'}, 2181, 5000, 'terra rod')
shopModule:addSellableItem({'hailstorm rod', 'hailstorm'}, 2183, 7500, 'hailstorm rod')

shopModule:addBuyableItem({'fire bomb'}, 2305, 117, 1, 'fire bomb')
shopModule:addBuyableItem({'destroy field'}, 2261, 15, 1, 'destroy field rune')
shopModule:addBuyableItem({'light magic missile'}, 2287, 4, 1, 'light magic missile rune')
shopModule:addBuyableItem({'heavy magic missile'}, 2311, 12, 1, 'heavy magic missile rune')
shopModule:addBuyableItem({'great fireball'}, 2304, 45, 1, 'great fireball rune')

shopModule:addBuyableItem({'convince creature'}, 2290, 80, 1, 'convince creature rune')
shopModule:addBuyableItem({'chameleon'}, 2291, 210, 1, 'chameleon rune')
shopModule:addBuyableItem({'desintegrate'}, 2310, 80,  1, 'desintegreate rune')
shopModule:addBuyableItem({'fire field'}, 2301, 28,  1, 'fire field rune')
shopModule:addBuyableItem({'fire wall'}, 2303, 61,  1, 'fire wall rune')
shopModule:addBuyableItem({'fire field'}, 2301, 38,  1, 'fire field rune')
shopModule:addBuyableItem({'antidote rune'}, 2266, 65,  1, 'antidote rune')
shopModule:addBuyableItem({'energy wall'}, 2279, 85,  1, 'energy wall rune')
shopModule:addBuyableItem({'fire ball'}, 2302, 30,  1, 'fire ball rune')
shopModule:addBuyableItem({'poison field'}, 2285, 21,  1, 'poison field rune')
shopModule:addBuyableItem({'poison wall'}, 2289, 52,  1, 'poison wall rune')
shopModule:addBuyableItem({'magic wall'}, 2293, 52,  1, 'magic wall rune')
shopModule:addBuyableItem({'wild growth rune'}, 2269, 52,  1, 'wild growth rune')
shopModule:addBuyableItem({'blank'}, 2260, 10,  1, 'blank rune')

shopModule:addBuyableItem({'wand of dragonbreath', 'dragonbreath'}, 2191, 1000, 1, 'wand of dragonbreath')
shopModule:addBuyableItem({'wand of decay', 'decay'}, 2188, 5000, 1, 'wand of decay')
shopModule:addBuyableItem({'wand of cosmic energy', 'cosmic energy'}, 2189, 10000, 1, 'wand of cosmic energy')
shopModule:addBuyableItem({'wand of inferno', 'inferno'}, 2187, 15000, 1, 'wand of inferno')

shopModule:addBuyableItem({'snakebite rod', 'snakebite'}, 2182, 500, 1, 'snakebite rod')
shopModule:addBuyableItem({'moonlight rod', 'moonlight'}, 2186, 1000, 1, 'moonlight rod')
shopModule:addBuyableItem({'necrotic rod', 'necrotic'}, 2185, 5000, 1, 'necrotic rod')
shopModule:addBuyableItem({'terra rod', 'terra'}, 2181, 10000, 1, 'terra rod')
shopModule:addBuyableItem({'hailstorm rod', 'hailstorm'}, 2183, 15000, 1, 'hailstorm rod')


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

    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
    local items = {[1] = 2190, [2] = 2182, [5] = 2190, [6] = 2182}

    if(msgcontains(msg, 'first rod') or msgcontains(msg, 'first wand')) then
        if(isSorcerer(cid) or isDruid(cid)) then
            if(getPlayerStorageValue(cid, 30002) == -1) then
                selfSay('So you ask me for a {' .. getItemNameById(items[getPlayerVocation(cid)]) .. '} to begin your advanture?', cid)
                talkState[talkUser] = 1
            else
                selfSay('What? I have already gave you one {' .. getItemNameById(items[getPlayerVocation(cid)]) .. '}!', cid)
            end
        else
            selfSay('Sorry, you aren\'t a druid either a sorcerer.', cid)
        end
    elseif(msgcontains(msg, 'yes')) then
        if(talkState[talkUser] == 1) then
            doPlayerAddItem(cid, items[getPlayerVocation(cid)], 1)
            selfSay('Here you are young adept, take care yourself.', cid)
            setPlayerStorageValue(cid, 30002, 1)
        end
        talkState[talkUser] = 0
    elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
        selfSay('Ok then.', cid)
        talkState[talkUser] = 0
    end

    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
this script has work for u?
now only lifefluid has work :S
otlands.png
 
Then you should try to find the correct manafluid.
You can do so to do /i 2006, 1, /i 2006, 2, /i 2006, 3, /i 2006, 4, /i 2006, 5 etc.... and see which is the correct number and change that in the script. In this case we used /i 2006, 7 for manafluid.

I hope this will work for you, I am out of idea's. Or I must work with the actual sources. Now just doing help from the head to give you leads and guidance.
 
thanks for the help, I tried all possible fluids, because I believe the problem is in the same IDS, something in the npcsystem prevents the same id from being listed, I have a module that accepts the sale of the 2 items but it does not recognize the function ' itemlist '
 
thanks for the help, I tried all possible fluids, because I believe the problem is in the same IDS, something in the npcsystem prevents the same id from being listed, I have a module that accepts the sale of the 2 items but it does not recognize the function ' itemlist '
You're welcome :), I would suggest if you're using this project to use for an actual live server at some point better going with TFS 1.3 instead. It has was more functions and modules available out of the box. TFS 0.4 is out-dated.

Much coding love,
Ralumbi(Caleb)
 
You're welcome :), I would suggest if you're using this project to use for an actual live server at some point better going with TFS 1.3 instead. It has was more functions and modules available out of the box. TFS 0.4 is out-dated.

Much coding love,
Ralumbi(Caleb)

I don’t understand anything about the new codes, I don’t understand codes, very badly, so I still use 0.4, because there are more codes available.
 
Back
Top