jaicob
Active Member
- Joined
- Feb 16, 2009
- Messages
- 100
- Solutions
- 2
- Reaction score
- 41
We'll since there was nothing wrong with the lua itself it was no problem.
It was just that i should've gone to bed...
My problem was that i made a backup on all the Lib files and i kept edit the backup lib for hours...
So solution = sleep
Though i keep it here if someone else have the same problem or want the same script
Hell I'm currently trying to fix an amulet of loss that cost dependant on what level.
currently I've changed the bless script to
modules.lua I've added
and in my npc script i've added
It was just that i should've gone to bed...
My problem was that i made a backup on all the Lib files and i kept edit the backup lib for hours...
So solution = sleep
Though i keep it here if someone else have the same problem or want the same script
Hell I'm currently trying to fix an amulet of loss that cost dependant on what level.
currently I've changed the bless script to
modules.lua I've added
Code:
function StdModule.aol(cid, message, keywords, parameters, node)
local npcHandler = parameters.npcHandler
if(npcHandler == nil) then
print('[Warning - ' .. getCreatureName(getNpcCid()) .. '] StdModule.aol called without any npcHandler instance.')
return false
end
if(not npcHandler:isFocused(cid)) then
return false
end
if(isPlayerPremiumCallback(cid) or not(parameters.premium)) then
local price = parameters.baseCost
if(getPlayerLevel(cid) > parameters.startLevel) then
price = (price + ((math.min(parameters.endLevel, getPlayerLevel(cid)) - parameters.startLevel) * parameters.levelCost))
end
if doPlayerRemoveMoney(cid, price) == false then
npcHandler:say("You do not have enough money for an amulet of the loss.", cid)
else
npcHandler:say("You have bought an amulet of the loss!", cid)
doPlayerAddItem(cid, 2173, 1)
end
else
npcHandler:say('You need a premium account in order to be blessed.', cid)
end
npcHandler:resetNpc()
return true
end
and in my npc script i've added
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 onPlayerEndTrade(cid) npcHandler:onPlayerEndTrade(cid) end
function onPlayerCloseChannel(cid) npcHandler:onPlayerCloseChannel(cid) end
local node1 = keywordHandler:addKeyword({'amulet of loss'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy an amulet of loss for 2000 (plus level depending amount) gold?'})
node1:addChildKeyword({'yes'}, StdModule.aol, {npcHandler = npcHandler, number = 2173, premium = true, baseCost = 1900, levelCost = 300, startLevel = 30, endLevel = 357})
node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Ok, just be cautious!'})
npcHandler:addModule(FocusModule:new())
Last edited: