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

[7.72] OTHire 0.0.1b - Based in OTServ Trunk (Latest)

Anyone know how to add "Please bring me to" a boat NPC to allow people to just run up, say "please bring me to carlin" if someone is already talking to the npc, it will auto check if the player has the money then sends them to the city. Otherwise, sending the "You do not have enough money" message.

Example I found that doesn't work:
Code:
[QUOTE="Cykotitan, post: 1167804, member: 18868"]"Please bring me to …" method:
[code=lua]local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid)        npcHandler:eek:nCreatureAppear(cid) end
function onCreatureDisappear(cid)     npcHandler:eek:nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg)     npcHandler:eek:nCreatureSay(cid, type, msg) end
function onThink()             npcHandler:eek:nThink() end

local t = {
    {'Carlin', {x=32387, y=31820, z=6}},
    {'Ab\'dendriel', {x=32734, y=31668, z=6}},
    {'Edron', {x=33173, y=31764, z=6}},
    {'Venore', {x=32954, y=32022, z=6}},
    {'Port Hope', {x=32527, y=32784, z=6}},
    {'Svargrond', {x=32341, y=31108, z=6}},
    {'Yalahar', {x=32816, y=31272, z=6}},
    {'Darashia', {x=33289, y=32480, z=6}},
    {'Ankrahmun', {x=33092, y=32883, z=6}},
    {'Goroma', {x=32161, y=32557, z=6}},
    {'sail', 'Where do you want to go? To Carlin, Ab\'Dendriel, Edron, Venore, Port Hope, Svargrond, Yalahar, Darashia, Ankrahmun or Goroma?'},
    {'job', 'I am the captain of this ship.'},
    {'captain', 'I am the captain of this ship.'}
}

for i = 1, #t do
    local v = t
    if type(v[2]) == 'table' then
        keywordHandler:addKeyword({'please bring me to ' .. v[1]:lower()}, StdModule.travel, {npcHandler = npcHandler, level = 0, cost = 0, destination = v[2]})
        local k = keywordHandler:addKeyword({v[1]:lower()}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to sail to ' .. v[1] .. ' for free?'})
        k:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, level = 0, cost = 0, destination = v[2]})
        k:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'We would like to serve you some time.'})
    else
        keywordHandler:addKeyword({v[1]}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = v[2]})
    end
end

t = nil
npcHandler:addModule(FocusModule:new())
"Hi -> Town name" method:
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid)        npcHandler:eek:nCreatureAppear(cid) end
function onCreatureDisappear(cid)     npcHandler:eek:nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg)     npcHandler:eek:nCreatureSay(cid, type, msg) end
function onThink()             npcHandler:eek:nThink() end

local t = {
    {'Carlin', {x=32387, y=31820, z=6}},
    {'Ab\'dendriel', {x=32734, y=31668, z=6}},
    {'Edron', {x=33173, y=31764, z=6}},
    {'Venore', {x=32954, y=32022, z=6}},
    {'Port Hope', {x=32527, y=32784, z=6}},
    {'Svargrond', {x=32341, y=31108, z=6}},
    {'Yalahar', {x=32816, y=31272, z=6}},
    {'Darashia', {x=33289, y=32480, z=6}},
    {'Ankrahmun', {x=33092, y=32883, z=6}},
    {'Goroma', {x=32161, y=32557, z=6}},
    {'sail', 'Where do you want to go? To Carlin, Ab\'Dendriel, Edron, Venore, Port Hope, Svargrond, Yalahar, Darashia, Ankrahmun or Goroma?'},
    {'job', 'I am the captain of this ship.'},
    {'captain', 'I am the captain of this ship.'}
}

for i = 1, #t do
    local v = t
    if type(v[2]) == 'table' then
        keywordHandler:addKeyword({v[1]:lower()}, StdModule.travel, {npcHandler = npcHandler, level = 0, cost = 0, destination = v[2]})
    else
        keywordHandler:addKeyword({v[1]}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = v[2]})
    end
