• 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 addons.lua tfs 0.3.6 need help

LuisPro

World War <3
Joined
May 10, 2009
Messages
425
Solutions
1
Reaction score
53
Hello, can someone help me? i buy all first addons for 500k, works well, i buy all second addons for 500k works well, BUT if i again write to npc first addon > yes he again take my 500k ;/ (i need to him answer me "you already got all first addons/second addons") halp me pls :D this my addons.lua:

Code:
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

function buyAddons(cid, message, keywords, parameters, node)
    --TODO: buyAddons function in modules.lua
    if(not npcHandler:isFocused(cid)) then
        return false
    end

    local addon = parameters.addon
    local cost = parameters.cost
    local premium = (parameters.premium ~= nil and parameters.premium)

    if isPlayerPremiumCallback == nil or (isPlayerPremiumCallback(cid) and premium) then
        if doPlayerRemoveMoney(cid, cost) then
            doPlayerAddAddons(cid, addon)
            npcHandler:say('There, you are now able to use all addons!', cid)
        else
            npcHandler:say('Sorry, you do not have enough money.', cid)
        end
    else
        npcHandler:say('I only serve customers with premium accounts.', cid)
    end

    keywordHandler:moveUp(1)
    return true
end

local node1 = keywordHandler:addKeyword({'first addon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the first addons set for 500000 gold coins?'})
    node1:addChildKeyword({'yes'}, buyAddons, {addon = 1, cost = 500000, premium = true})
    node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, moveup = 1, text = 'Too expensive, eh?'})

local node2 = keywordHandler:addKeyword({'second addon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Would you like to buy the second addons set for 500000 gold coins?'})
    node2:addChildKeyword({'yes'}, buyAddons, {addon = 2, cost = 500000, premium = true})
    node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, moveup = 1, text = 'Too expensive, eh?'})

keywordHandler:addKeyword({'addon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I sell the first addons set for 500000 gold coins and the second addons set for 500000 gold coins.'})

npcHandler:addModule(FocusModule:new())
 
try to add this code
Code:
else
npcHandler:say('you already optain your addons.', cid)
end
after
Code:
else
npcHandler:say('I only serve customers with premium accounts.', cid)
end
 
You want him to add this?
Code:
    else
        npcHandler:say('I only serve customers with premium accounts.', cid)
    end
    else
        npcHandler:say('you already optain your addons.', cid)
    end
-.-

Test this, will give a storage value for each addon
Code:
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

function buyAddons(cid, message, keywords, parameters, node)
    --TODO: buyAddons function in modules.lua
    if(not npcHandler:isFocused(cid)) then
        return false
    end

    local addon = parameters.addon
    local cost = parameters.cost
    local premium = (parameters.premium ~= nil and parameters.premium)
    local storage = 1925
  
    if(isPlayerPremiumCallback == nil or (isPlayerPremiumCallback(cid) and premium)) then
        if(getPlayerStorageValue(cid, storage) =~ addon) then
            npcHandler:say('You already have this addon!', cid)
            npcHandler:resetNpc()
            return true
        end
        if(doPlayerRemoveMoney(cid, cost)) then
            doPlayerAddAddons(cid, addon)
            setPlayerStorageValue(cid,storage,addon)
            npcHandler:say('There, you are now able to use all addons!', cid)
        else
            npcHandler:say('Sorry, you do not have enough money.', cid)
        end
    else
        npcHandler:say('I only serve customers with premium accounts.', cid)
    end
    keywordHandler:moveUp(1)
    return true
end

local node1 = keywordHandler:addKeyword({'first addon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the first addons set for 500000 gold coins?'})
    node1:addChildKeyword({'yes'}, buyAddons, {addon = 1, cost = 500000, premium = true})
    node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, moveup = 1, text = 'Too expensive, eh?'})

local node2 = keywordHandler:addKeyword({'second addon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Would you like to buy the second addons set for 500000 gold coins?'})
    node2:addChildKeyword({'yes'}, buyAddons, {addon = 2, cost = 500000, premium = true})
    node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, moveup = 1, text = 'Too expensive, eh?'})

keywordHandler:addKeyword({'addon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I sell the first addons set for 500000 gold coins and the second addons set for 500000 gold coins.'})

