Godely
Member
- Joined
- Aug 19, 2007
- Messages
- 233
- Reaction score
- 19
Hello. I made a NPC who gives an obsidian knife if you give him a dragon shield and 15k:
On this line is bold, the script is not working: It don't appears any bug message on the console, but, in the server, the NPC just requires the dragon shield. For example:
*You can have 1k and a dragon shield, and he will take all the money and the dragon shield.
*You can have only the dragon sheild, and he will take only the dragon shield.
*You can have 16k and the dragon shield, and he will take 15k and the dragon shield.
The correct is: He just gives you the obsidian knife IF you have either the 15k AND the dragon shield.
I hope someone fixes it.
Thanks, bye.
Code:
local crystalCoins = getPlayerItemCount(cid,2160)
local platinumCoins = getPlayerItemCount(cid,2152)
local goldCoins = getPlayerItemCount(cid,2148)
money = crystalCoins * 10000 + platinumCoins * 100 + goldCoins
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
--special function
function tradeKnife(cid, message, keywords, parameters, node)
if(cid ~= npcHandler.focus) then
return false
end
[B] if getPlayerItemCount(cid,2516) < 1 and getPlayerItemCount(cid,money) < 15000 then[/B]
selfSay('Sorry, but you don\'t have some of the itens that I asked of you.')
else
doPlayerAddItem(cid,5908,1)
doPlayerRemoveMoney(cid,15000)
doPlayerRemoveItem(cid,2516,1)
selfSay('Thank you! Now make a good use of your obsidian knife. If you don\'t know how to use, just ask for help.')
end
end
-- Add keyword
keywordHandler:addKeyword({'offer'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Hah! I\'m selling an obsidian knife. But it\'s not so cheap...'})
keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I\'m just a cyclops, trying to sell somethings for my family.'})
keywordHandler:addKeyword({'name'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'My name is Urghit. I was blood brother of Urgath, the master.'})
keywordHandler:addKeyword({'help'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Well, don\'t you know how to use the obsidian knife? It\'s simple! Just use it on a refresh dead body of all kinds of minotaur, all kinds of lizards, all kinds of dragon, bone beast and behemoth!... If you get lucky, you can take the leather or something else from them.'})
--special keywords
local node1 = keywordHandler:addKeyword({'obsidian knife'}, StdModule.say, {npcHandler = npcHandler, text = 'Hmmmm... The price is 15000 gold coins and 1 dragon shield. Accept?'})
node1:addChildKeyword({'yes'}, tradeKnife)
node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, text = 'Ok then, no problem.'}, true)
-- Makes sure the npc reacts when you say hi, bye etc.
npcHandler:addModule(FocusModule:new())
On this line is bold, the script is not working: It don't appears any bug message on the console, but, in the server, the NPC just requires the dragon shield. For example:
*You can have 1k and a dragon shield, and he will take all the money and the dragon shield.
*You can have only the dragon sheild, and he will take only the dragon shield.
*You can have 16k and the dragon shield, and he will take 15k and the dragon shield.
The correct is: He just gives you the obsidian knife IF you have either the 15k AND the dragon shield.
I hope someone fixes it.
Thanks, bye.