Darqneez
ShaC-Ohhhh
hello, I have a problem, my npc is not working correctly, I don't have any errors, can someone explain me why it's not working? Here's code, NPC gives player outfit and 2 addons. To obtain addons players need outfit first.
Edit: I have repaired some mistakes, but script doesnt work how I want it to do. When I use function AssassinOutfit I get outfit + first addon, and I want to get only outfit. Then when I Use function
AssassinSecond, npc tells me 'You need outfit to obtain this addon!'.
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
assassinoutfit = 21025
assassin = 22025
newoutfit = 'Here you are. Enjoy your new outfit!'
newaddon = 'Here you are. Enjoy your new addon!'
noitems = 'Sorry, but you don\'t have required items.'
already = 'You already have this addon!'
already1 = 'You already have this outfit!'
needoutfit = 'You need outfit to obtain this addon!'
-- ASSASSIN START --
function AssassinOutfit(cid, message, keywords, parameters, node)
if(not npcHandler:isFocused(cid)) then
return false
end
if isPremium(cid) then
outfit = getPlayerStorageValue(cid,assassinoutfit)
if getPlayerSex(cid) == 0 then
if outfit == -1 then
if getPlayerItemCount(cid,5898) >= 30 and getPlayerItemCount(cid,5882) >= 10 and getPlayerItemCount(cid,5881) >= 30 and getPlayerItemCount(cid,5895) >= 20 and getPlayerItemCount(cid,5905) >= 20 and getPlayerItemCount(cid,5906) >= 10 and getPlayerItemCount(cid,5885) >= 1 then
if doPlayerRemoveItem(cid,5898,30) and doPlayerRemoveItem(cid,5882,10) and doPlayerRemoveItem(cid,5881,30) and doPlayerRemoveItem(cid,5895,20) and doPlayerRemoveItem(cid,5905,20) and doPlayerRemoveItem(cid,5906,10) and doPlayerRemoveItem(cid,5885,1) then
selfSay(newoutfit, cid)
doSendMagicEffect(getCreaturePosition(cid), 13)
doPlayerAddOutfit(cid, 156, 1)
setPlayerStorageValue(cid,outfit,1)
end
else
selfSay(noitems, cid)
end
else
selfSay(already1, cid)
end
elseif getPlayerSex(cid) == 1 then
if outfit == -1 then
if getPlayerItemCount(cid,5898) >= 30 and getPlayerItemCount(cid,5882) >= 10 and getPlayerItemCount(cid,5881) >= 30 and getPlayerItemCount(cid,5895) >= 20 and getPlayerItemCount(cid,5905) >= 20 and getPlayerItemCount(cid,5906) >= 10 and getPlayerItemCount(cid,5885) >= 1 then
if doPlayerRemoveItem(cid,5898,30) and doPlayerRemoveItem(cid,5882,10) and doPlayerRemoveItem(cid,5881,30) and doPlayerRemoveItem(cid,5895,20) and doPlayerRemoveItem(cid,5905,20) and doPlayerRemoveItem(cid,5906,10) and doPlayerRemoveItem(cid,5885,1) then
selfSay(newoutfit, cid)
doSendMagicEffect(getCreaturePosition(cid), 13)
doPlayerAddOutfit(cid, 152, 1)
setPlayerStorageValue(cid,outfit,1)
end
else
selfSay(noitems, cid)
end
else
selfSay(already1, cid)
end
else
selfSay('you don\'t have sex Oo', cid)
end
end
end
function AssassinFirst(cid, message, keywords, parameters, node)
if(not npcHandler:isFocused(cid)) then
return false
end
if isPremium(cid) then
addon = getPlayerStorageValue(cid,assassin)
outfit = getPlayerStorageValue(cid,assassinoutfit)
if outfit == 1 then
if addon == -1 then
if getPlayerItemCount(cid,5909) >= 50 and getPlayerItemCount(cid,5910) >= 50 and getPlayerItemCount(cid,5911) >= 50 and getPlayerItemCount(cid,5912) >= 50 and getPlayerItemCount(cid,5913) >= 50 and getPlayerItemCount(cid,5914) >= 50 and getPlayerItemCount(cid,5886) >= 10 then
if doPlayerRemoveItem(cid,5909,50) and doPlayerRemoveItem(cid,5910,50) and doPlayerRemoveItem(cid,5911,50) and doPlayerRemoveItem(cid,5912,50) and doPlayerRemoveItem(cid,5913,50) and doPlayerRemoveItem(cid,5914,50) and doPlayerRemoveItem(cid,5886,10) then
selfSay(newaddon, cid)
doSendMagicEffect(getCreaturePosition(cid), 13)
doPlayerAddAddons(cid, 152, 1)
doPlayerAddAddons(cid, 156, 1)
setPlayerStorageValue(cid,assassin,1)
end
else
selfSay(noitems, cid)
end
else
selfSay(already, cid)
end
else
selfSay(needoutfit, cid)
end
end
end
function AssassinSecond(cid, message, keywords, parameters, node)
if(not npcHandler:isFocused(cid)) then
return false
end
if isPremium(cid) then
addon = getPlayerStorageValue(cid,assassin+1)
outfit = getPlayerStorageValue(cid,assassinoutfit)
if outfit == 1 then
if addon == -1 then
if getPlayerItemCount(cid,5804) >= 1 and getPlayerItemCount(cid,5930) >= 1 then
if doPlayerRemoveItem(cid,5804,1) and doPlayerRemoveItem(cid,5930,1) then
selfSay(newaddon, cid)
doSendMagicEffect(getCreaturePosition(cid), 13)
doPlayerAddAddons(cid, 152, 2)
doPlayerAddAddons(cid, 156, 2)
setPlayerStorageValue(cid,assassin+1,1)
end
else
selfSay(noitems, cid)
end
else
selfSay(already, cid)
end
else
selfSay(needoutfit, cid)
end
end
end
-- ASSASSIN END --
node1 = keywordHandler:addKeyword({'assassin outfit'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'To achieve the assassin outfit you need to give me 30 beholder eyes, 10 red dragon scales, 30 lizard scales, 20 fish fins, 20 vampire dusts, 10 demon dusts and Warrior\'s sweat. Do you have them with you?'})
node1:addChildKeyword({'yes'}, AssassinOutfit, {})
node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back when you got all neccessary items.', reset = true})
node2 = keywordHandler:addKeyword({'first assassin addon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'To achieve first assassin addon you need to give me 50 blue piece of cloth, 50 green piece of cloth, 50 red piece of cloth, 50 brown piece of cloth, 50 yellow piece of cloth, 50 white piece of cloth and 10 spider silk yarns. Do you have them with you?'})
node2:addChildKeyword({'yes'}, AssassinFirst, {})
node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back when you got all neccessary items.', reset = true})
node3 = keywordHandler:addKeyword({'second assassin addon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'To achieve second assassin addon you need to give me a nose ring and a behemoth claw. Do you have them with you?'})
node3:addChildKeyword({'yes'}, AssassinSecond, {})
node3:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back when you got all neccessary items.', reset = true})
npcHandler:addModule(FocusModule:new())
AssassinSecond, npc tells me 'You need outfit to obtain this addon!'.
Last edited: