- Joined
- Aug 6, 2007
- Messages
- 1,767
- Reaction score
- 35
Hi,
I'v made this function because the old buycontainer was way to big and you couldent make it compare with the new buy RUne npcs.
Some points about my buycontainer:
-You can use it with the newest Jiddo Npc system (V3.0)
-You can only buy 1 backpack at the time
-Yes it's weard
And no!, I wont release my advanced buyContainer function only this buycontainer.. since no one is giving me rep -.-"
Lets begin!!
Add this ABOVE "function StdModule.say(cid, message, keywords, parameters, node) in modules.lua"
Npc Code (it's an working example):
Credits:
-Pedro B (Helped with some bugs)
-Mokerhamer (Scripted)
-Jiddo? (I forgot if he helped with this function or the other one)
Not Released buyContainer function unless i got 15+ rep in 1 weak
as i said i wont release my advanced buyContainer version unless i get atleast 15 COUNTING rep in 1 weak.
How does my advanced buyContainer work?
-You can buy Multi backpacks at 1 time
-Checks cap, and if you have enoughe place in your backpack
-And you can use my advanced buyContainer with 1 line likt this.
shopModule:buyContainer({'crap', 'bp sd'},
Yours,
Mokerhamer
I'v made this function because the old buycontainer was way to big and you couldent make it compare with the new buy RUne npcs.
Some points about my buycontainer:
-You can use it with the newest Jiddo Npc system (V3.0)
-You can only buy 1 backpack at the time
-Yes it's weard
And no!, I wont release my advanced buyContainer function only this buycontainer.. since no one is giving me rep -.-"
Lets begin!!
Add this ABOVE "function StdModule.say(cid, message, keywords, parameters, node) in modules.lua"
Code:
function StdModule.buyContainer(cid, message, keywords, parameters, node)
local npcHandler = parameters.npcHandler
if(npcHandler == nil) then
error('StdModule.buyContainer called without any npcHandler instance.')
end
if(cid ~= npcHandler.focus) then
return false
end
if(doPlayerRemoveMoney(cid, parameters.cost) ~= TRUE) then
selfSay('You do not have enough money!')
else
local containerId = doPlayerAddItem(cid, parameters.containerId, 1)
if isContainer(containerId) == TRUE then
while getContainerSize(containerId) ~= 20 do
doAddContainerItem(containerId, parameters.runeId, parameters.runeCharges)
end
end
return true
end
end
Npc Code (it's an working example):
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
local SDNode = keywordHandler:addKeyword({'bp sd', 'backpack of sd', 'backpack of sudden death'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy a backpack of sudden death runes for 6000 gold?'})
SDNode:addChildKeyword({'yes'}, StdModule.buyContainer, {npcHandler = npcHandler, onlyFocus = true, cost = 6000, containerId = 2000, runeId = 2216, runeCharges = 1})
SDNode:addChildKeyword({'no'}, StdModuel.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ok, can I help you in anything else?'})
npcHandler:addModule(FocusModule:new())
Credits:
-Pedro B (Helped with some bugs)
-Mokerhamer (Scripted)
-Jiddo? (I forgot if he helped with this function or the other one)
Not Released buyContainer function unless i got 15+ rep in 1 weak
as i said i wont release my advanced buyContainer version unless i get atleast 15 COUNTING rep in 1 weak.
How does my advanced buyContainer work?
-You can buy Multi backpacks at 1 time
-Checks cap, and if you have enoughe place in your backpack
-And you can use my advanced buyContainer with 1 line likt this.
shopModule:buyContainer({'crap', 'bp sd'},
Code:
BpID, runeId, Cost, Charges, 'Back Pack of sudden death')
Yours,
Mokerhamer