npcHandler:addModule(FocusModule:new())

Also, always use if(var) then not if var then
 
[29/11/2013 02:06:33] [Error - LuaScriptInterface::loadFile] data/npc/scripts/addons.lua:22: ')' expected near '='
[29/11/2013 02:06:33] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/addons.lua
[29/11/2013 02:06:33] data/npc/scripts/addons.lua:22: ')' expected near '='
 
Code:
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

function buyAddons(cid, message, keywords, parameters, node)
    --TODO: buyAddons function in modules.lua
    if(not npcHandler:isFocused(cid)) then
        return false
    end

    local addon = parameters.addon
    local cost = parameters.cost
    local premium = (parameters.premium ~= nil and parameters.premium)
    local storage = 1925
    if(isPlayerPremiumCallback == nil or (isPlayerPremiumCallback(cid) and premium)) then
        if(getPlayerStorageValue(cid, storage) == addon) then
            npcHandler:say('You already have this addon!', cid)
            npcHandler:resetNpc()
            return true
        end
        if(doPlayerRemoveMoney(cid, cost)) then
            doPlayerAddAddons(cid, addon)
            setPlayerStorageValue(cid,storage,addon)
            npcHandler:say('There, you are now able to use all addons!', cid)
        else
            npcHandler:say('Sorry, you do not have enough money.', cid)
        end
    else
        npcHandler:say('I only serve customers with premium accounts.', cid)
    end
    keywordHandler:moveUp(1)
    return true
end

local node1 = keywordHandler:addKeyword({'first addon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the first addons set for 500000 gold coins?'})
    node1:addChildKeyword({'yes'}, buyAddons, {addon = 1, cost = 500000, premium = true})
    node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, moveup = 1, text = 'Too expensive, eh?'})

local node2 = keywordHandler:addKeyword({'second addon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Would you like to buy the second addons set for 500000 gold coins?'})
    node2:addChildKeyword({'yes'}, buyAddons, {addon = 2, cost = 500000, premium = true})
    node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, moveup = 1, text = 'Too expensive, eh?'})

keywordHandler:addKeyword({'addon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I sell the first addons set for 500000 gold coins and the second addons set for 500000 gold coins.'})

npcHandler:addModule(FocusModule:new())
 
nothing changed, still take money, and i test also "~=" then works correct but then i cant buy addons in to second character on the same account ;/
 
http://pastebin.com/snbxHtrT

this is Varkhal with addons

this is npc which sells all items :p

Code:
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)
--citizen addon
shopModule:addBuyableItem({'Minotaur leather'}, 5878, 100)
shopModule:addBuyableItem({'Chicken feather'}, 5890, 100)
shopModule:addBuyableItem({'Honeycomb'}, 5902, 300)
shopModule:addBuyableItem({'Legion helmet'}, 2480, 1000)
--hunter addon
shopModule:addBuyableItem({'Sniper gloves'}, 5875, 5000)
shopModule:addBuyableItem({'Enchanted chicken wings'}, 5891, 35000)
shopModule:addBuyableItem({'Piece of royal steel'}, 5887, 15000)
shopModule:addBuyableItem({'Piece of draconian steel'}, 5889, 4000)
shopModule:addBuyableItem({'Piece of hell steal'}, 5888, 1000)
shopModule:addBuyableItem({'Red dragon leather'}, 5948, 1000)
shopModule:addBuyableItem({'Lizard leather'}, 5876, 200)
shopModule:addBuyableItem({'Elanes crossbow'}, 5947, 100000)
--mage addon
shopModule:addBuyableItem({'Soul stone'}, 5809, 100000)
shopModule:addBuyableItem({'Ankh'}, 2193, 2000)
shopModule:addBuyableItem({'Ferumbras hat'}, 5903, 10000000)
--knight addon
shopModule:addBuyableItem({'Damaged steel helmet'}, 5924, 5000)
shopModule:addBuyableItem({'Huge chunk of crude iron'}, 5892, 17000)
shopModule:addBuyableItem({'Perfect behemoth fang'}, 5893, 2500)
shopModule:addBuyableItem({'Warrior sweat'}, 5885, 20000)
shopModule:addBuyableItem({'Iron ore'}, 5880, 1000)
--nobleman addon
--Only money
--summoner addon
shopModule:addBuyableItem({'Vampire dust'}, 5905, 3000)
shopModule:addBuyableItem({'Giant spider silk'}, 5879, 8000)
shopModule:addBuyableItem({'Holy orshid'}, 5922, 3000)
shopModule:addBuyableItem({'Ape fur'}, 5883, 500)
shopModule:addBuyableItem({'Red piece of cloth'}, 5911, 3000)
shopModule:addBuyableItem({'Bat wing'}, 5894, 500)
--warrior addon
shopModule:addBuyableItem({'Dragon claw'}, 5919, 700000)
shopModule:addBuyableItem({'Turtle shell'}, 5899, 600)
shopModule:addBuyableItem({'Fighting spirit'}, 5884, 60000)
shopModule:addBuyableItem({'Hardened bones'}, 5925, 1000)
--barbarian addon
shopModule:addBuyableItem({'Green piece of cloth'}, 5910, 1000)
shopModule:addBuyableItem({'Spool of yarn'}, 5886, 70000)
--druid addon
shopModule:addBuyableItem({'Bear Paw'}, 5896, 1000)
shopModule:addBuyableItem({'Wolf Paw'}, 5897, 1000)
shopModule:addBuyableItem({'waterhose'}, 5938, 2000)
shopModule:addBuyableItem({'ceiron wolf tooth chain.'}, 5940, 3000)
shopModule:addBuyableItem({'Demon Dust'}, 5906, 6000)
--wizard addon
shopModule:addBuyableItem({'Holy Orchid'}, 5922, 3500)
--oriental addon
shopModule:addBuyableItem({'Mermaid Comb'}, 5945, 20000)
shopModule:addBuyableItem({'Fish Fin'}, 5895, 3000)
shopModule:addBuyableItem({'Blue Piece of Cloth'}, 5912, 1000)
--pirate addon
shopModule:addBuyableItem({'Eye Patch'}, 6098, 1500)
shopModule:addBuyableItem({'Hook'}, 6097, 1500)
shopModule:addBuyableItem({'Peg leg'}, 6126, 1500)
shopModule:addBuyableItem({'Ron the Ripper sabre'}, 6101, 150000)
shopModule:addBuyableItem({'Lethal Lissy Shirt'}, 6100, 150000)
shopModule:addBuyableItem({'Brutus Bloodbeard hat'}, 6099, 150000)
shopModule:addBuyableItem({'Deadeye Devious Eye Patch'}, 6102, 150000)
--assassin addon
shopModule:addBuyableItem({'White Piece of Cloth'}, 5909, 2000)
shopModule:addBuyableItem({'Red Piece of Cloth'}, 5911, 5000)
shopModule:addBuyableItem({'Brown Piece of Cloth'}, 5913, 1000)
shopModule:addBuyableItem({'Yellow Piece of Cloth'}, 5914, 3000)
shopModule:addBuyableItem({'Green Piece of Cloth'}, 5910, 2000)
shopModule:addBuyableItem({'Behemoth Claw'}, 5930, 4000)
--beggar addon
shopModule:addBuyableItem({'Heaven Blossom'}, 5921, 1300)
shopModule:addBuyableItem({'Simon the beggar favorite staff'}, 6107, 150000)
--shaman addon
shopModule:addBuyableItem({'Mandrake'}, 5015, 400000)
shopModule:addBuyableItem({'Tribal Mask'}, 3967, 6000)
shopModule:addBuyableItem({'Banana Staff'}, 3966, 4000)
shopModule:addBuyableItem({'Voodoo Doll'}, 2322, 10000)
shopModule:addBuyableItem({'Pirate Voodoo Doll'}, 5810, 3000)
--norseman addon
shopModule:addBuyableItem({'Shard'}, 7290, 5000)
--nightmare addon
shopModule:addBuyableItem({'Demonic Essence'}, 6500, 1500)
--jester addon
--Already Sold
--brotherhood addon
--Already Sold
--demonhunter addon
shopModule:addBuyableItem({'Demon Horn'}, 5954, 3500)
shopModule:addBuyableItem({'Talon'}, 2151, 600)
--yalaharian addon
--warmaster addon
--Crystal
--wayfarer addon
--Quest
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Back
Top