• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Mount Seller by Items

president vankk

Web Developer & AuraOT Owner
Joined
Jul 10, 2009
Messages
5,719
Solutions
9
Reaction score
339
Hi, I found this script at OtLand, but itsn't working with TFS 1.2, anyone can please update this? I tryed but I have problem with tables.

PS: With the code below didn't have any erros, nothing.

The main idea of this code would be:
Selling mounts by items, :p

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 AddMount(cid, message, keywords, parameters, node) --by vodka
   if(not npcHandler:isFocused(cid)) then
     return false
   end
     if (isPlayerPremiumCallback == nil or isPlayerPremiumCallback(cid) == true or parameters.premium == false) then
       if(parameters.level ~= nil and getPlayerLevel(cid) < parameters.level) then
         npcHandler:say('You must reach level ' .. parameters.level .. ' to buy this mount.', cid)
       elseif canPlayerRideMount(cid, parameters.mountid) then
         npcHandler:say('you already have this mount!', cid)
       elseif not doRemoveItemsFromList(cid,parameters.items) then
         npcHandler:say('Sorry You need '..getItemsFromList(parameters.items)..' to buy this mount!', cid)
       else
         doPlayerAddMount(cid, parameters.mountid)
         npcHandler:say('Here is your mount!', cid)
         npcHandler:resetNpc()
       end
     else
       npcHandler:say('I can only allow premium players to buy this mount.', cid)
     end
   npcHandler:resetNpc()
   return true
end

local mounts = {
   {"widow queen", items = {{6527,10}}, mountid = 1, level = 10, premium = true},
   {"racing bird", items = {{6527,5}}, mountid = 2, level = 15, premium = true},
   {"war bear", items = {{6527,5}}, mountid = 3, level = 15, premium = true},
   {"black sheep", items = {{6527,7}}, mountid = 4, level = 15, premium = true},
   {"midnight panther", items = {{6527,10}}, mountid = 5, level = 15, premium = true},
   {"draptor", items = {{6527,20}}, mountid = 6, level = 15, premium = true},
   {"titanica", items = {{6527,20}}, mountid = 7, level = 15, premium = true},
   {"tin lizzard", items = {{6527,15}}, mountid = 8, level = 15, premium = true},
   {"blazebringer", items = {{6527,25}}, mountid = 9, level = 15, premium = true},
   {"rapid boar", items = {{6527,15}}, mountid = 10, level = 15, premium = true},
   {"stampor", items = {{6527,30}}, mountid = 11, level = 15, premium = true},
   {"undead cavebear", items = {{6527,30}}, mountid = 12, level = 15, premium = true},
   {"mounts", text = "I sell these mounts: {Widow Queen},{Racing Bird},{War Bear},{Black Sheep},{Midnight Panther},{Draptor},{Titanica},{Tin Lizzard},{Blazebringer},{Rapid Boar},{Stampor},{Undead Cavebear}"}
}
for i = 1, #mounts do local get = mounts if type(get.items) == "table" then
local node = keywordHandler:addKeyword({get[1]}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "You want to buy the mount " .. get[1] .. " for "..getItemsFromList(get.items).." ?"})
node:addChildKeyword({"yes"}, AddMount, {items = get.items,mountid = get.mountid, level = get.level, premium = get.premium})
node:addChildKeyword({"no"}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Ok, then.", reset = true})
else keywordHandler:addKeyword({get[1]}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = get.text}) end end
mounts = nil npcHandler:addModule(FocusModule:new())

Thanks.
 
