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

Request!!

bomba

Member
Joined
Feb 26, 2008
Messages
635
Reaction score
7
Location
Brazil
Hi!
I want a script that makes a Broadcast when someone advance s to level 100,200 or 300.

^_^
I need Too!

I need NPC 2 lang:
**Trade NPC:
*Eng
Code:
Player: hi
NPC: Hello Player. I am [B][I](weapon man??)[/I][/B]!
Player: trade

*Br
Code:
Jogador: oi
NPC: Oi. eu eu sou o armeiro.
Jogador: trocar

**King NPC:
*Eng
Code:
Player: hiho king
NPC: Hello player. I am the king of city.
Player: fuck [B][U]or[/U][/B] fag [B][U]or[/U][/B] ass
NPC: [U][B]remove 99% of player's life[/B][/U]
Player: promotion [U][B]or[/B][/U] promot [U][B]or[/B][/U] promo
NPC: I can promote you for 20000 gold coins. Do you want me to promote you?
Player: yes
NPC: Congratulations! You are now promoted.

*Br
Code:
Jogador: oi king
NPC: Oi jogador. Eu sou o rei desta cidade.
Jogador: vsf [U][B]or[/B][/U] fdp [U][B]or[/B][/U] [U]tnc[/U]
NPC: [U][B]remove 99% of player's life[/B][/U]
Jogador: promover
NPC: Eu posso lhe promover por apenas 20000 gold coins. é isso que quer?
Player: sim
NPC: Parabéns!!

