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

Rune bp seller on 7.6 xml bug.

challe92

New Member
Joined
Jun 14, 2008
Messages
31
Reaction score
0
Hello Otland. I've found a bp rune seller npc in my npc directory.
Which means that this npc will sell backpack of runes or manas etc. This is a 7.6 xml real map, and those scripts are kinda rare here since the newer scripts wont work on the older xml servers. The problem is that when you say for example:

Sture Den Lure: Buy bp sds.

Xodet: Do you want to buy a backpack of Sudden Death runes for 6000 gold pieces?

Sture Den Lure: Yes

And nothing happens, he wont answer you with: "Here You Go!". you wont loose your money tho, and you wont get any bp runes in your backpack.

Can someone please help me get this npc working?

Here is the Data/npc/Bp_runes.xml
Code:
<?xml version="1.0"?>

<npc name="Xodet" script="data/npc/scripts/bp_runes.lua" access="3" pushable="0" dir="1">
	<health now="1000" max="1000"/>
	<look type="128" head="78" body="71" legs="82" feet="114" corpse="3128"/>
</npc>

Here is Data/Npc/Scripts/Bp_runes.lua

Code:
-- Scripts by TLM TEAM
-- Modified by HoTS

target = 0 
following = false 
attacking = false 
focus = 0
itemid = 0 
count = 0
payback = 0
talkcount = 0

talk_start = 0 

function selfLook(cid)
if cid ~= 0 then
 x, y, z = creatureGetPosition(focus)
 myx, myy, myz = selfGetPosition()
 if ((myy-y==0) and (myx-x<=0 and myx-x>=-4)) then
       selfTurn(0)
 end
 if ((myy-y==0) and (myx-x>=0 and myx-x<=4)) then
       selfTurn(2)
 end
 if ((myx-x==0) and (myy-y<=0 and myy-y>=-4)) then
       selfTurn(1)
 end
 if ((myx-x==0) and (myy-y>=0 and myy-y<=4)) then
       selfTurn(3)
 end
 if ((myy-y==-2) and (myx-x>=-1 and myx-x<=1)) then
       selfTurn(1)
 end
 if ((myy-y==2) and (myx-x>=-1 and myx-x<=1)) then
        selfTurn(3)
 end
 if ((myx-x==2) and (myy-y>=-1 and myy-y<=1)) then
        selfTurn(2)
 end
 if ((myx-x==-2) and (myy-y>=-1 and myy-y<=1)) then
        selfTurn(0)
 end
 if ((myy-y==-3) and (myx-x>=-2 and myx-x<=2)) then
        selfTurn(1)
 end
 if ((myy-y==3) and (myx-x>=-2 and myx-x<=2)) then
        selfTurn(3)
 end
 if ((myx-x==3) and (myy-y>=-2 and myy-y<=2)) then
        selfTurn(2)
 end
 if ((myx-x==-3) and (myy-y>=-2 and myy-y<=2)) then
        selfTurn(0)
 end
 if ((myy-y==-4) and (myx-x>=-3 and myx-x<=3)) then
        selfTurn(1)
 end
 if ((myy-y==4) and (myx-x>=-3 and myx-x<=3)) then
        selfTurn(3)
 end
 if ((myx-x==4) and (myy-y>=-3 and myy-y<=3)) then
        selfTurn(2)
 end
 if ((myx-x==-4) and (myy-y>=-3 and myy-y<=3)) then
        selfTurn(0)
 end
end
end

function onThingMove(creature, thing, oldpos, oldstackpos) 
end 


function onCreatureAppear(creature) 
end 


function onCreatureDisappear(id) 
if id == target then 
target = 0 
attacking = false 
selfAttackCreature(0) 
following = false 
--Stop--Speaking()
end 

focus = 0
itemid = 0 
end 


function onCreatureTurn(creature) 
end 

function onCreatureSay(cid, type, msg)
  msg = string.lower(msg) 

	dist = getDistanceToCreature(cid)
		if dist >= 4 then

   return

end

  talk_start = os.clock() 