end

t = nil
npcHandler:addModule(FocusModule:new())
[/QUOTE]
[/code]

Any help is appreciated.
 
Bug> Put 300 ms in vocations atk speed. stay walk every attack take 1 second, but if you start walk it take the attack speed from vocations (300 ms).
 
@Ezzz Will you do any more work on this? I'm thinking of starting a new server from scratch using this, but it still seems too "young" to start a project on. Haven't tried the distro myself yet, but people seem to have problems. :)
 
@Ezzz Will you do any more work on this? I'm thinking of starting a new server from scratch using this, but it still seems too "young" to start a project on. Haven't tried the distro myself yet, but people seem to have problems. :)

If you got no C++ knowledge to fix things you won't be able to simulate oldschool gameplay. Those are the main issues #21 and #22.
 
If you got no C++ knowledge to fix things you won't be able to simulate oldschool gameplay. Those are the main issues #21 and #22.
I've got some knowledge, just not that advanced. Also, I'm not into tfs/otserv programming. That's mainly why I asked if he stopped working on the project or not.
Of course I can fix some small things, but I don't know enough about how the server works to be able to for example downgrade certain things.
 
Hey, thanks for this project!
I wanna go into hosting an ot and work with this. But, I have to get acquainted with everything first.

Can you please rehost the files to use with RME because it shows a damaged or empty .rar somehow.
 
Hmm this doesn't work at all, the clients.xml from your package is totally different form the one in my RME, it doesn't support it/can't read the versions. And when I use the clients.xml that comes with RME I get errors loading from otb...

I think we're using different RME versions?
 
Nevermind I made a misstake by downloading the files they ended up having some source info mixed in from where they were downloaded...

offtopic: can we edit posts somehow?
 
So I have my rune npc on OTHire set up, and when people go to sell empty vials the npc will also take vials that are already full.

Code:
-- Empty Vial
shopModule:addSellableItem({'empty', 'vial'}, 2006, 5, 'vial')

This is what I am using, I am on OTHire. Hopefully someone can figure this out.
 
So I have my rune npc on OTHire set up, and when people go to sell empty vials the npc will also take vials that are already full.

Code:
-- Empty Vial
shopModule:addSellableItem({'empty', 'vial'}, 2006, 5, 'vial')

This is what I am using, I am on OTHire. Hopefully someone can figure this out.
I didn't tested, but try this:
Code:
-- Empty Vial
shopModule:addSellableItem({'empty', 'vial'}, 2006, 5, 0, 'vial')
 
@Peonso - thanks for the quick response, unfortunately it still takes all vials and responds with..

01:55 Xodet: Do you want to sell 1 0 for 5 gold coins?
 
@Peonso - thanks for the quick response, unfortunately it still takes all vials and responds with..

01:55 Xodet: Do you want to sell 1 0 for 5 gold coins?

My last bet, got it from some random data folder. Function for lib file.
Code:
function SellPlayerEmptyVials(cid)
    emptyvialmoney = 0
    while doPlayerRemoveItem(cid, 2006, 1, 0) == 1 do
        emptyvialmoney = (emptyvialmoney+5)
    end
    if getNumberValue(emptyvialmoney) > 0 then
        doPlayerAddMoney(cid, getNumberValue(emptyvialmoney))
        return true
    else
        return false
    end
end

For the npc
Code:
function creatureSayCallback(cid, type, msg) msg = string.lower(msg)
    if(npcHandler.focus ~= cid) then
        return false
    end
    if msgcontains(msg, 'vial') then
        NPCSay("I will give you 5 gold for every empty vial of yours, accept?", 1)
        npc01_talk_state = 857
    elseif npc01_talk_state == 857 and msgcontains(msg, 'yes') then
        if SellPlayerEmptyVials(cid) == true then
            NPCSay("Here's your money!", 1)
            npc01_talk_state = 0
        else
            NPCSay("You don't have any empty vials!", 1)
            npc01_talk_state = 0
        end
    end
