Zinc
New Member
NVM it's fixed.
Last edited:
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(cid ~= npcHandler.focus) then
return false
end
local addon = parameters.addon
local cost = parameters.cost
local premium = (parameters.premium ~= nil and parameters.premium ~= false)
if isPlayerPremiumCallback == nil or isPlayerPremiumCallback(cid) == true or premium == false then
if doPlayerRemoveMoney(cid, cost) == TRUE 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 5000 gold coins?'})
node1:addChildKeyword({'yes'}, buyAddons, {addon = 1, cost = 5000, 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 10000 gold coins?'})
node2:addChildKeyword({'yes'}, buyAddons, {addon = 2, cost = 10000, 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 5000 gold coins and the second addons set for 10000 gold coins.'})
npcHandler:addModule(FocusModule:new())
[18/08/2008 15:26:13] [Warning - NpcScript::NpcScript] Can not load script: data/npc/scripts/addons.lua
[18/08/2008 15:26:13] data/npc/scripts/addons.lua:35: ')' expected near '='
use rl tibia addon system instead
15:51 CM Zincs [1002]: hi
15:51 Varkhal: Welcome, CM Zincs! I have been expecting you.
15:51 CM Zincs [1002]: addon
15:51 Varkhal: I sell the first addons set for 5000 gold coins and the second addons set for 10000 gold coins.
15:51 CM Zincs [1002]: first addon
15:51 Varkhal: Do you want to buy the first addons set for 5000 gold coins?
15:51 CM Zincs [1002]: yes
15:51 CM Zincs [1002]: <nothing happening>
15:51 Varkhal: Too expensive, eh?
15:51 CM Zincs [1002]: second addon
15:51 Varkhal: Would you like to buy the second addons set for 10000 gold coins?
15:51 CM Zincs [1002]: yes
15:51 CM Zincs [1002]: bye
15:51 Varkhal: Good bye, CM Zincs!
Wait... Im working on the error...
What version of TFS are you using?
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
-- OTServ event handling functions start
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
-- OTServ event handling functions end
function creatureSayCallback(cid, type, msg)
if(npcHandler.focus ~= cid) then
return false
end
addon_need_premium = 'Sorry, you need a premium account to get addons.'
addon_have_already = 'Sorry, you already have this addons.'
addon_give = 'Here you are.'
player_gold = getPlayerItemCount(cid,2148)
player_plat = getPlayerItemCount(cid,2152)*100
player_crys = getPlayerItemCount(cid,2160)*10000
player_money = player_gold + player_plat + player_crys
if msgcontains(msg, 'addons') then
selfSay('I can give you your first first addons and second addons.')
elseif msgcontains(msg, 'help') then
selfSay('To buy the first addon say 'first addon', for the second addon say 'second addon'.')
elseif msgcontains(msg, 'first addon') then
if isPremium(cid) then
selfSay('Do you want to pay 5k for the first addons?')
talk_state = 1
end
else
selfSay(addon_need_premium)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 1 then
talk_state = 0
addon = getPlayerStorageValue(cid,10001)
if addon == -1 then
selfSay(addon_give)
doPlayerAddOutfit(cid, 273, 1)
doPlayerAddOutfit(cid, 270, 1)
doPlayerAddOutfit(cid, 128, 1)
doPlayerAddOutfit(cid, 136, 1)
doPlayerAddOutfit(cid, 129, 1)
doPlayerAddOutfit(cid, 137, 2)
doPlayerAddOutfit(cid, 131, 1)
doPlayerAddOutfit(cid, 139, 1)
doPlayerAddOutfit(cid, 141, 1)
doPlayerAddOutfit(cid, 130, 1)
doPlayerAddOutfit(cid, 133, 1)
doPlayerAddOutfit(cid, 138, 2)
doPlayerAddOutfit(cid, 143, 2)
doPlayerAddOutfit(cid, 147, 2)
doPlayerAddOutfit(cid, 144, 1)
doPlayerAddOutfit(cid, 148, 1)
doPlayerAddOutfit(cid, 132, 1)
doPlayerAddOutfit(cid, 140, 1)
doPlayerAddOutfit(cid, 146, 1)
doPlayerAddOutfit(cid, 150, 1)
doPlayerAddOutfit(cid, 134, 1)
doPlayerAddOutfit(cid, 142, 1)
doPlayerAddOutfit(cid, 145, 2)
doPlayerAddOutfit(cid, 149, 2)
doPlayerAddOutfit(cid, 152, 1)
doPlayerAddOutfit(cid, 156, 1)
doPlayerAddOutfit(cid, 153, 1)
doPlayerAddOutfit(cid, 157, 1)
doPlayerAddOutfit(cid, 151, 1)
doPlayerAddOutfit(cid, 155, 1)
doPlayerAddOutfit(cid, 154, 1)
doPlayerAddOutfit(cid, 158, 1)
doPlayerAddOutfit(cid, 251, 1)
doPlayerAddOutfit(cid, 252, 1)
doPlayerAddOutfit(cid, 278, 1)
doPlayerAddOutfit(cid, 279, 1)
setPlayerStorageValue(cid,10001,1)
end
else
selfSay(addon_have_already)
end
end
elseif msgcontains(msg, 'second addon') then
if isPremium(cid) then
selfSay('Do you want to pay 10k for the second addons?')
talk_state = 2
end
else
selfSay(addon_need_premium)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 2 then
talk_state = 0
addon = getPlayerStorageValue(cid,10002)
if addon == -1 then
selfSay(addon_give)
doPlayerAddOutfit(cid, 273, 2)
doPlayerAddOutfit(cid, 270, 2)
doPlayerAddOutfit(cid, 128, 2)
doPlayerAddOutfit(cid, 136, 2)
doPlayerAddOutfit(cid, 129, 2)
doPlayerAddOutfit(cid, 137, 1)
doPlayerAddOutfit(cid, 131, 2)
doPlayerAddOutfit(cid, 139, 2)
doPlayerAddOutfit(cid, 141, 2)
doPlayerAddOutfit(cid, 130, 2)
doPlayerAddOutfit(cid, 138, 1)
doPlayerAddOutfit(cid, 133, 2)
doPlayerAddOutfit(cid, 143, 1)
doPlayerAddOutfit(cid, 147, 1)
doPlayerAddOutfit(cid, 144, 2)
doPlayerAddOutfit(cid, 148, 2)
doPlayerAddOutfit(cid, 132, 2)
doPlayerAddOutfit(cid, 140, 2)
doPlayerAddOutfit(cid, 146, 2)
doPlayerAddOutfit(cid, 150, 2)
doPlayerAddOutfit(cid, 134, 2)
doPlayerAddOutfit(cid, 142, 2)
doPlayerAddOutfit(cid, 145, 1)
doPlayerAddOutfit(cid, 149, 1)
doPlayerAddOutfit(cid, 152, 2)
doPlayerAddOutfit(cid, 156, 2)
doPlayerAddOutfit(cid, 153, 2)
doPlayerAddOutfit(cid, 157, 2)
doPlayerAddOutfit(cid, 151, 2)
doPlayerAddOutfit(cid, 155, 2)
doPlayerAddOutfit(cid, 154, 2)
doPlayerAddOutfit(cid, 158, 2)
doPlayerAddOutfit(cid, 251, 2)
doPlayerAddOutfit(cid, 252, 2)
doPlayerAddOutfit(cid, 268, 2)
doPlayerAddOutfit(cid, 269, 2)
doPlayerAddOutfit(cid, 278, 2)
doPlayerAddOutfit(cid, 279, 2)
setPlayerStorageValue(cid,10002,1)
end
else
selfSay(addon_have_already)
end
end
elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 2) then
selfSay('Go away then...!')
talk_state = 0
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
[18/08/2008 16:45:24] [Warning - NpcScript::NpcScript] Can not load script: data/npc/scripts/addons.lua
[18/08/2008 16:45:24] data/npc/scripts/addons.lua:28: ')' expected near 'first'
[18/08/2008 16:45:24] Lua Script Error: [Npc interface]
[18/08/2008 16:45:24] (Unknown scriptfile)
[18/08/2008 16:45:24] attempt to call a nil value
[18/08/2008 16:45:24] stack traceback:
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(cid ~= npcHandler.focus) then
return false
end
local addon = parameters.addon
local cost = parameters.cost
local premium = (parameters.premium ~= nil and parameters.premium ~= false)
if isPlayerPremiumCallback == nil or isPlayerPremiumCallback(cid) == true or premium == false then
if doPlayerRemoveMoney(cid, cost) == TRUE 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 5000 gold coins?'})
node1:addChildKeyword({'yes'}, buyAddons, {addon = 1, cost = 5000, 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 10000 gold coins?'})
node2:addChildKeyword({'yes'}, buyAddons, {addon = 2, cost = 10000, 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 5000 gold coins and the second addons set for 10000 gold coins.'})
npcHandler:addModule(FocusModule:new())