if string.find(msg, '(%a*)offer(%a*)') then
 selfSay('The runes are: Bp SD - 3x (6500gp), Bp UH - 5x (3500gp), Bp GFB - 3x (3600gp), Bp Hmm - 5x (2500gp), Bp Explosion - 5x (5000), Bp Ih - 10x (1900gp) Bp Mana Fluid - 1x (1000gp).')
end



  if string.find(msg, '(%a*)yes(%a*)') and cid == focus and talkcount == 2 then       
     talkcount = 0
     SellItem(focus,itemid,count,cost)
  end

-- Some More Commands To Shopping


if string.find(msg, '(%a*)rune(%a*)') and cid == focus then
     selfSay('A blank rune costs 10 gold pieces, do you want to buy one?')
talk_start = os.clock()
       itemid = 2260
       count = 1
cost = 10*20
       talkcount = 1
       return
  end

if string.find(msg, '(%a*)sd(%a*)') and cid == focus then
     selfSay('do you want to buy one?')
talk_start = os.clock()
       itemid = 2268
       count = 1
	cost = 325*20
       talkcount = 1
       return
  end

if string.find(msg, '(%a*)ih(%a*)') and cid == focus then
     selfSay('do you want to buy one?')
talk_start = os.clock()
       itemid = 2265
       count = 1
	cost = 95*20
       talkcount = 1
       return
  end

if string.find(msg, '(%a*)uh(%a*)') and cid == focus then
     selfSay('do you want to buy one?')
talk_start = os.clock()
       itemid = 2273
       count = 1
	cost = 175*20
       talkcount = 1
       return
  end

if string.find(msg, '(%a*)gfb(%a*)') and cid == focus then
     selfSay('do you want to buy one?')
talk_start = os.clock()
       itemid = 2304
       count = 3
	cost = 180*20
       talkcount = 1
       return
  end

if string.find(msg, '(%a*)explosion(%a*)') and cid == focus then
     selfSay('do you want to buy one?')
talk_start = os.clock()
       itemid = 2313
       count = 3
	cost = 250*20
       talkcount = 1
       return
  end

if string.find(msg, '(%a*)hmm(%a*)') and cid == focus then
     selfSay('do you want to buy one?')
talk_start = os.clock()
       itemid = 2311
       count = 5
	cost = 125*20
       talkcount = 1
       return
  end

if string.find(msg, '(%a*)mana fluid(%a*)') and cid == focus then
     selfSay('do you want to buy one?')
talk_start = os.clock()
       itemid = 2006
       count = 20
	cost = 50*20
       talkcount = 1
       return
  end

-- End of Shopping



  if string.find(msg, '(%a*)no(%a*)') and cid == focus and talkcount == 1 then
     selfSay('Ok, is there something else you want? If so tell me.')
itemid = 0
count = 0
cost = 0
talkcount = 0
  end 

  if string.find(msg, '(%a*)yes(%a*)') and cid == focus and talkcount == 1 then       
     talkcount = 0
     buycontainer(focus,itemid,count,cost)
  end

  if string.find(msg, '(%a*)hi(%a*)') and string.len(msg) == 2 then
     if focus == cid then
        selfSay('I am already talking to you!')
     else if focus > 0 then
        selfSay('' .. creatureGetName(cid) .. ', please wait until it is your turn!')
        end
     end
     if(focus == 0) then
        selfSay('Hello, ' .. creatureGetName(cid) .. ', welcome to my tools shop!') 
        focus = cid
	--TurnToPlayer(focus)
	--Speaking()
     end
     talk_start = os.clock()
  end

  if string.find(msg, '(%a*)hello(%a*)') and string.len(msg) == 5 then
     if focus == cid then
        selfSay('I am already talking to you!')
     else if focus > 0 then
        selfSay('' .. creatureGetName(cid) .. ', please wait until it is your turn!')
        end
     end
     if(focus == 0) then
        selfSay('Hello, ' .. creatureGetName(cid) .. ', welcome to my tools shop!') 
        focus = cid
	--TurnToPlayer(focus)
	--Speaking()
     end
     talk_start = os.clock()
  end

  if string.find(msg, '(%a*)hey(%a*)') and string.len(msg) == 3 then
     if focus == cid then
        selfSay('I am already talking to you!')
     else if focus > 0 then
        selfSay('' .. creatureGetName(cid) .. ', please wait until it is your turn!')
        end
     end
     if(focus == 0) then
        selfSay('Hello, ' .. creatureGetName(cid) .. ', welcome to my tools shop!') 
	focus = cid
	--TurnToPlayer(focus)
	--Speaking()
     end
     talk_start = os.clock()
  end

  if string.find(msg, '(%a*)bye(%a*)') and cid == focus then 
     selfSay('Farewell, ' .. creatureGetName(cid) .. '!') 