end
 
You might need this one for lib also.
Code:
function getNumberValue(msg)
    b, e = string.find(msg, "%d+")
   
    if b == nil or e == nil then
        count = 1
    else
        count = tonumber(string.sub(msg, b, e))
    end   
    return count
end
 
Alrighty thanks, so currently I have it set to this in npc.lua

Code:
--sell empty vial
function SellPlayerEmptyVials(cid)
  emptyvialmoney = 0
  while doPlayerRemoveItem(cid, 2006, 1, 0) == 1 do
  emptyvialmoney = (emptyvialmoney+5)
  end
  if getNumberValue(emptyvialmoney) > 0 then
  doPlayerAddMoney(cid, getNumberValue(emptyvialmoney))
  return true
  else
  return false
  end
end

function getNumberValue(msg)
  b, e = string.find(msg, "%d+")
   
  if b == nil or e == nil then
  count = 1
  else
  count = tonumber(string.sub(msg, b, e))
  end   
  return count
end

and this is my runes.lua for the npc,

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

local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

function creatureSayCallback(cid, type, msg) msg = string.lower(msg)
  if(npcHandler.focus ~= cid) then
  return false
  end
  if msgcontains(msg, 'vial') then
  NPCSay("I will give you 5 gold for every empty vial of yours, accept?", 1)
  npc01_talk_state = 857
  elseif npc01_talk_state == 857 and msgcontains(msg, 'yes') then
  if SellPlayerEmptyVials(cid) == true then
  NPCSay("Here's your money!", 1)
  npc01_talk_state = 0
  else
  NPCSay("You don't have any empty vials!", 1)
  npc01_talk_state = 0
  end
  end
end

-- Spell Book

shopModule:addBuyableItem({'spellbook'}, 2175, 150,   'spellbook')

-- Fluids

shopModule:addBuyableItem({'life fluid','lifefluid','health potion','healthpotion','health'}, 2006, 60,10,'life fluid')
shopModule:addBuyableItem({'mana fluid','manafluid','mana potion','manapotion','mana'},2006,55,7,'mana fluid')

-- Runes
shopModule:addBuyableItem({'blank', 'rune'},2260, 10,'blank rune')
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Unfortunately there is no reply when I say vial. Do I need to restart the server to reload /npc/scripts/lib/ or does /reload npcs do it fine? Because I only did /reload npcs
 
I now have it removing only the empty vials, it doesn't give you money and it only takes 1 at a time.

runes.lua
Code:
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

local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
  if msgcontains(msg, 'vial') then
  npcHandler:say("I will give you 5 gold for every empty vial of yours, accept?", 1)
  TalkState(cid, 0)
  elseif msgcontains(msg, 'yes') then
  if SellPlayerEmptyVials(cid) == true then
  npcHandler:say("Here's your money!", 1)
  TalkState(cid, 0)
  else
  npcHandler:say("You don't have any empty vials!", 1)
  TalkState(cid, 0)
  end
  end

-- Spell Book

shopModule:addBuyableItem({'spellbook'}, 2175, 150,   'spellbook')

-- Fluids

shopModule:addBuyableItem({'life fluid','lifefluid','health potion','healthpotion','health'}, 2006, 60,10,'life fluid')
shopModule:addBuyableItem({'mana fluid','manafluid','mana potion','manapotion','mana'},2006,55,7,'mana fluid')

-- Runes
shopModule:addBuyableItem({'blank', 'rune'},2260, 10,'blank rune')
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
@Peonso - Cant edit above post, but this is how the interaction with the npc currently goes.

02:39 Xodet: I will give you 5 gold for every empty vial of yours, accept?
02:39 GM Exploze: yes
02:39 Xodet: You don't have any empty vials!
02:39 GM Exploze: vial
02:39 Xodet: I will give you 5 gold for every empty vial of yours, accept?
02:39 GM Exploze: yes
 
Back
Top