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

[request] Buying BPs of runes (TFS)

Falazen

New Member
Joined
Feb 18, 2008
Messages
82
Reaction score
2
Greetings. After hours of trying to script a NPC for TFS 2.14, I've finally basically given up; thus I'm here asking you all for it. If anyone could supply an NPC that can sell whole BPs of runes (and work) would be highly appreciated.

Thanks in advance.
 
Look i had the same problem and you will not find any helpful posts, I checked the whole internet and found some but dindt work as i thought the will.

REMEMBER: This is a click and buy action

heres the code:

function onUse(cid, item, frompos, item2, topos)

if doPlayerRemoveMoney(cid,6500) == 1 then
bp = doPlayerAddItem(cid,5926,1) --container
doAddContainerItem(bp,2268,5)
doAddContainerItem(bp,2268,5)
doAddContainerItem(bp,2268,5)
doAddContainerItem(bp,2268,5)
doAddContainerItem(bp,2268,5)
doAddContainerItem(bp,2268,5)
doAddContainerItem(bp,2268,5)
doAddContainerItem(bp,2268,5)
doAddContainerItem(bp,2268,5)
doAddContainerItem(bp,2268,5)
doAddContainerItem(bp,2268,5)
doAddContainerItem(bp,2268,5)
doAddContainerItem(bp,2268,5)
doAddContainerItem(bp,2268,5)
doAddContainerItem(bp,2268,5)
doAddContainerItem(bp,2268,5)
doAddContainerItem(bp,2268,5)
doAddContainerItem(bp,2268,5)
doAddContainerItem(bp,2268,5)
doAddContainerItem(bp,2268,5)
setPlayerStorageValue(cid,51000,1)
doSendMagicEffect(frompos,12)
else
doPlayerSendCancel(cid, "You need 6500 gps to buy")
end

return 0
end

this will go to \actions\scripts\bpsd.lua


add this to your actions.xml

<action actionid="3504" script="bpsd.lua" />

This action will buy a bp of sd for the price of 6500 with 5 charges every sd, remeber this will add a whole new backpack with sd inside no problems found i tested in my server SQL


THX
 
Look i had the same problem and you will not find any helpful posts, I checked the whole internet and found some but dindt work as i thought the will.

REMEMBER: This is a click and buy action

heres the code:



this will go to \actions\scripts\bpsd.lua


add this to your actions.xml



This action will buy a bp of sd for the price of 6500 with 5 charges every sd, remeber this will add a whole new backpack with sd inside no problems found i tested in my server SQL


THX


Alot of work, but whatever. What must be done must be done.

Thanks ;]
 
no, no, no... Use "Mokerhammers" buyContainer tutorial...it adds a function to your server, in which makes it so you can buy runes like this

"Bp, Rune, Price, Charges"
"2003, 2268, 6000, 3"
gray backpack, sd, 6k, 3 charges

OR you could use this lever script which "you use a lever, and it takes the money, and gives a bp full of runes"

Code:
local suddendeath = 2268
local ultimatehealing = 2273
local greatfireball = 2304
local explotion = 2313
local heavymagicmissle = 2268
local bp, rune, charges

function onUse(cid, item, frompos, item2, topos)
	if item.itemid == 1945 then
		if item.actionid == 10550 then
			if doRemoveMoney(cid, 6000) == 1 then 
				bp = doPlayerAddItem(cid, 2003)
				rune = suddendeath
				charges = 1
			else
				doPlayerSendTextMessage(player, 22, "You don\'t have enough money.")
			end
		elseif item.actionid == 10551 then
			if doRemoveMoney(cid, 4000) == 1 then
				bp = doPlayerAddItem(cid, 2002)
				rune = ultimatehealing
				charges = 1
			else
				doPlayerSendTextMessage(player, 22, "You don\'t have enough money.")
			end
		elseif item.actionid== 10552 then
			if doRemoveMoney(cid, 1000) == 1 then
				bp = doPlayerAddItem(cid, 2001)
				rune = heavymagicmissle
				charges = 10
			else
				doPlayerSendTextMessage(player, 22, "You don\'t have enough money.")
			end
		elseif item.actionid == 10553 then
			if doRemoveMoney(cid, 3000) == 1 then
				bp = doPlayerAddItem(cid, 2001)
				rune = explotion
				charges = 2
			else
				doPlayerSendTextMessage(player, 22, "You don\'t have enough money.")
			end
		elseif item.actionid == 10554 then
			if doRemoveMoney(cid, 2000) == 1 then
				bp = doPlayerAddItem(cid, 2000)
				rune = greatfireball
				charges = 2
			else
				doPlayerSendTextMessage(player, 22, "You don\'t have enough money.")
			end
		end
 
		if rune then
			for i = 1, 20 do
				doAddContainerItem(bp, rune, charges)
			end
			bp, rune, charges = nil
		end
	elseif item.itemid == 1946 then
		doTransformItem(item.uid, item.itemid + 1)
	end
		return TRUE
end
 
I've got NPC's in the new distro to sell bp's of runes.

You have to make a couple of simple changes.

In data\global.lua
Find:
Code:
function doPlayerBuyItemContainer(cid, container, itemid, count, cost, charges)
	if doPlayerRemoveMoney(cid, cost) == TRUE then
		for i = 1, count do
			local containerItem = doPlayerAddItem(cid, container, 1)
			for x = 1, 20 do
				doAddContainerItem(containerItem[1], itemid, charges)
			end
		end
		return LUA_NO_ERROR
	end
	return LUA_ERROR
end
And replace with:
Code:
function doPlayerBuyItemContainer(cid, container, itemid, charges, cost, count)
	if doPlayerRemoveMoney(cid, cost) == TRUE then
		for i = 1, count do
			local backpack = doPlayerAddItem(cid, container, 1)
			for x = 1, 20 do
				doAddContainerItem(backpack, itemid, charges)
			end
		end
		return LUA_NO_ERROR
	end
	return LUA_ERROR
end

In data\npc\lib\npcsystem\modules.lua
Find:
Code:
local ret = doPlayerBuyItemContainer(cid, parentParameters.container, parentParameters.itemid, module.amount, parentParameters.cost * module.amount, parentParameters.subType)
And replace with:
Code:
local ret = doPlayerBuyItemContainer(cid, parentParameters.container, parentParameters.itemid, parentParameters.charges, parentParameters.cost, module.amount, parentParameters.subType)

Use the following format in the npc's .lua file to sell BP's (this format is slightly different to what you would already have so make sure you change).
Code:
shopModule:addBuyableItemContainer({'bp of uh'}, 2002, 2273, 10500, 'backpack of ultimate healing runes')
Where 'bp of uh' is the keyword, 2002 is the id of the container (backpack), 2273 is the id of the rune and 10500 is the cost of the entire backpack.

Note, the amount of charges the rune is sold with is determined in the data\spells\spells.xml file.
E.g.
Code:
<rune name="Ultimate Healing Rune" id="2273" allowfaruse="1" charges="100" lvl="24" maglv="4" exhaustion="1000" aggressive="0" needtarget="1" blocktype="solid" script="healing/ultimate healing rune.lua"/>
Will mean that the backpack of UH each have 100 charges.

Hope this made sense and helps someone.

Cheers.
 
Back
Top