focus = 0 
itemid = 0
talk_start = 0 
talkcount = 0
--Stop--Speaking()
  end 

  if string.find(msg, '(%a*)farewell(%a*)') and cid == focus then 
     selfSay('Farewell, ' .. creatureGetName(cid) .. '!') 
focus = 0 
itemid = 0
talk_start = 0 
talkcount = 0
--Stop--Speaking()
  end 
end


function onCreatureChangeOutfit(creature)
end


function onThink() 

if (os.clock() - talk_start) > 40 then 
if focus > 0 then 
selfSay('Next please!') 
talkcount = 0
--Stop--Speaking()
end 

focus = 0 
itemid = 0
talk_start = 0 
end 
end

Please. If anyone can solve this problem, would you be too kind and post it here?

Kind Regards
Your's
Challe92
 
Last edited:
if you want to use buycontainer, you'll have to add this into your npc.cpp: [7.6] BuyContainer System edited by Crea - Open Tibia Forum (OTS)

this is a temporary fix:
Code:
local target, following, attacking, focus, itemid, count, payback, Topic, ticks = 0, false, false, 0, 0, 0, 0, 0, 0
local NORTH, EAST, SOUTH, WEST = 0, 1, 2, 3

local _selfSay = selfSay
local function selfSay(msg)
	ticks = os.clock()
	_selfSay(msg)
end

function selfLook(cid)
	if cid > 0 then
		local creaturePos, myPos = {}, {}
		creaturePos.x, creaturePos.y, creaturePos.z = creatureGetPosition(cid)
		myPos.x, myPos.y, myPos.z = selfGetPosition()
		local dx, dy = myPos.x - creaturePos.x, myPos.y - creaturePos.y
		
		
		local tan = 10
		if dx ~= 0 then
			tan = dy / dx
		end
		
		local dir = SOUTH
		if math.abs(tan) < 1 then
			dir = dx > 0 and WEST or EAST
		elseif dy > 0 then
			dir = NORTH
		end

		selfTurn(dir)
	end
end

function onThingMove(creature, thing, oldpos, oldstackpos) end 
function onCreatureAppear(creature) end
function onCreatureDisappear(id) 
	if id == target then
		target, attacking, following = 0, false, false
		selfAttackCreature(0)
	end 
	focus, itemid, count, cost, Topic = 0, 0, 0, 0 ,0
end

function onCreatureTurn(creature) end
function msgcontains(message, keyword, dollar)
	local message, keyword = message:lower(), keyword:lower()
	return message:find(keyword) and not message:find('(%w+)' .. keyword) and (not dollar or not message:find(keyword .. '(%w+)'))
end

