• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

NPC Exchange Npc

krille09

Belden
Joined
Aug 15, 2007
Messages
4,892
Reaction score
55
Location
Stockholm, Sweden
PHP:
/* Script made by krille09 (exchange npc) */
local focus = 0
local talk_start = 0
local target = 0
local following = false
local attacking = false

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)
end

  	if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
  		selfSay('Great to meet you again, ' .. creatureGetName(cid) .. '! I can exchange mystic turban for 1 blue piece of cloth, red robe for 1 red piece of cloth, green tunics for 1 green piece of cloth. And i can exchange a crown armor for piece of royal steel, devil helmet for piece of hell steel, dragon shield for piece of draconian steel, giant sword for huge chunk of crude iron, soul orb for 10 infernal bolts. Also warrior helmet for 1 flask warrior sweat and 10 giant spider silk for spool of yarn.')
  		focus = cid
  		talk_start = os.clock()
end

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

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

		if msgcontains(msg, 'mystic turban') then
			selfSay('Do you want trade mystic turban for blue piece of cloth?')
			talk_state = 1	
end
		
		elseif talk_state == 1 then
			if msgcontains(msg, 'yes') then
			doPlayerRemoveItem(cid, 2663, 1)
			doPlayeraddItem(cid, 5912, 1)
			selfSay('Here you go, blue piece of cloth.')
				
				end

		if msgcontains(msg, 'red robe') then
			selfSay('Do you want trade red robe for red piece of cloth?')
			talk_state = 1	
end
		elseif talk_state == 1 then
			if msgcontains(msg, 'yes') then
			doPlayerRemoveItem(cid, 2655, 1)
			doPlayeraddItem(cid, 5911, 1)
			selfSay('Here you go, red piece of cloth.')
				
				end
 			end

		if msgcontains(msg, 'green tunic') then
			selfSay('Do you want trade green tunic for green piece of cloth?')
			talk_state = 1	
end
		elseif talk_state == 1 then
			if msgcontains(msg, 'yes') then
			doPlayerRemoveItem(cid, 2652, 1)
			doPlayeraddItem(cid, 5910, 1)
			selfSay('Here you go, green piece of cloth.')
				
				end
 			end
		if msgcontains(msg, ''crown armor) then
			selfSay('Do you want trade crown armor for royal steel?')
			talk_state = 1	
end
		elseif talk_state == 1 then
			if msgcontains(msg, 'yes') then
			doPlayerRemoveItem(cid, 2487, 1)
			doPlayeraddItem(cid, 5887, 1)
			selfSay('Here you go, royal steel.')
				
				end
 			end
		if msgcontains(msg, 'devil helmet') then
			selfSay('Do you want trade devil helmet for hell steel?')
			talk_state = 1	
end
		elseif talk_state == 1 then
			if msgcontains(msg, 'yes') then
			doPlayerRemoveItem(cid, 2462, 1)
			doPlayeraddItem(cid, 5888, 1)
			selfSay('Here you go, hell steel.')
				
				end
 			end
		if msgcontains(msg, 'dragon shield') then
			selfSay('Do you want trade dragon shield for draconian steel?')
			talk_state = 1	
end
		elseif talk_state == 1 then
			if msgcontains(msg, 'yes') then
			doPlayerRemoveItem(cid, 2516, 1)
			doPlayeraddItem(cid, 5889, 1)
			selfSay('Here you go, draconian steel.')
				
				end
 			end
		if msgcontains(msg, 'giant sword') then
			selfSay('Do you want trade giant sword for huge chunk of iron?')
			talk_state = 1	
end
		elseif talk_state == 1 then
			if msgcontains(msg, 'yes') then
			doPlayerRemoveItem(cid, 2393, 1)
			doPlayeraddItem(cid, 5892, 1)
			selfSay('Here you go, huge chunk of iron.')
				
				end
 			end
		if msgcontains(msg, 'soul orb') then
			selfSay('Do you want trade soul orb for 10 infernal bolts')
			talk_state = 1	
end
		elseif talk_state == 1 then
			if msgcontains(msg, 'yes') then
			doPlayerRemoveItem(cid, 5944, 1)
			doPlayeraddItem(cid, 6529, 10)
			selfSay('Here you go, 10 infernal bolts.')
				
				end
 			end
		if msgcontains(msg, 'warrior helmet') then
			selfSay('Do you want trade warrior helemt for warrior sweat?')
			talk_state = 1	
end
		elseif talk_state == 1 then
			if msgcontains(msg, 'yes') then
			doPlayerRemoveItem(cid, 2475, 1)
			doPlayeraddItem(cid, 5885, )
			selfSay('Here you go, warror sweat.')
				
				end
 			end
		if msgcontains(msg, 'giant spider silk) then
			selfSay('Do you want trade 10 giant spider silk for spool of yarn?')
			talk_state = 1	
end
		elseif talk_state == 1 then
			if msgcontains(msg, 'yes') then
			doPlayerRemoveItem(cid, 5879, 10)
			doPlayeraddItem(cid, 5886, 1)
			selfSay('Here you go, spool of yarn.')
				
				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
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

Hello, I need some help with my exchange npc I did for about 1 year ago, but forgot it:eek:

could anyone help me?
 
@Up
Trade a determined item for other item ?? lol
@OnTopic
Good script but the system is old xdd
 
Code:
        if msgcontains(msg, 'giant spider silk) then

BUGGGGGGGGGGGGGGGGGGGGGGGGGG :confused::(:rolleyes:
 
Back
Top