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

Quest NPC

Emile

New Member
Joined
Dec 19, 2007
Messages
5
Reaction score
0
Code:
local focus = 0
local talk_start = 0
local target = 0
local days = 0

function onThingMove(creature, thing, oldpos, oldstackpos)

end


function onCreatureAppear(creature)

end


function onCreatureDisappear(cid, pos)
  	if focus == cid then
          selfSay('Good bye then.')
          focus = 0
          talk_start = 0
  	end
end


function onCreatureTurn(creature)

end


function msgcontains(txt, str)
  	return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
end


function onCreatureSay(cid, type, msg)
  	msg = string.lower(msg)

  	if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
 		selfSay('Hello ' .. getCreatureName(cid) .. '! I need some help.')
 		focus = cid
 		talk_start = os.clock()

	elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
  		selfSay('Sorry, ' .. getCreatureName(cid) .. '! I talk to you in a minute.')

  	elseif focus == cid then
		talk_start = os.clock()

		if msgcontains(msg, 'help') or msgcontains(msg, 'quest') then
 			if getPlayerStorageValue(cid,50088) == -1 then
				selfSay('Do you want to help me?')
				talk_state = 1
				else
				selfSay('I already sent you on my quest.')
				talk_state = 0
			end

		elseif msgcontains(msg, 'sheet') or msgcontains(msg, 'music') then
 			if getPlayerStorageValue(cid,50088) == 1 then
			selfSay('Do you have the music sheets?')
			talk_state = 2
			else
			selfSay('You already did my quest')			
			talk_state = 0
			end

		elseif talk_state == 1 then
			if msgcontains(msg, 'yes') then
					setPlayerStorageValue(cid,50088, 1)
					selfSay('Get the 3 different music sheets from 3 different kings')
					selfSay('They are in the human dimension')
				else
					selfSay('Then not.')
				end
 			end
			talk_state = 0

		elseif talk_state == 3 then
			sheet1 = getPlayerItemCount(cid,6087)
			sheet2 = getPlayerItemCount(cid,6088)
			sheet3 =getPlayerItemCount(cid,6089)
			if msgcontains(msg, 'yes') then
				if sheet1 >= 1 and sheet2 >= 1 and sheet3 >=1 then
					doPlayerRemoveItem (cid,6087,1)
					doPlayerRemoveItem (cid,6088,1)
					doPlayerRemoveItem (cid,6089,1)
					doPlayerAddItem (cid,2127,1)
					selfSay('Here is your reward!')
					selfSay('Youll have to figure the secret out yourself.')
 					focus = 0
				else
					selfSay('Fool, You dont have all the sheets!')
					selfSay('Get outta here')
 					focus = 0
end
			end
			talk_state = 0

  		elseif msgcontains(msg, 'bye')  and getDistanceToCreature(cid) < 4 then
  			selfSay('Good bye, ' .. creatureGetName(cid) .. '!')
  			focus = 0
  			talk_start = 0
  		end
end


function onCreatureChangeOutfit(creature)

end


function onThink()
	doNpcSetCreatureFocus(focus)
  	if (os.clock() - talk_start) > 30 then
  		if focus > 0 then
  			selfSay('Next Please...')
  		end
  			focus = 0
  	end
 	if focus ~= 0 then
 		if getDistanceToCreature(focus) > 5 then
 			selfSay('Good bye then.')
 			focus = 0
 		end
  	end
end

Whats wrong:
Code:
[COLOR="blue"]19:54 GOD Wiggle Jiggle [105]: hi
19:54 Crazy Old Man: Hello GOD Wiggle Jiggle! I need some help.
19:55 GOD Wiggle Jiggle [105]: help
19:55 Crazy Old Man: Do you want to help me?
19:55 GOD Wiggle Jiggle [105]: yes
19:55 GOD Wiggle Jiggle [105]: .....
19:55 Crazy Old Man: Next Please...[/COLOR]

[COLOR="Red"]20:03 GOD Wiggle Jiggle [105]: hi
20:03 Crazy Old Man: Hello GOD Wiggle Jiggle! I need some help.
20:03 GOD Wiggle Jiggle [105]: music sheets
20:03 Crazy Old Man: You already did my quest[/COLOR]

after yes it doesnt say what it is supposed to say...
it also does NOT give errors
can someone help me?

PS:mad:Moderator, can you put like help in front of the thread name? thx in advance
 
Last edited:
PHP:
local focus = 0
local talk_start = 0
local target = 0
local days = 0

function onThingMove(creature, thing, oldpos, oldstackpos)

end


function onCreatureAppear(creature)

end


function onCreatureDisappear(cid, pos)
  	if focus == cid then
          selfSay('Good bye then.')
          focus = 0
          talk_start = 0
  	end
end


function onCreatureTurn(creature)

end


function msgcontains(txt, str)
  	return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
end


function onCreatureSay(cid, type, msg)
  	msg = string.lower(msg)

  	if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
 		selfSay('Hello ' .. getCreatureName(cid) .. '! I need some help.')
 		focus = cid
 		talk_start = os.clock()

	elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
  		selfSay('Sorry, ' .. getCreatureName(cid) .. '! I talk to you in a minute.')

  	elseif focus == cid then
		talk_start = os.clock()

		if msgcontains(msg, 'help') or msgcontains(msg, 'quest') then
 			if getPlayerStorageValue(cid,50088) == -1 then
				selfSay('Do you want to help me?')
				talk_state = 1
			else
				selfSay('I already gave you my Quest.')
				talk_state = 0
			end

		elseif msgcontains(msg, 'sheet') or msgcontains(msg, 'music') then
 			if getPlayerStorageValue(cid,50088) == 1 then
				selfSay('Do you have the music sheets?')
				talk_state = 2
			elseif getPlayerStorageValue(cid,50088) > 1
				selfSay('You already did my quest')			
				talk_state = 0
			end

		elseif talk_state == 1 then
			if msgcontains(msg, 'yes') then
				selfSay('Get the 3 different music sheets from 3 different kings. They are in the human dimension.')
				setPlayerStorageValue(cid,50088, 1)
				talk_state = 0
			else
				selfSay('So shall it be chicken.')
				talk_state = 0
			end

		elseif talk_state == 2 then
			sheet1 = getPlayerItemCount(cid,6087)
			sheet2 = getPlayerItemCount(cid,6088)
			sheet3 = getPlayerItemCount(cid,6089)
			if msgcontains(msg, 'yes') then
				if sheet1 >= 1 and sheet2 >= 1 and sheet3 >=1 then
					doPlayerRemoveItem (cid,6087,1)
					doPlayerRemoveItem (cid,6088,1)
					doPlayerRemoveItem (cid,6089,1)
					doPlayerAddItem (cid,2127,1)
					selfSay('Here is your reward. You have to figure the secret out yourself.')
					talk_state = 0
 					focus = 0
				else
					selfSay('Fool, You dont have all the sheets! Get out of here.')
					talk_state = 0
 					focus = 0
				end
			end

  		elseif msgcontains(msg, 'bye')  and getDistanceToCreature(cid) < 4 then
  			selfSay('Good bye, ' .. creatureGetName(cid) .. '!')
  			focus = 0
  			talk_start = 0
  		end
end


function onCreatureChangeOutfit(creature)

end


function onThink()
	doNpcSetCreatureFocus(focus)
  	if (os.clock() - talk_start) > 30 then
  		if focus > 0 then
  			selfSay('Next Please...')
  		end
  			focus = 0
  	end
 	if focus ~= 0 then
 		if getDistanceToCreature(focus) > 5 then
 			selfSay('Good bye then.')
 			focus = 0
 		end
  	end
end

there you go :)
 
Back
Top