Tjay
Retired Hoster
Is There a way to make a npc that you need 100 metal spikes(id 11208) and can trade them in for a health stone{id 11220} or mana skull(id 2229)
Thanks,
Tjay
Thanks,
Tjay
if getPlayerItemCount(cid, 11208) >= 100 then
doPlayerRemoveItem(cid, 11208, 100)
doPlayerAddItem(cid, 11220, 1) -- Or doPlayerAddItem(cid, 2229, 1)
end
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 buyMana(cid, message, keywords, parameters, node)
if doPlayerRemoveItem(cid, 11208, 100) then
setCreatureMaxMana(cid, getCreatureMaxMana(cid)+1000)
npcHandler:say("Thank you.", cid)
npcHandler:releaseFocus(cid)
else
npcHandler:say("You don't have items required yet...", cid)
npcHandler:releaseFocus(cid)
end
return true
end
function buyHealth(cid, message, keywords, parameters, node)
if doPlayerRemoveItem(cid, 11208, 100) then
setCreatureMaxHealth(cid, getCreatureMaxHealth(cid)+1000)
npcHandler:say("Thank you.", cid)
npcHandler:releaseFocus(cid)
else
npcHandler:say("You don't have items required yet..", cid)
npcHandler:releaseFocus(cid)
end
return true
end
local node1 = keywordHandler:addKeyword({'mana'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Do you want to buy 1000 mana for 100 metal spikes?"})
node1:addChildKeyword({'yes'}, buyMana, {npcHandler = npcHandler, onlyFocus = true, reset = true})
node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ok then.', reset = true})
local node2 = keywordHandler:addKeyword({'health'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Do you want to buy 1000 health for 100 metal spikes?"})
node2:addChildKeyword({'yes'}, buyMana, {npcHandler = npcHandler, onlyFocus = true, reset = true})
node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ok then.', reset = true})
npcHandler:addModule(FocusModule:new())
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local Topic = 0
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 greetCallback(cid)
Topic = 0
return true
end
npcHandler:setMessage(MESSAGE_GREET, "Greetings, |PLAYERNAME|.")
npcHandler:setMessage(MESSAGE_WALKAWAY, "How rude!")
npcHandler:setMessage(MESSAGE_FAREWELL, "Bye.")
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
if msgcontains(msg, "mana") then
npcHandler:say("Do you want to buy 1000 mana for 100 metal spikes?.", cid)
Topic = 1
elseif msgcontains(msg, "health") then
npcHandler:say("Do you want to buy 1000 health for 100 metal spikes?.", cid)
Topic = 2
elseif Topic == 1 then
if msgcontains(msg, 'yes') then
if getPlayerItemCount(cid, 11208) >= 100 then
doPlayerRemoveItem(cid, 11208, 100)
setCreatureMaxMana(cid, getCreatureMaxMana(cid)+1000)
npcHandler:say("Thank you.", cid)
npcHandler:releaseFocus(cid)
Topic = 0
else
npcHandler:say("You don't have items required yet...", cid)
npcHandler:releaseFocus(cid)
Topic = 0
end
end
elseif Topic == 2 then
if msgcontains(msg, 'yes') then
if getPlayerItemCount(cid, 11208) >= 100 then
doPlayerRemoveItem(cid, 11208, 100)
setCreatureMaxMana(cid, getCreatureMaxHealth(cid)+1000)
npcHandler:say("Thank you.", cid)
npcHandler:releaseFocus(cid)
Topic = 0
else
npcHandler:say("You don't have items required yet...", cid)
npcHandler:releaseFocus(cid)
Topic = 0
end
end
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Exchanger" script="data/npc/scripts/exchange.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="22" head="0" body="0" legs="0" feet="0" addons="0"/>
<parameters>
<parameter key="message_greet" value="! Welcume ' Player.."/>
<parameter key="message_farewell" value="Good bye!."/>
</parameters>
</npc>
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
-- XVX FORGER START --
function amulet(cid, message, keywords, parameters, node)
if(not npcHandler:isFocused(cid)) then
return false
end
if getPlayerItemCount(cid,11208) >= 1 then
if doPlayerRemoveItem(cid,11208,100) and ) then
npcHandler:say('Here is your item!', cid)
doPlayerAddItem(cid,11220,1)
end
else
npcHandler:say('You don\'t have these items!', cid)
end
end
function obsidian(cid, message, keywords, parameters, node)
if(not npcHandler:isFocused(cid)) then
return false
end
if getPlayerItemCount(cid,11208) >= 1
if doPlayerRemoveItem(cid,11208,100) and
npcHandler:say('Here is your item!', cid)
doPlayerAddItem(cid,2229,1)
end
else
npcHandler:say('You don\'t have these items!', cid)
end
end
local node1 = keywordHandler:addKeyword({'health stone'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to trade 100 metal spikes for a health stone?'})
node2:addChildKeyword({'yes'}, obsidian, {npcHandler = npcHandler, onlyFocus = true, reset = true})
node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back when you got the neccessary items.', reset = true})
local node2 = keywordHandler:addKeyword({'mana skull'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to trade 100 metal spikes for a mana skull?'})
node2:addChildKeyword({'yes'}, obsidian, {npcHandler = npcHandler, onlyFocus = true, reset = true})
node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back when you got the neccessary items.', reset = true})
npcHandler:addModule(FocusModule:new())
@up
Can u post source pls
Give me link to the thread u got the script from. =Pwhat do you mean ? i dont really speak good english
Perhaps by showing the errors, you can get more help?