• 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!

Script

Look at the script now, I have fixed it already.

Code:
local items = {1000,2000,3000}
for i = 1, #items do
	if(getPlayerItemCount(cid,items[i]) > 0) then 
		......
	end
end
 
look my script :
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

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 creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
		return false
	end

	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

	if(msgcontains(msg, 'addon doll')) then
		selfSay('If you want to get addon doll for doll part?', cid)
		talkState[talkUser] = 1
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
	  local items = {9694,9695,9696,9697,9698,9699}
    for i = 1, #items do
	          if(getPlayerItemCount(cid,items[i]) > 0) then 
		  if(doPlayerRemoveMoney(cid, 0) == TRUE) then
				doPlayerRemoveItem(cid, 9694, 1,9695, 1,9696, 1,9697, 1,9698, 1,9699, 1)
				doPlayerAddItem(cid, 9693)
				selfSay('Here you are.', cid)
			else
				selfSay('Sorry, you don\'t have enough gold.', cid)
			end
		else
			selfSay('Sorry, you don\'t have the item.', cid)
		end
		talkState[talkUser] = 0
	elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
		talkState[talkUser] = 0
		selfSay('Ok then.', cid)
  end

	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

and error
Code:
[18/06/2010 17:41:34] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/jester doll.lua
[18/06/2010 17:41:34] data/npc/scripts/jester doll.lua:36: 'end' expected (to close 'for' at line 23) near 'elseif'
 
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

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 creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
	return false
end

local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	if(msgcontains(msg, 'addon doll')) then
		selfSay('If you want to get addon doll for doll part?', cid)
		talkState[talkUser] = 1
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
	local items = {9694,9695,9696,9697,9698,9699}
		for i = 1, #items do
			if(getPlayerItemCount(cid,items[i]) > 0) then 
				if doPlayerRemoveMoney(cid, 0) then
					doPlayerRemoveItem(cid, 9694, 1,9695, 1,9696, 1,9697, 1,9698, 1,9699, 1)
					doPlayerAddItem(cid, 9693)
					selfSay('Here you are.', cid)
				else
					selfSay('Sorry, you don\'t have enough gold.', cid)
					talkState[talkUser] = 0
				end
			else
				selfSay('Sorry, you don\'t have the item.', cid)
				talkState[talkUser] = 0
			end
		end
	elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
		talkState[talkUser] = 0
		selfSay('Ok then.', cid)
	end
	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
lol npc give 6 addon doll no 1 ;( and dont remove items from bp no work plz help :blink:

and error
Code:
[18/06/2010 17:53:07] Lua Script Error: [Npc interface] 
[18/06/2010 17:53:07] data/npc/scripts/jester doll.lua:onCreatureSay

[18/06/2010 17:53:07] luaDoPlayerRemoveItem(). Player not found

[18/06/2010 17:53:07] Lua Script Error: [Npc interface] 
[18/06/2010 17:53:07] data/npc/scripts/jester doll.lua:onCreatureSay

[18/06/2010 17:53:07] luaDoPlayerRemoveItem(). Player not found

[18/06/2010 17:53:07] Lua Script Error: [Npc interface] 
[18/06/2010 17:53:07] data/npc/scripts/jester doll.lua:onCreatureSay

[18/06/2010 17:53:07] luaDoPlayerRemoveItem(). Player not found

[18/06/2010 17:53:07] Lua Script Error: [Npc interface] 
[18/06/2010 17:53:07] data/npc/scripts/jester doll.lua:onCreatureSay

[18/06/2010 17:53:07] luaDoPlayerRemoveItem(). Player not found

[18/06/2010 17:53:07] Lua Script Error: [Npc interface] 
[18/06/2010 17:53:07] data/npc/scripts/jester doll.lua:onCreatureSay

[18/06/2010 17:53:07] luaDoPlayerRemoveItem(). Player not found

[18/06/2010 17:53:07] Lua Script Error: [Npc interface] 
[18/06/2010 17:53:07] data/npc/scripts/jester doll.lua:onCreatureSay

[18/06/2010 17:53:07] luaDoPlayerRemoveItem(). Player not found
 
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 Topic = {}
function creatureSayCallback(cid, type, msg)
	if msgcontains(msg,'addon doll') then
		npcHandler:say('Do you want to exchange an addon doll for doll parts?',cid)
		Topic[cid] = 1
	elseif Topic[cid] == 1 then
		if msgcontains(msg,'yes') then
		local items = {5897,2544}
			for i = 1, #items do
				if doPlayerRemoveItem(cid,items[i],1) then
					if doPlayerRemoveMoney(cid,0) then
						doPlayerGiveItem(cid,9693,1)
						npcHandler:say('Here you go.',cid)
					else
						npcHandler:say('You don\'t have enough money.',cid)
					end
				else
					npcHandler:say('You don\'t have the right items.',cid)
				end
			end
		else
			npcHandler:say('Than not.',cid)
			npcHandler:releaseFocus(cid)
		end
	end
	return true
end
npcHandler:setMessage(MESSAGE_WALKAWAY, "Goodbye")
npcHandler:setMessage(MESSAGE_FAREWELL, "Goodbye..")
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Johny Johnson" script="quests\ridgewood\johnyjohnson.lua" walkinterval="8000" floorchange="0">
	<health now="100" max="100"/>
	<look type="128" head="57" body="115" legs="58" feet="114" addons="3"/>
	<parameters>
      <parameter key="message_greet" value="Hey.. you, can you {help} me out of here?" />
    </parameters>
</npc>

make the npc like this.

{} will make something cyan.
 
ey this script good but plx fix it because npc give 6 addon doll no 1 and answer 6
here you are.
..
look:

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 Topic = {}
function creatureSayCallback(cid, type, msg)
	if msgcontains(msg,'addon doll') then
		npcHandler:say('Do you want to exchange an addon doll for doll parts?',cid)
		Topic[cid] = 1
	elseif Topic[cid] == 1 then
		if msgcontains(msg,'yes') then
		local items = {9694,9695,9696,9697,9698,9699}
			for i = 1, #items do
				if doPlayerRemoveItem(cid,items[i],1) then
					if doPlayerRemoveMoney(cid,0) then
						doPlayerGiveItem(cid,9693,1)
						npcHandler:say('Here you go.',cid)
					else
						npcHandler:say('You don\'t have enough money.',cid)
					end
				else
					npcHandler:say('You don\'t have the right items.',cid)
				end
			end
		else
			npcHandler:say('Than not.',cid)
			npcHandler:releaseFocus(cid)
		end
	end
	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
Back
Top