nefinoo
Carnage.flv
talkaction or npc sell you charges for yours pots, i am using tfs 1.3
talkaction or npc sell you charges for yours pots, i am using tfs 1.3
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
item = 'You do not have the required items.'
done = 'Here you are.'
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
if msgcontains(msg, 'offer') then
selfSay('Here you can buy the following training items: {training sword}, {training axe}, {training club}, {training distance}, {training druid}, and {training sorcerer}. Also I sell the following amulets: {stone skin amulet}, {dragon necklace} and {garlic necklace}.', cid)
elseif msgcontains(msg, 'training sword') then
if getPlayerItemCount(cid,2160) >= 6 or getPlayerItemCount(cid,2152) >= 600 then
selfSay('Are you willing to pay 60,000 gold coins for {training sword}?', cid)
talk_state = 1
else
selfSay('I need 60,000 gold coins to give you the {training sword}. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 1 then
talk_state = 0
if getPlayerItemCount(cid,2160) >= 6 or getPlayerItemCount(cid,2152) >= 600 then
if doPlayerRemoveItem(cid,2160, 6) or doPlayerRemoveItem(cid,2152, 600) == TRUE then
selfSay(done, cid)
local xx = doPlayerAddItem(cid, 2376, 1)
doItemSetAttribute(xx, "aid", 1443)
doItemSetAttribute(xx, "charges", 50)
end
else
selfSay(item, cid)
end
-- axe ---
elseif msgcontains(msg, 'training axe') then
if getPlayerItemCount(cid,2160) >= 6 or getPlayerItemCount(cid,2152) >= 600 then
selfSay('Are you willing to pay 60,000 gold coins for {training axe}?', cid)
talk_state = 2
else
selfSay('I need 60,000 gold coins to give you the {training axe}. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 2 then
talk_state = 0
if getPlayerItemCount(cid,2160) >= 6 or getPlayerItemCount(cid,2152) >= 600 then
if doPlayerRemoveItem(cid,2160, 6) or doPlayerRemoveItem(cid,2152, 600) == TRUE then
selfSay(done, cid)
local xa = doPlayerAddItem(cid, 2388, 1)
doItemSetAttribute(xa, "aid", 1443)
doItemSetAttribute(xa, "charges", 50)
end
else
selfSay(item, cid)
end
-- club---
elseif msgcontains(msg, 'training club') then
if getPlayerItemCount(cid,2160) >= 6 or getPlayerItemCount(cid,2152) >= 600 then
selfSay('Are you willing to pay 60,000 gold coins for {training club}?', cid)
talk_state = 3
else
selfSay('I need 60,000 gold coins to give you the {training club}. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 3 then
talk_state = 0
if getPlayerItemCount(cid,2160) >= 6 or getPlayerItemCount(cid,2152) >= 600 then
if doPlayerRemoveItem(cid,2160, 6) or doPlayerRemoveItem(cid,2152, 600) == TRUE then
selfSay(done, cid)
local xb = doPlayerAddItem(cid, 2382, 1)
doItemSetAttribute(xb, "aid", 1443)
doItemSetAttribute(xb, "charges", 50)
end
else
selfSay(item, cid)
end
-- pally--
elseif msgcontains(msg, 'training distance') then
if getPlayerItemCount(cid,2160) >= 6 or getPlayerItemCount(cid,2152) >= 600 then
selfSay('Are you willing to pay 60,000 gold coins for {training distance}?', cid)
talk_state = 4
else
selfSay('I need 60,000 gold coins to give you the {training distance}. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 4 then
talk_state = 0
if getPlayerItemCount(cid,2160) >= 6 or getPlayerItemCount(cid,2152) >= 600 then
if doPlayerRemoveItem(cid,2160, 6) or doPlayerRemoveItem(cid,2152, 600) == TRUE then
selfSay(done, cid)
local xc = doPlayerAddItem(cid, 2404, 1)
doItemSetAttribute(xc, "aid", 1443)
doItemSetAttribute(xc, "charges", 50)
end
else
selfSay(item, cid)
end
--druid--
elseif msgcontains(msg, 'training druid') then
if getPlayerItemCount(cid,2160) >= 6 or getPlayerItemCount(cid,2152) >= 600 then
selfSay('Are you willing to pay 60,000 gold coins for {training druid}?', cid)
talk_state = 5
else
selfSay('I need 60,000 gold coins to give you the {training druid}. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 5 then
talk_state = 0
if getPlayerItemCount(cid,2160) >= 6 or getPlayerItemCount(cid,2152) >= 600 then
if doPlayerRemoveItem(cid,2160, 6) or doPlayerRemoveItem(cid,2152, 600) == TRUE then
selfSay(done, cid)
local xd = doPlayerAddItem(cid, 2401, 1)
doItemSetAttribute(xd, "aid", 1443)
doItemSetAttribute(xd, "charges", 50)
end
else
selfSay(item, cid)
end
--- sorcerer--
elseif msgcontains(msg, 'training sorcerer') then
if getPlayerItemCount(cid,2160) >= 6 or getPlayerItemCount(cid,2152) >= 600 then
selfSay('Are you willing to pay 60,000 gold coins for {training sorcerer}?', cid)
talk_state = 6
else
selfSay('I need 60,000 gold coins to give you the {training sorcerer}. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 6 then
talk_state = 0
if getPlayerItemCount(cid,2160) >= 6 or getPlayerItemCount(cid,2152) >= 600 then
if doPlayerRemoveItem(cid,2160, 6) or doPlayerRemoveItem(cid,2152, 600) == TRUE then
selfSay(done, cid)
local xf = doPlayerAddItem(cid, 2433, 1)
doItemSetAttribute(xf, "aid", 1443)
doItemSetAttribute(xf, "charges", 50)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'stone skin amulet') then
if getPlayerItemCount(cid,2160) >= 1 or getPlayerItemCount(cid,2152) >= 100 then
selfSay('Are you willing to pay 10,000 gold coins for {stone skin amulet}?', cid)
talk_state = 7
else
selfSay('I need 10,000 gold coins to give you the {stone skin amulet}. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 7 then
talk_state = 0
if getPlayerItemCount(cid,2160) >= 1 or getPlayerItemCount(cid,2152) >= 100 then
if doPlayerRemoveItem(cid,2160, 1) or doPlayerRemoveItem(cid,2152, 100) == TRUE then
selfSay(done, cid)
local aq = doPlayerAddItem(cid, 2197, 1)
doItemSetAttribute(aq, "charges", 5)
end
else
selfSay(item, cid)
end
-- axe ---
elseif msgcontains(msg, 'dragon necklace') then
if getPlayerItemCount(cid,2148) >= 200 or getPlayerItemCount(cid,2152) >= 2 then
selfSay('Are you willing to pay 200 gold coins for {dragon necklace}?', cid)
talk_state = 8
else
selfSay('I need 200 gold coins to give you the {dragon necklace}. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 8 then
talk_state = 0
if getPlayerItemCount(cid,2148) >= 200 or getPlayerItemCount(cid,2152) >= 2 then
if doPlayerRemoveItem(cid,2148, 200) or doPlayerRemoveItem(cid,2152, 2) == TRUE then
selfSay(done, cid)
local aw = doPlayerAddItem(cid, 2201, 1)
doItemSetAttribute(aw, "charges", 200)
end
else
selfSay(item, cid)
end
-- club---
elseif msgcontains(msg, 'garlic necklace') then
if getPlayerItemCount(cid,2148) >= 200 or getPlayerItemCount(cid,2152) >= 2 then
selfSay('Are you willing to pay 200 gold coins for {garlic necklace}?', cid)
talk_state = 9
else
selfSay('I need 200 gold coins to give you the {garlic necklace}. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 9 then
talk_state = 0
if getPlayerItemCount(cid,2148) >= 200 or getPlayerItemCount(cid,2152) >= 2 then
if doPlayerRemoveItem(cid,2148, 200) or doPlayerRemoveItem(cid,2152, 2) == TRUE then
selfSay(done, cid)
local ae = doPlayerAddItem(cid, 2199, 1)
doItemSetAttribute(ae, "charges", 150)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 6) then
selfSay('Farewell.')
talk_state = 0
end
-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
I'll try it, see if it works with mana potionsI use this NPC to sell items with charges, just change the ids and the charge ammounts
Lua: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 item = 'You do not have the required items.' done = 'Here you are.' function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end if msgcontains(msg, 'offer') then selfSay('Here you can buy the following training items: {training sword}, {training axe}, {training club}, {training distance}, {training druid}, and {training sorcerer}. Also I sell the following amulets: {stone skin amulet}, {dragon necklace} and {garlic necklace}.', cid) elseif msgcontains(msg, 'training sword') then if getPlayerItemCount(cid,2160) >= 6 or getPlayerItemCount(cid,2152) >= 600 then selfSay('Are you willing to pay 60,000 gold coins for {training sword}?', cid) talk_state = 1 else selfSay('I need 60,000 gold coins to give you the {training sword}. Come back when you have them.', cid) talk_state = 0 end elseif msgcontains(msg, 'yes') and talk_state == 1 then talk_state = 0 if getPlayerItemCount(cid,2160) >= 6 or getPlayerItemCount(cid,2152) >= 600 then if doPlayerRemoveItem(cid,2160, 6) or doPlayerRemoveItem(cid,2152, 600) == TRUE then selfSay(done, cid) local xx = doPlayerAddItem(cid, 2376, 1) doItemSetAttribute(xx, "aid", 1443) doItemSetAttribute(xx, "charges", 50) end else selfSay(item, cid) end -- axe --- elseif msgcontains(msg, 'training axe') then if getPlayerItemCount(cid,2160) >= 6 or getPlayerItemCount(cid,2152) >= 600 then selfSay('Are you willing to pay 60,000 gold coins for {training axe}?', cid) talk_state = 2 else selfSay('I need 60,000 gold coins to give you the {training axe}. Come back when you have them.', cid) talk_state = 0 end elseif msgcontains(msg, 'yes') and talk_state == 2 then talk_state = 0 if getPlayerItemCount(cid,2160) >= 6 or getPlayerItemCount(cid,2152) >= 600 then if doPlayerRemoveItem(cid,2160, 6) or doPlayerRemoveItem(cid,2152, 600) == TRUE then selfSay(done, cid) local xa = doPlayerAddItem(cid, 2388, 1) doItemSetAttribute(xa, "aid", 1443) doItemSetAttribute(xa, "charges", 50) end else selfSay(item, cid) end -- club--- elseif msgcontains(msg, 'training club') then if getPlayerItemCount(cid,2160) >= 6 or getPlayerItemCount(cid,2152) >= 600 then selfSay('Are you willing to pay 60,000 gold coins for {training club}?', cid) talk_state = 3 else selfSay('I need 60,000 gold coins to give you the {training club}. Come back when you have them.', cid) talk_state = 0 end elseif msgcontains(msg, 'yes') and talk_state == 3 then talk_state = 0 if getPlayerItemCount(cid,2160) >= 6 or getPlayerItemCount(cid,2152) >= 600 then if doPlayerRemoveItem(cid,2160, 6) or doPlayerRemoveItem(cid,2152, 600) == TRUE then selfSay(done, cid) local xb = doPlayerAddItem(cid, 2382, 1) doItemSetAttribute(xb, "aid", 1443) doItemSetAttribute(xb, "charges", 50) end else selfSay(item, cid) end -- pally-- elseif msgcontains(msg, 'training distance') then if getPlayerItemCount(cid,2160) >= 6 or getPlayerItemCount(cid,2152) >= 600 then selfSay('Are you willing to pay 60,000 gold coins for {training distance}?', cid) talk_state = 4 else selfSay('I need 60,000 gold coins to give you the {training distance}. Come back when you have them.', cid) talk_state = 0 end elseif msgcontains(msg, 'yes') and talk_state == 4 then talk_state = 0 if getPlayerItemCount(cid,2160) >= 6 or getPlayerItemCount(cid,2152) >= 600 then if doPlayerRemoveItem(cid,2160, 6) or doPlayerRemoveItem(cid,2152, 600) == TRUE then selfSay(done, cid) local xc = doPlayerAddItem(cid, 2404, 1) doItemSetAttribute(xc, "aid", 1443) doItemSetAttribute(xc, "charges", 50) end else selfSay(item, cid) end --druid-- elseif msgcontains(msg, 'training druid') then if getPlayerItemCount(cid,2160) >= 6 or getPlayerItemCount(cid,2152) >= 600 then selfSay('Are you willing to pay 60,000 gold coins for {training druid}?', cid) talk_state = 5 else selfSay('I need 60,000 gold coins to give you the {training druid}. Come back when you have them.', cid) talk_state = 0 end elseif msgcontains(msg, 'yes') and talk_state == 5 then talk_state = 0 if getPlayerItemCount(cid,2160) >= 6 or getPlayerItemCount(cid,2152) >= 600 then if doPlayerRemoveItem(cid,2160, 6) or doPlayerRemoveItem(cid,2152, 600) == TRUE then selfSay(done, cid) local xd = doPlayerAddItem(cid, 2401, 1) doItemSetAttribute(xd, "aid", 1443) doItemSetAttribute(xd, "charges", 50) end else selfSay(item, cid) end --- sorcerer-- elseif msgcontains(msg, 'training sorcerer') then if getPlayerItemCount(cid,2160) >= 6 or getPlayerItemCount(cid,2152) >= 600 then selfSay('Are you willing to pay 60,000 gold coins for {training sorcerer}?', cid) talk_state = 6 else selfSay('I need 60,000 gold coins to give you the {training sorcerer}. Come back when you have them.', cid) talk_state = 0 end elseif msgcontains(msg, 'yes') and talk_state == 6 then talk_state = 0 if getPlayerItemCount(cid,2160) >= 6 or getPlayerItemCount(cid,2152) >= 600 then if doPlayerRemoveItem(cid,2160, 6) or doPlayerRemoveItem(cid,2152, 600) == TRUE then selfSay(done, cid) local xf = doPlayerAddItem(cid, 2433, 1) doItemSetAttribute(xf, "aid", 1443) doItemSetAttribute(xf, "charges", 50) end else selfSay(item, cid) end elseif msgcontains(msg, 'stone skin amulet') then if getPlayerItemCount(cid,2160) >= 1 or getPlayerItemCount(cid,2152) >= 100 then selfSay('Are you willing to pay 10,000 gold coins for {stone skin amulet}?', cid) talk_state = 7 else selfSay('I need 10,000 gold coins to give you the {stone skin amulet}. Come back when you have them.', cid) talk_state = 0 end elseif msgcontains(msg, 'yes') and talk_state == 7 then talk_state = 0 if getPlayerItemCount(cid,2160) >= 1 or getPlayerItemCount(cid,2152) >= 100 then if doPlayerRemoveItem(cid,2160, 1) or doPlayerRemoveItem(cid,2152, 100) == TRUE then selfSay(done, cid) local aq = doPlayerAddItem(cid, 2197, 1) doItemSetAttribute(aq, "charges", 5) end else selfSay(item, cid) end -- axe --- elseif msgcontains(msg, 'dragon necklace') then if getPlayerItemCount(cid,2148) >= 200 or getPlayerItemCount(cid,2152) >= 2 then selfSay('Are you willing to pay 200 gold coins for {dragon necklace}?', cid) talk_state = 8 else selfSay('I need 200 gold coins to give you the {dragon necklace}. Come back when you have them.', cid) talk_state = 0 end elseif msgcontains(msg, 'yes') and talk_state == 8 then talk_state = 0 if getPlayerItemCount(cid,2148) >= 200 or getPlayerItemCount(cid,2152) >= 2 then if doPlayerRemoveItem(cid,2148, 200) or doPlayerRemoveItem(cid,2152, 2) == TRUE then selfSay(done, cid) local aw = doPlayerAddItem(cid, 2201, 1) doItemSetAttribute(aw, "charges", 200) end else selfSay(item, cid) end -- club--- elseif msgcontains(msg, 'garlic necklace') then if getPlayerItemCount(cid,2148) >= 200 or getPlayerItemCount(cid,2152) >= 2 then selfSay('Are you willing to pay 200 gold coins for {garlic necklace}?', cid) talk_state = 9 else selfSay('I need 200 gold coins to give you the {garlic necklace}. Come back when you have them.', cid) talk_state = 0 end elseif msgcontains(msg, 'yes') and talk_state == 9 then talk_state = 0 if getPlayerItemCount(cid,2148) >= 200 or getPlayerItemCount(cid,2152) >= 2 then if doPlayerRemoveItem(cid,2148, 200) or doPlayerRemoveItem(cid,2152, 2) == TRUE then selfSay(done, cid) local ae = doPlayerAddItem(cid, 2199, 1) doItemSetAttribute(ae, "charges", 150) end else selfSay(item, cid) end elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 6) then selfSay('Farewell.') talk_state = 0 end -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself. return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
No i try your script, with the same ids, and dont work@nefinoo That happens because potions has stackable value direct from Object Builder. If you expect to use an object as a charges object first you need to change the item flags (in this case you will have to use a customized .otb, .spr and .dat).
Or just use a rune as a potion, regards!