I'm trying using the script below, but isn't adding the mount ask for items then when you type yes, the script grab the items, but didn't give the mount.

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
npcHandler:setMessage(MESSAGE_GREET, "Hello |PLAYERNAME|. Will you help me? If you do, I'll reward you with nice mounts! Just say {mounts} or {help} if you don't know what to do.")
function playerBuyMountNPC(cid, message, keywords, parameters, node)
  if(not npcHandler:isFocused(cid)) then
  return false
  end
  if (parameters.confirm ~= true) and (parameters.decline ~= true) then
  --  if (getPlayerStorageValue(cid, parameters.storageID) ~= -1) then
  --  npcHandler:say('You already have this mount!', cid)
  --  npcHandler:resetNpc()
  --  return true
  -- end
  local itemsTable = parameters.items
  local items_list = ''
  if table.maxn(itemsTable) > 0 then
  for i = 1, table.maxn(itemsTable) do
  local item = itemsTable[i]
  items_list = items_list .. item[2] .. ' ' .. getItemName(item[1])
  if i ~= table.maxn(itemsTable) then
  items_list = items_list .. ', '
  end
  end
  end
  local text = ''
  if (parameters.cost > 0) and table.maxn(parameters.items) then
  text = items_list .. ' and ' .. parameters.cost .. ' gp'
  elseif (parameters.cost > 0) then
  text = parameters.cost .. ' gp'
  elseif table.maxn(parameters.items) then
  text = items_list
  end
  npcHandler:say('Did you bring me ' .. text .. ' for ' .. keywords[1] .. '?', cid)
  return true
  elseif (parameters.confirm == true) then
  local MountNode = node:getParent()
  local Mountinfo = MountNode:getParameters()
  local items_number = 0
  if table.maxn(Mountinfo.items) > 0 then
  for i = 1, table.maxn(Mountinfo.items) do
  local item = Mountinfo.items[i]
  if (getPlayerItemCount(cid,item[1]) >= item[2]) then
  items_number = items_number + 1
  end
  end
  end
     local player = Player(cid)
     if not player:hasMount(Mountinfo.mount_clientId) then
       if(getPlayerMoney(cid) >= Mountinfo.cost) and (items_number == table.maxn(Mountinfo.items)) then
         doPlayerRemoveMoney(cid, Mountinfo.cost)
         if table.maxn(Mountinfo.items) > 0 then
           for i = 1, table.maxn(Mountinfo.items) do
             local item = Mountinfo.items[i]
             doPlayerRemoveItem(cid,item[1],item[2])
           end
         end
         player:addMount(Mountinfo.mount_clientId)
         print(' '.. Mountinfo.mount_clientId..' opa')
         doPlayerAddMount(cid, Mountinfo.mount_clientId)
         npcHandler:say('Here you are.', cid)
         -- setPlayerStorageValue(cid,Mountinfo.storageID,1)
       else
         npcHandler:say('You do not have needed items or cash!', cid)
       end
     else
       npcHandler:say('You already have this mount!', cid)
     end
       npcHandler:resetNpc()
  return true
  elseif (parameters.decline == true) then
  npcHandler:say('Not interested? Maybe other mount?', cid)
  npcHandler:resetNpc()
  return true
  end
  return false
end
local noNode = KeywordNode:new({'no'}, playerBuyMountNPC, {decline = true})
local yesNode = KeywordNode:new({'yes'}, playerBuyMountNPC, {confirm = true})
local mount_node = keywordHandler:addKeyword({'widow queen'}, playerBuyMountNPC, {premium = false, cost = 0, items = {{5878,100}}, mount_clientId = 368, storageID = 11512})
  mount_node:addChildKeywordNode(yesNode)
  mount_node:addChildKeywordNode(noNode)

local mount_node = keywordHandler:addKeyword({'racing bird'}, playerBuyMountNPC, {premium = false, cost = 0, items = {{5890,100}, {5902,50}, {2480,1}}, mount_clientId = 369, storageID = 11513})
  mount_node:addChildKeywordNode(yesNode)
  mount_node:addChildKeywordNode(noNode)
local mount_node = keywordHandler:addKeyword({'war bear'}, playerBuyMountNPC, {premium = false, cost = 0, items = {{5947,1}, {5876,100}, {5948,100}, {5891,5}, {5887,1}, {5889,1}, {5888,1}}, mount_clientId = 370, storageID = 11003})
  mount_node:addChildKeywordNode(yesNode)
  mount_node:addChildKeywordNode(noNode)
   
local mount_node = keywordHandler:addKeyword({'black sheep'}, playerBuyMountNPC, {premium = false, cost = 0, items = {{5875,1}}, mount_clientId = 371, storageID = 11514})
  mount_node:addChildKeywordNode(yesNode)
  mount_node:addChildKeywordNode(noNode)
   
local mount_node = keywordHandler:addKeyword({'tin lizzard'}, playerBuyMountNPC, {premium = false, cost = 0, items = {{5903,1}}, mount_clientId = 375, storageID = 11515})
mount_node:addChildKeywordNode(yesNode)
mount_node:addChildKeywordNode(noNode)
local mount_node = keywordHandler:addKeyword({'stampor'}, playerBuyMountNPC, {premium = false, cost = 0, items = {{5884,1}, {5885,1}, {5910,50}, {5911,50}, {5886,10}}, mount_clientId = 378, storageID = 11516})
  mount_node:addChildKeywordNode(yesNode)
  mount_node:addChildKeywordNode(noNode)