function onCreatureSay(cid, type, msg)
	if getDistanceTo(cid) > 3 then return
	elseif msgcontains(msg, "hi", true) or msgcontains(msg, "hello", true) then
		if focus ~= cid and focus > 0 then
			selfSay(creatureGetName(cid) .. ', please wait until it is your turn!')
		elseif focus == 0 then
			selfSay('Hello, ' .. creatureGetName(cid) .. ', welcome to my rune shop!')
			focus = cid
		end
		return
	elseif focus ~= cid then
		return
	end
	selfLook(focus)
	if msgcontains(msg, 'bye') or msgcontains(msg, 'farewell') then 
		selfSay('Farewell, ' .. creatureGetName(cid) .. '!')
		focus, itemid, ticks, Topic = 0, 0, 0, 0
	elseif msgcontains(msg, 'yes') and Topic == 1 then       
		Topic = 0
		cost = cost / 20
		for i = 1, 20 do
			buy(focus, itemid, count, cost)
		end
	elseif msgcontains(msg, 'blank') then
		itemid, count, cost, Topic = 2260, 1, 10 * 20, 1
		selfSay('Do you want to buy ' .. count .. ' blank runes for ' .. cost ..' gold?')
	elseif msgcontains(msg, 'sd') or (msgcontains(msg, 'sudden') and msgcontains(msg, 'death')) then
		itemid, count, cost, Topic = 2268, 1, 325 * 20, 1
		selfSay('Do you want to buy ' .. count .. ' sudden death runes for ' .. cost ..' gold?')
	elseif msgcontains(msg, 'ih') or (msgcontains(msg, 'intense') and msgcontains(msg, 'healing')) then
		itemid, count, cost, Topic = 2265, 1, 95 * 20, 1
		selfSay('Do you want to buy ' .. count .. ' intense healing runes for ' .. cost ..' gold?')
	elseif msgcontains(msg, 'uh') or (msgcontains(msg, 'ultimate') and msgcontains(msg, 'healing')) then
		itemid, count, cost, Topic = 2273, 1, 175 * 20, 1
		selfSay('Do you want to buy ' .. count .. ' ultimate healing runes for ' .. cost ..' gold?')
	elseif msgcontains(msg, 'gfb') or (msgcontains(msg, 'great') and msgcontains(msg, 'fireball')) then
		itemid, count, cost, Topic = 2304, 3, 180 * 20, 1
		selfSay('Do you want to buy ' .. count .. ' great fireball runes for ' .. cost ..' gold?')
	elseif msgcontains(msg, 'explosion') then
		itemid, count, cost, Topic = 2313, 3, 250 * 20, 1
		selfSay('Do you want to buy ' .. count .. ' explosion runes for ' .. cost ..' gold?')
	elseif msgcontains(msg, 'hmm') or (msgcontains(msg, 'heavy') and msgcontains(msg, 'magic') and msgcontains(msg, 'missile'))then
		itemid, count, cost, Topic = 2311, 5, 125 * 20, 1
		selfSay('Do you want to buy ' .. count .. ' heavy magic missile runes for ' .. cost ..' gold?')
	elseif msgcontains(msg, 'mana') and  msgcontains(msg, 'fluid') then
		itemid, count, cost, Topic = 2006, 20, 50 * 20, 1
		selfSay('Do you want to buy ' .. count .. ' sudden death runes for ' .. cost ..' gold?')
	elseif msgcontains(msg, "offer") or msgcontains(msg, "trade") or msgcontains(msg, "equipment") or msgcontains(msg, "goods") or msgcontains(msg, "ware") or msgcontains(msg, "buy") or msgcontains(msg, "sell") or msgcontains(msg, "stuff") or msgcontains(msg, "rune") then
		selfSay('The runes are: Bp SD - 3x (6500gp), Bp UH - 5x (3500gp), Bp GFB - 3x (3600gp), Bp Hmm - 5x (2500gp), Bp Explosion - 5x (5000), Bp Ih - 10x (1900gp) Bp Mana Fluid - 1x (1000gp).')
	elseif Topic == 1 then
		selfSay('Hmm, but next time.')
		itemid, count, cost, Topic = 0, 0, 0, 0
	end
end

function onCreatureChangeOutfit(creature) end
function onThink()
	selfLook(focus)
	if os.clock() - ticks > 60 or (focus > 0 and getDistanceToCreature(focus) > 3) then
		if focus > 0 then
			selfSay('Next please!')
		end
		Topic, focus, itemid, ticks = 0, 0, 0, 0
	end
end
 
Last edited:
Back
Top