mam takie pytanie na szybko bo mi nie wychodzi jak jest npc Uzgod od obsidian knife to na rl gracz moze wykonac tylko raz to jak dobrze wiem
a ja bede mial tyle obsidianow ile draconian steelow lipa jest a nie moge storage dodac po yes i jak to na rl jest jak drugi raz do niego przyjdziesz z draconian stelem i lancem
a ja bede mial tyle obsidianow ile draconian steelow lipa jest a nie moge storage dodac po yes i jak to na rl jest jak drugi raz do niego przyjdziesz z draconian stelem i lancem
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
local item = 'You do not have the required items.'
local done = 'Here you have it.'
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
if msgcontains(msg, 'help') then
selfSay('You can here change {draconian steel} for {obsidian knife}.', cid)
elseif msgcontains(msg, 'obsidian knife') then
if getPlayerItemCount(cid,5889) >= 1 then
selfSay('You bringing me draconian steel and obsidian lance in exchange for obsidian knife?', cid)
talk_state = 2
else
selfSay('I need a draconian steel, to give you the obsidian knife. 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,2425) >= 1 then
if doPlayerRemoveItem(cid,2425,1) == true then
selfSay(done, cid)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'draconian steel') then
if getPlayerItemCount(cid,5889) >= 1 and getPlayerItemCount(cid,2425) >= 1then
selfSay('You bringing me draconian steel and obsidian lance in exchange for obsidian knife?', cid)
talk_state = 4
else
selfSay('I need draconian steel and obsidian lance, to give you the obsidian knife. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'rtyutyuoyal sttyufgeel') then
if getPlayerItemCount(cid,2487) >= 1 then
selfSay('Did you bring me the Crown Armor ?', cid)
talk_state = 8
else
selfSay('I need Crown Armor, to give you the royal steel. 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,2487) >= 1 then
if doPlayerRemoveItem(cid,2487,1) == true then
doPlayerAddItem(cid,5887,1)
selfSay(done, cid)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'helfhgl strtydeel') then
if getPlayerItemCount(cid,2462) >= 1 then
selfSay('Did you bring me the Devil Helmet ?', cid)
talk_state = 9
else
selfSay('I need a Devil Helmet, to give you the hell steel. 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,2462) >= 1 then
if doPlayerRemoveItem(cid,2462,1) == true then
doPlayerAddItem(cid,5888,1)
selfSay(done, cid)
end
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'yes') then
if talk_state == 1 then
if getPlayerItemCount(cid,5889) >= 1 then
if doPlayerRemoveItem(cid,5889, 1) == TRUE then
doPlayerAddItem(cid, 5908, 1)
end
end
selfSay(done, cid)
elseif talk_state == 2 then
if getPlayerItemCount(cid,5889) >= 1 then
if doPlayerRemoveItem(cid,5889, 1) == TRUE then
doPlayerAddItem(cid, 5908, 1)
end
end
selfSay(done, cid)
elseif talk_state == 3 then
if getPlayerItemCount(cid,5889) >= 1 then
if doPlayerRemoveItem(cid,5889, 1) == TRUE then
doPlayerAddItem(cid, 5908, 1)
end
end
selfSay(done, cid)
elseif talk_state == 4 then
if getPlayerItemCount(cid,5889) >= 1 then
if doPlayerRemoveItem(cid,5889, 1) == TRUE then
doPlayerAddItem(cid, 5908, 1)
end
end
selfSay(done, cid)
else
selfSay(item, cid)
end
elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
selfSay('Ok than.')
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())