local mount_node = keywordHandler:addKeyword({'donkey'}, playerBuyMountNPC, {premium = false, cost = 0, items = {{5896,50}, {5897,50}}, mount_clientId = 387, storageID = 11517})
  mount_node:addChildKeywordNode(yesNode)
  mount_node:addChildKeywordNode(noNode)
   
local mount_node = keywordHandler:addKeyword({'tiger slug'}, playerBuyMountNPC, {premium = false, cost = 0, items = {{5906,100}, {5940,1}}, mount_clientId = 388, storageID = 11518})
  mount_node:addChildKeywordNode(yesNode)
  mount_node:addChildKeywordNode(noNode)
local mount_node = keywordHandler:addKeyword({'uniwheel mount'}, playerBuyMountNPC, {premium = false, cost = 150000, items = {}, mount_clientId = 389, storageID = 11519})
  mount_node:addChildKeywordNode(yesNode)
  mount_node:addChildKeywordNode(noNode)

local mount_node = keywordHandler:addKeyword({'war horse'}, playerBuyMountNPC, {premium = false, cost = 50000, items = {{5945,1}}, mount_clientId = 392, storageID = 11520})
  mount_node:addChildKeywordNode(yesNode)
  mount_node:addChildKeywordNode(noNode)
   
local mount_node = keywordHandler:addKeyword({'kingly deer'}, playerBuyMountNPC, {premium = false, cost = 0, items = {{11423,1}}, mount_clientId = 401, storageID = 11521})
  mount_node:addChildKeywordNode(yesNode)
  mount_node:addChildKeywordNode(noNode)
local mount_node = keywordHandler:addKeyword({'tamed panda'}, playerBuyMountNPC, {premium = false, cost = 0, items = {{5925,100}, {5899,100}, {5884,1}, {5919,1}}, mount_clientId = 402, storageID = 11522})
  mount_node:addChildKeywordNode(yesNode)
  mount_node:addChildKeywordNode(noNode)
   
local mount_node = keywordHandler:addKeyword({'dromedary'}, playerBuyMountNPC, {premium = false, cost = 0, items = {{5880,100}, {5887,1}}, mount_clientId = 405, storageID = 11523})
  mount_node:addChildKeywordNode(yesNode)
  mount_node:addChildKeywordNode(noNode)
local mount_node = keywordHandler:addKeyword({'ladybug'}, playerBuyMountNPC, {premium = false, cost = 0, items = {{6098,100}, {6126,100}, {6097,100}}, mount_clientId = 447, storageID = 11524})
  mount_node:addChildKeywordNode(yesNode)
  mount_node:addChildKeywordNode(noNode)
   
local mount_node = keywordHandler:addKeyword({'manta'}, playerBuyMountNPC, {premium = false, cost = 0, items = {{6101,1}, {6102,1}, {6100,1}, {6099,1}}, mount_clientId = 450, storageID = 11525})
  mount_node:addChildKeywordNode(yesNode)
  mount_node:addChildKeywordNode(noNode)
local mount_node = keywordHandler:addKeyword({'ironblight'}, playerBuyMountNPC, {premium = false, cost = 0, items = {{5810,5}, {2322,5}, {5015,1}}, mount_clientId = 502, storageID = 11526})
  mount_node:addChildKeywordNode(yesNode)
  mount_node:addChildKeywordNode(noNode)
   
local mount_node = keywordHandler:addKeyword({'magma crawler'}, playerBuyMountNPC, {premium = false, cost = 0, items = {{3966,5}, {3967,5}}, mount_clientId = 503, storageID = 11527})
  mount_node:addChildKeywordNode(yesNode)
  mount_node:addChildKeywordNode(noNode)
keywordHandler:addKeyword({'mounts'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can give you {widow queen}, {racing bird}, {war bear}, {black sheep}, {tin lizzard}, {stampor}, {donkey}, {tiger slug}, {uniwheel}, {war horse}, {kingly deer}, {tamed panda}, {dromedary}, {ladybug}, {manta}, {ironblight}, {magma crawler}.'})
keywordHandler:addKeyword({'help'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'To buy mount say \'mount\','})
npcHandler:addModule(FocusModule:new())
 
Last edited:
It does "give" mount, but you're using incorrect values. You are passing clientId instead of mountId to Player.addMount.
 
Back
Top