**Rachel NPC(like real tibia:
*Eng
Code:
Player: hi
Rachel: Hello player. I sell wands, rods and runes.
Player: trade

*Br
Code:
Jogador: oi
Rachel: Oii jogador. Eu vendo wands, rods e runas.
Jogador: trocar

15/10/2008> added: [Trade NPC_request], [King NPC_request].
16/10/2008> added: [Rachel NPC_request].
 
Last edited:
Those are just message edits of the NPC I already gave you before...

Trade: (trading window is handled by npcsystem itself)
Code:
focus = 0
talk_start = 0
target = 0
following = false
attacking = false
language = 0 -- 1 = english, 2 = pt-br
talkState = 0

function onThingMove(creature, thing, oldpos, oldstackpos)
end
function onCreatureAppear(creature)
end
function onCreatureDisappear(cid, pos)
  	if focus == cid then
		if language == 1 then
			selfSay('Good bye then.')
		elseif language == 2 then
			selfSay('At\é logo ' .. getCreatureName(cid) .. '.')
		end
		focus = 0
		talk_start = 0
		language = 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 focus == cid then
		talk_start = os.clock()
	end
  	if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
  		selfSay("Hello "..getCreatureName(cid)..". I am {weapon man??}!", cid)
  		focus = cid
  		talk_start = os.clock()
		language = 1
	elseif (msgcontains(msg, 'oi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
		selfSay('Oi. Eu sou o armeiro.', cid)
		focus = cid
		talk_start = os.clock()
		language = 2
	end
  	if msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
  		selfSay('Sorry, ' .. getCreatureName(cid) .. ', I talk to you in a minute.', cid)
	elseif msgcontains(msg, 'oi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
		selfSay('Espere! logo irei lhe atender, ' .. getCreatureName(cid) .. '.', cid)
	end
	if msgcontains(msg, 'bye') and language == 1 and getDistanceToCreature(cid) < 4 then
		selfSay('Good bye, ' .. getCreatureName(cid) .. '!', cid)
		focus = 0
		talk_start = 0
		language = 0
	elseif msgcontains(msg, 'tchau') and language == 2 and getDistanceToCreature(cid) < 4 then
		selfSay('Tchau, ' .. getCreatureName(cid) .. '!', cid)
		focus = 0
		talk_start = 0
		language = 0
	end
end

function onCreatureChangeOutfit(creature)

end

function onThink()
  	if (os.clock() - talk_start) > 30 then
  		if focus > 0 then
			if language == 1 then
				selfSay('Next Please...')
			elseif language == 2 then
				selfSay('O pr\óximo por favor.')
			end
  		end
		language = 0
  		focus = 0
  	end
 	if focus ~= 0 then
 		if getDistanceToCreature(focus) > 5 then
			if language == 1 then
				selfSay('Good bye then.')
			elseif language == 2 then
				selfSay('Tchau.')
			end
			language = 0
 			focus = 0
		end
	end
end

King:
Code:
focus = 0
talk_start = 0
target = 0
following = false
attacking = false
language = 0 -- 1 = english, 2 = pt-br
talkState = 0

function onThingMove(creature, thing, oldpos, oldstackpos)
end
function onCreatureAppear(creature)
end
function onCreatureDisappear(cid, pos)
  	if focus == cid then
		if language == 1 then
			selfSay('Good bye then.')
		elseif language == 2 then
			selfSay('At\é logo ' .. getCreatureName(cid) .. '.')
		end
		focus = 0
		talk_start = 0
		language = 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 focus == cid then
		talk_start = os.clock()
	end
  	if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
  		selfSay("Hello "..getCreatureName(cid)..". I am {weapon man??}!", cid)
  		focus = cid
  		talk_start = os.clock()
		language = 1
	elseif (msgcontains(msg, 'oi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
		selfSay('Oi. Eu sou o armeiro.', cid)
		focus = cid
		talk_start = os.clock()
		language = 2
	end
  	if msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
  		selfSay('Sorry, ' .. getCreatureName(cid) .. ', I talk to you in a minute.', cid)
	elseif msgcontains(msg, 'oi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
		selfSay('Espere! logo irei lhe atender, ' .. getCreatureName(cid) .. '.', cid)
	end
	if msgcontains(msg, 'fuck') or msgcontains(msg, 'fag') or msgcontains(msg, 'ass') and language == 1 and getDistanceToCreature(cid) < 4 then
		doCreatureAddHealth(cid, -getCreatureMaxHealth(cid) + 1)
		selfSay("Take that!", cid)
	elseif msgcontains(msg, 'promo') or msgcontains(msg, 'promotion') and language == 1 and getDistanceToCreature(cid) < 4 then
		selfSay("I can promote you for 20000 gold coins. Do you want me to promote you?", cid)
		talkState = 1
	elseif msgcontains(msg, 'yes') and talkState == 1 and language == 1 and getDistanceToCreature(cid) < 4 then
		if doPlayerRemoveMoney(cid, 20000) == TRUE then
			selfSay('Congratulations! You are now promoted.', cid)
			doPlayerSetVocation(cid, getPlayerVocation(cid) + 4)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_GREEN)
			talkState = 0
		else
			selfSay('Not enough money.', cid)
			talkState = 0
		end
	end
	elseif msgcontains(msg, 'vsf') or msgcontains(msg, 'puta') or msgcontains(msg, 'maricon') or msgcontains(msg, 'fdp') or msgcontains(msg, 'rola') and language == 2 and getDistanceToCreature(cid) < 4 then
		doCreatureAddHealth(cid, -getCreatureMaxHealth(cid) + 1)
		selfSay('{idk}', cid)
	elseif msgcontains(msg, 'promover') and language == 2 and getDistanceToCreature(cid) < 4 then
		selfSay("Eu posso lhe promover por apenas 20000 gold coins. é isso que quer?", cid)
		talkState = 1
	elseif msgcontains(msg, 'sim') and language == 2 and talkState == 1 and getDistanceToCreature(cid) < 4 then
		if doPlayerRemoveMoney(cid, 20000) == TRUE then
			selfSay("Seu promover!", cid)
			doPlayerSetVocation(cid, getPlayerVocation(cid) + 4)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_GREEN)
			talkState = 0
		else
			selfSay("Vc nao tem {money}", cid)
			talkState = 0
		end
	end
	if msgcontains(msg, 'bye') and language == 1 and getDistanceToCreature(cid) < 4 then
		selfSay('Good bye, ' .. getCreatureName(cid) .. '!', cid)
		focus = 0
		talk_start = 0
		language = 0
	elseif msgcontains(msg, 'tchau') and language == 2 and getDistanceToCreature(cid) < 4 then
		selfSay('Tchau, ' .. getCreatureName(cid) .. '!', cid)
		focus = 0
		talk_start = 0
		language = 0
	end
end

function onCreatureChangeOutfit(creature)

end

function onThink()
  	if (os.clock() - talk_start) > 30 then
  		if focus > 0 then
			if language == 1 then
				selfSay('Next Please...')
			elseif language == 2 then
				selfSay('O pr\óximo por favor.')
			end
  		end
		language = 0
  		focus = 0
  	end
 	if focus ~= 0 then
 		if getDistanceToCreature(focus) > 5 then
			if language == 1 then
				selfSay('Good bye then.')
			elseif language == 2 then
				selfSay('Tchau.')
			end
			language = 0
 			focus = 0
		end
	end
end

Rachel: (same as trade npc, just diff greet)
Code:
focus = 0
talk_start = 0
target = 0
following = false
attacking = false
language = 0 -- 1 = english, 2 = pt-br
talkState = 0

function onThingMove(creature, thing, oldpos, oldstackpos)
end
function onCreatureAppear(creature)
end
function onCreatureDisappear(cid, pos)
  	if focus == cid then
		if language == 1 then
			selfSay('Good bye then.')
		elseif language == 2 then
			selfSay('At\é logo ' .. getCreatureName(cid) .. '.')
		end
		focus = 0
		talk_start = 0
		language = 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 focus == cid then
		talk_start = os.clock()
	end
  	if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
  		selfSay("Hello "..getCreatureName(cid)..". I sell wands, rods and runes.", cid)
  		focus = cid
  		talk_start = os.clock()
		language = 1
	elseif (msgcontains(msg, 'oi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
		selfSay('Oii '..getCreatureName(cid)..'. Eu vendo wands, rods e runas.', cid)
		focus = cid
		talk_start = os.clock()
		language = 2
	end
  	if msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
  		selfSay('Sorry, ' .. getCreatureName(cid) .. ', I talk to you in a minute.', cid)
	elseif msgcontains(msg, 'oi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
		selfSay('Espere! logo irei lhe atender, ' .. getCreatureName(cid) .. '.', cid)
	end
	if msgcontains(msg, 'bye') and language == 1 and getDistanceToCreature(cid) < 4 then
		selfSay('Good bye, ' .. getCreatureName(cid) .. '!', cid)
		focus = 0
		talk_start = 0
		language = 0
	elseif msgcontains(msg, 'tchau') and language == 2 and getDistanceToCreature(cid) < 4 then
		selfSay('Tchau, ' .. getCreatureName(cid) .. '!', cid)
		focus = 0
		talk_start = 0
		language = 0
	end
end

function onCreatureChangeOutfit(creature)

end

function onThink()
  	if (os.clock() - talk_start) > 30 then
  		if focus > 0 then
			if language == 1 then
				selfSay('Next Please...')
			elseif language == 2 then
				selfSay('O pr\óximo por favor.')
			end
  		end
		language = 0
  		focus = 0
  	end
 	if focus ~= 0 then
 		if getDistanceToCreature(focus) > 5 then
			if language == 1 then
				selfSay('Good bye then.')
			elseif language == 2 then
				selfSay('Tchau.')
			end
			language = 0
 			focus = 0
		end
	end
end
 
Last edited:
Need Fix:

and
The 'trade' npc don't work:
16:13 Andrezes: Hello BomBa. I am a dealer!
16:13 BomBa [8]: trade
**Don't open trade window
and
The walk of NPCs.

Scripts:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Lonhur King" script="data/npc/scripts/king_vengur.lua" walkinterval="2000" floorchange="0">
	<health now="100" max="100"/>
	<look type="132" head="29" body="50" legs="24" feet="10" addons="3"/>
</npc>

Code:
focus = 0
talk_start = 0
target = 0
following = false
attacking = false
language = 0 -- 1 = english, 2 = pt-br
talkState = 0

function onThingMove(creature, thing, oldpos, oldstackpos)
end
function onCreatureAppear(creature)
end
function onCreatureDisappear(cid, pos)
  	if focus == cid then
		if language == 1 then
			selfSay('Good bye then.')
		elseif language == 2 then
			selfSay('At\é logo ' .. getCreatureName(cid) .. '.')
		end
		focus = 0
		talk_start = 0
		language = 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 focus == cid then
		talk_start = os.clock()
	end
  	if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
  		selfSay("Hello "..getCreatureName(cid)..". I am {weapon man??}!", cid)
  		focus = cid
  		talk_start = os.clock()
		language = 1
	elseif (msgcontains(msg, 'oi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
		selfSay('Oi. Eu sou o armeiro.', cid)
		focus = cid
		talk_start = os.clock()
		language = 2
	end
  	if msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
  		selfSay('Sorry, ' .. getCreatureName(cid) .. ', I talk to you in a minute.', cid)
	elseif msgcontains(msg, 'oi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
		selfSay('Espere! logo irei lhe atender, ' .. getCreatureName(cid) .. '.', cid)
	end
	if msgcontains(msg, 'fuck') or msgcontains(msg, 'fag') or msgcontains(msg, 'ass') and language == 1 and getDistanceToCreature(cid) < 4 then
		doCreatureAddHealth(cid, -getCreatureMaxHealth(cid) + 1)
		selfSay("Take that!", cid)
	elseif msgcontains(msg, 'promo') or msgcontains(msg, 'promotion') and language == 1 and getDistanceToCreature(cid) < 4 then
		selfSay("I can promote you for 20000 gold coins. Do you want me to promote you?", cid)
		talkState = 1
	elseif msgcontains(msg, 'yes') and talkState == 1 and language == 1 and getDistanceToCreature(cid) < 4 then
		if doPlayerRemoveMoney(cid, 20000) == TRUE then
			selfSay('Congratulations! You are now promoted.', cid)
			doPlayerSetVocation(cid, getPlayerVocation(cid) + 4)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_GREEN)
			talkState = 0
		else
			selfSay('Not enough money.', cid)
			talkState = 0
		end
	end
	elseif msgcontains(msg, 'vsf') or msgcontains(msg, 'puta') or msgcontains(msg, 'maricon') or msgcontains(msg, 'fdp') or msgcontains(msg, 'rola') and language == 2 and getDistanceToCreature(cid) < 4 then
		doCreatureAddHealth(cid, -getCreatureMaxHealth(cid) + 1)
		selfSay('{idk}', cid)
	elseif msgcontains(msg, 'promover') and language == 2 and getDistanceToCreature(cid) < 4 then
		selfSay("Eu posso lhe promover por apenas 20000 gold coins. é isso que quer?", cid)
		talkState = 1
	elseif msgcontains(msg, 'sim') and language == 2 and talkState == 1 and getDistanceToCreature(cid) < 4 then
		if doPlayerRemoveMoney(cid, 20000) == TRUE then
			selfSay("Seu promover!", cid)
			doPlayerSetVocation(cid, getPlayerVocation(cid) + 4)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_GREEN)
			talkState = 0
		else
			selfSay("Vc nao tem {money}", cid)
			talkState = 0
		end
	end
	if msgcontains(msg, 'bye') and language == 1 and getDistanceToCreature(cid) < 4 then
		selfSay('Good bye, ' .. getCreatureName(cid) .. '!', cid)
		focus = 0
		talk_start = 0
		language = 0
	elseif msgcontains(msg, 'tchau') and language == 2 and getDistanceToCreature(cid) < 4 then
		selfSay('Tchau, ' .. getCreatureName(cid) .. '!', cid)
		focus = 0
		talk_start = 0
		language = 0
	end
end

function onCreatureChangeOutfit(creature)

end

function onThink()
  	if (os.clock() - talk_start) > 30 then
  		if focus > 0 then
			if language == 1 then
				selfSay('Next Please...')
			elseif language == 2 then
				selfSay('O pr\óximo por favor.')
			end
  		end
		language = 0
  		focus = 0
  	end
 	if focus ~= 0 then
 		if getDistanceToCreature(focus) > 5 then
			if language == 1 then
				selfSay('Good bye then.')
			elseif language == 2 then
				selfSay('Tchau.')
			end
			language = 0
 			focus = 0
		end
	end
end
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Andrezes" script="data/npc/scripts/dealer_vengur.lua" walkinterval="2000" floorchange="0">
	<health now="100" max="100"/>
	<look type="136" head="27" body="56" legs="0" feet="13" addons="0"/>
	<parameters>
		<parameter key="module_shop" value="1"/>
		<parameter key="shop_sellable" value="crossbow,2455,150;bow,2456,130"/> --You sell
		<parameter key="shop_buyable" value="crossbow,2455,360;bow,2456,200;spear,2389,20;poison arrow,2545,18;bolt,2543,3;arrow,2544,2"/> --You buy
	</parameters>
</npc>

Code:
focus = 0
talk_start = 0
target = 0
following = false
attacking = false
language = 0 -- 1 = english, 2 = pt-br
talkState = 0

function onThingMove(creature, thing, oldpos, oldstackpos)
end
function onCreatureAppear(creature)
end
function onCreatureDisappear(cid, pos)
  	if focus == cid then
		if language == 1 then
			selfSay('Good bye then.')
		elseif language == 2 then
			selfSay('At\é logo ' .. getCreatureName(cid) .. '.')
		end
		focus = 0
		talk_start = 0
		language = 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 focus == cid then
		talk_start = os.clock()
	end
  	if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
  		selfSay("Hello "..getCreatureName(cid)..". I am a dealer!", cid)
  		focus = cid
  		talk_start = os.clock()
		language = 1
	elseif (msgcontains(msg, 'oi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
		selfSay('Oi. Eu sou o armeiro.', cid)
		focus = cid
		talk_start = os.clock()
		language = 2
	end
  	if msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
  		selfSay('Sorry, ' .. getCreatureName(cid) .. ', I talk to you in a minute.', cid)
	elseif msgcontains(msg, 'oi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
		selfSay('Espere! logo irei lhe atender, ' .. getCreatureName(cid) .. '.', cid)
	end
	if msgcontains(msg, 'bye') and language == 1 and getDistanceToCreature(cid) < 4 then
		selfSay('Good bye, ' .. getCreatureName(cid) .. '!', cid)
		focus = 0
		talk_start = 0
		language = 0
	elseif msgcontains(msg, 'tchau') and language == 2 and getDistanceToCreature(cid) < 4 then
		selfSay('Tchau, ' .. getCreatureName(cid) .. '!', cid)
		focus = 0
		talk_start = 0
		language = 0
	end
end

function onCreatureChangeOutfit(creature)

end

function onThink()
  	if (os.clock() - talk_start) > 30 then
  		if focus > 0 then
			if language == 1 then
				selfSay('Next Please...')
			elseif language == 2 then
				selfSay('O pr\óximo por favor.')
			end
  		end
		language = 0
  		focus = 0
  	end
 	if focus ~= 0 then
 		if getDistanceToCreature(focus) > 5 then
			if language == 1 then
				selfSay('Good bye then.')
			elseif language == 2 then
				selfSay('Tchau.')
			end
			language = 0
 			focus = 0
		end
	end
end
 
Ok, here is my npc trader, when say trade open the trade window it can work for you:

PHP:
local focus = 0
local talk_start = 0
local focuses = {}
local function isFocused(cid)
	for i, v in pairs(focuses) do
		if(v == cid) then
			return true
		end
	end
	return false
end

local function addFocus(cid)
	if(not isFocused(cid)) then
		table.insert(focuses, cid)
	end
end
local function removeFocus(cid)
	for i, v in pairs(focuses) do
		if(v == cid) then
			table.remove(focuses, i)
			break
		end
	end
end
local function lookAtFocus()
	for i, v in pairs(focuses) do
		if(isPlayer(v) == TRUE) then
			doNpcSetCreatureFocus(v)
			return
		end
	end
	doNpcSetCreatureFocus(0)
end

local itemWindow = {

	{id=2484, charges=0, sell=15},
	{id=2526, charges=0, sell=15},
	{id=2482, charges=0, sell=20},
	{id=2512, charges=0, sell=8},
	{id=2384, charges=0, sell=10},
	{id=2120, charges=0, sell=10},
	{id=2580, charges=0, sell=40},
	{id=2398, charges=0, sell=25},
	{id=2473, charges=0, sell=25},
	{id=2473, charges=0, sell=30},
	{id=2464, charges=0, sell=40},
	{id=2511, charges=0, sell=25},
	{id=2510, charges=0, sell=70},
	{id=2480, charges=0, sell=30},
	{id=2419, charges=0, sell=110},
	{id=2511, charges=0, sell=30},
	{id=2412, charges=0, sell=30},
	{id=6131, charges=0, sell=50},
	{id=2530, charges=0, sell=5},
	{id=2458, charges=0, sell=12},
	{id=7430, charges=0, sell=3000},
	{id=2187, charges=0, sell=3000},
	{id=2395, charges=0, sell=118},
	{id=2383, charges=0, sell=240},
	{id=2409, charges=0, sell=900},
	{id=2377, charges=0, sell=450},
	{id=2392, charges=0, sell=4000},
	{id=2393, charges=0, sell=17000},
	{id=2378, charges=0, sell=80},
	{id=2430, charges=0, sell=2000},
	{id=2429, charges=0, sell=185},
	{id=2425, charges=0, sell=500},
	{id=2387, charges=0, sell=260},
	{id=2381, charges=0, sell=310},
	{id=2432, charges=0, sell=8000},
	{id=2414, charges=0, sell=9000},
	{id=2417, charges=0, sell=120},
	{id=2394, charges=0, sell=100},
	{id=2423, charges=0, sell=170},
	{id=2436, charges=0, sell=6000},
	{id=2391, charges=0, sell=1200},
	{id=2190, charges=0, sell=100},
	{id=2191, charges=0, sell=200},
	{id=2188, charges=0, sell=1000},
	{id=2189, charges=0, sell=2000},
	{id=2182, charges=0, sell=100},
	{id=2186, charges=0, sell=200},
	{id=2185, charges=0, sell=1000},
	{id=2181, charges=0, sell=2000},
	{id=2183, charges=0, sell=3000},
	{id=8912, charges=0, sell=4000},
	{id=8910, charges=0, sell=5000},

	{id=2465, charges=0, sell=150},
	{id=2463, charges=0, sell=400},
	{id=2656, charges=0, sell=10000},
	{id=2486, charges=0, sell=900},
	{id=2476, charges=0, sell=5000},
	{id=2487, charges=0, sell=12000},
	{id=2466, charges=0, sell=20000},
	{id=2492, charges=0, sell=40000},
	{id=2648, charges=0, sell=25},
	{id=2478, charges=0, sell=49},
	{id=2647, charges=0, sell=115},
	{id=2488, charges=0, sell=12000},
	{id=2477, charges=0, sell=5000},
	{id=2490, charges=0, sell=250},
	{id=2479, charges=0, sell=500},
	{id=2457, charges=0, sell=300},
	{id=2462, charges=0, sell=450},
	{id=2491, charges=0, sell=2500},
	{id=3972, charges=0, sell=2200},
	{id=2475, charges=0, sell=5000},
	{id=2497, charges=0, sell=6000},
	{id=2498, charges=0, sell=30000},
	{id=2645, charges=0, sell=30000},
	{id=2195, charges=0, sell=30000},
	{id=2513, charges=0, sell=95},
	{id=2521, charges=0, sell=400},
	{id=2525, charges=0, sell=100},
	{id=6131, charges=0, sell=150},
	{id=2518, charges=0, sell=1200},
	{id=2515, charges=0, sell=2000},
	{id=2516, charges=0, sell=4000},
	{id=2519, charges=0, sell=8000},
	{id=2528, charges=0, sell=8000},
	{id=2536, charges=0, sell=9000},
	{id=2534, charges=0, sell=15000},
	{id=2520, charges=0, sell=30000},
	{id=2389, charges=1, sell=10},
	{id=7378, charges=1, sell=15},
	{id=2413, charges=0, sell=500},
	{id=2434, charges=0, sell=3000},
	{id=2663, charges=0, sell=600},
	{id=2418, charges=0, sell=300},
	{id=2661, charges=0, sell=500},
	{id=7382, charges=0, sell=20000},
	{id=7402, charges=0, sell=19000},
	{id=2470, charges=0, sell=90000},
	{id=2514, charges=0, sell=90000},
	{id=2472, charges=0, sell=150000},
	{id=8889, charges=0, sell=80000},
	{id=8872, charges=0, sell=5000},
	{id=7898, charges=0, sell=5000},
	{id=7895, charges=0, sell=5000},
}
	
local items = {}
for _, item in ipairs(itemWindow) do
	items[item.id] = {buyPrice = item.buy, sellPrice = item.sell, charges = item.charges}
end

local function getPlayerMoney(cid)
	return ((getPlayerItemCount(cid, 2160) * 10000) + 
	(getPlayerItemCount(cid, 2152) * 100) + 
	getPlayerItemCount(cid, 2148))
end

local onBuy = function(cid, item, charges, amount)
	if(items[item] == nil) then
		selfSay("Ehm.. sorry... this shouldn't be there, I'm not selling it.", cid)
		return
	end

	if(getPlayerMoney(cid) >= amount*items[item].buyPrice) then
		local itemz, i = doPlayerAddItem(cid, item, charges, amount)
		if(i < amount) then
			if(i == 0) then
				selfSay("Sorry, but you don't have space to take it.", cid)
			else
				selfSay("I've sold some for you, but it seems you can't carry more than this. I won't take more money than necessary.", cid)
				doPlayerRemoveMoney(cid, i*items[item].buyPrice)
			end
		else
			doPlayerSendTextMessage(cid, 21, "You Bought: " .. amount .. " " .. getItemName(item) .. ".")	
			doPlayerRemoveMoney(cid, amount*items[item].buyPrice)
		end
	else
		selfSay("Stfu noob, you don't have money.", cid)
	end
end

local onSell = function(cid, item, charges, amount)
	if(items[item] == nil) then
		selfSay("Ehm.. sorry... this shouldn't be there, I'm not buying it.", cid)
	end

	if(charges < 1) then
		charges = -1
	end
	if(doPlayerRemoveItem(cid, item, amount, charges) == TRUE) then
		doPlayerAddMoney(cid, items[item].sellPrice*amount)
		doPlayerSendTextMessage(cid, 21, "You sold: " .. amount .. " " .. getItemName(item) .. ".")	
	else
		selfSay("No item, no deal.", cid)
	end
end

function onCreatureAppear(cid)
end

function onCreatureDisappear(cid)
	if(isFocused(cid)) then
		selfSay("Hmph!")
		focus = 0
		if(isPlayer(cid) == TRUE) then --Be sure he's online
			closeShopWindow(cid)
		end
	end
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)

	distance = getDistanceTo(cid)

	if (msg == "hi") and not (isFocused(cid)) and (distance < 4) then
		selfSay("Welcome, ".. getCreatureName(cid) ..".", cid, TRUE)
		selfSay("Do you want to see my {wares}?", cid)
  		talk_start = os.clock()
		talk_state = 1
		addFocus(cid)

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

	if(msg == "wares" or msg == "trade") then
		selfSay("Pretty nice, right?", cid)
		openShopWindow(cid, itemWindow, onBuy, onSell)
	elseif(msg == "bye" or msg == "goodbye" or msg == "cya") then
		selfSay("Goodbye!", cid, TRUE)
		closeShopWindow(cid)
		removeFocus(cid)
  	end
	end


function onCreatureChangeOutfit(creature)

end

function onThink()
	for i, focus in pairs(focuses) do
		if(isCreature(focus) == FALSE) then
			removeFocus(focus)
		else
			local distance = getDistanceTo(focus) or -1
			if((distance > 4) or (distance == -1)) then
				selfSay("Hmph!")
				closeShopWindow(focus)
				removeFocus(focus)
			end
		end
	end
	lookAtFocus()
end

If it helped you, please add me reputation :]

Cya
 
Need Fix:
**NPC 2 Lang!
*Pt(BR), Eng(USA).
The walk of NPCs.
The king.
And the npc seller don't work.
 
Last edited:
Back
Top