• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Little NPC problem.

Sane Mei

New Member
Joined
Feb 21, 2010
Messages
56
Reaction score
0
Hello boiz and girlz!:D

Well, I have got a little problem in my NPC what I just wrote, I am not good yet in scripting and have no clue why it does not work like I want to:

NPC should check in this part if I got item id - 7839 if not he should say "You do not have this item.", else if I got item id 7839 he should remove me item id 7839 and add me item id 7840.

Script actually just add me item id 7840 but it's not checking if I got item id 7839:S Also how can I edit my script so NPC can just give me one time item id - 7840?

And this the code what does not work:

Code:
elseif msgcontains(msg, "arrow") then
itemstatus = doPlayerRemoveItem(cid,7839)
if itemstatus == -1 then
selfSay('You do not have this item...')
else
doPlayerAddItem(cid, 7840, 1)
selfSay('Thanks.')
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

+ my locals

Code:
local storage = 4325
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

What have I wrote wrong in this script?:S Please help me as fast as possible cuz I need this script so then I can keep doing my quest:P Without this NPC I have stopped doing this quest because he is not working as I wanted to work:S
 
Last edited:
If you tab your code it's easier to read..
This should work:
LUA:
elseif msgcontains(msg, "arrow") then
	if doPlayerRemoveItem(cid,7839) then
		doPlayerAddItem(cid, 7840, 1)
		selfSay('Thanks.')
	else
		selfSay('You do not have this item...')
	end
end
return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
@Summ
Thanks for your fast reply, alright I fixed it because you forgot to add "1" after 7839 in DoPlayerRemoveItem :P
Alright, how can I set NPC to give for a player item with 7840 id just one time?
And next time if players brings again 7839 item id to get 7840 once again NPC will say
" I already gave you my special arrow. "
 
Last edited:
Back
Top