Ir para conteúdo
  • 0

NPC promotion (10 reps)


gmstrikker

Pergunta

Eu queria um NPC de promotion assim:

Não sei fazer, to com medo de fazer merda e bugar as vocações de novo ai vou ferrar minha DB então peço a alguem q saiba

 

Uso rev 3777, 0.4!!! 8.6!

 

 

Eu queria um script de promotion editado!

vocações
1 - sorcerer (começa)
5 - master sorcerer (20k, free)
9 - epic sorcerer (10kk, premmy) -- só premmy consegui-se comprar, já consigurei ela, no vocations.xml com premy="1"

============================================

2 - druid (começa)
6 - elder druid (20k, free)
10 - epic druid (10kk, premmy) -- só premmy consegui-se comprar, já consigurei ela, no vocations.xml com premy="1"

============================================

3 - paladin (começa)
7 - royal paladin (20k, free)
11 - epic paladin (10kk, premmy) -- só premmy consegui-se comprar, já consigurei ela, no vocations.xml com premy="1"

============================================

4 - knight (começa)
8 - elite knight (20k, free)
12 - epic paladin (10kk, premmy) -- só premmy consegui-se comprar, já consigurei ela, no vocations.xml com premy="1"

============================================

0 - none (começa)
13 - rooker (10k, free)
14 - rookguaardian (5kk, premmy) -- só premmy consegui-se comprar, já consigurei ela, no vocations.xml com premy="1"
Link para o comentário
Compartilhar em outros sites

9 respostass a esta questão

Posts Recomendados

  • 0

@@gmstrikker,

 

XML:

<?xml version="1.0" encoding="UTF-8"?>
<npc name="Promotion VIP" script="data/npc/scripts/promotions.lua" walkinterval="2000" floorchange="0">
	<mana now="800" max="800"/>
	<health now="200" max="200"/>
	<look type="133" head="114" body="119" legs="132" feet="114"/>
</npc>
Script Lua (promotions.lua):

 

local config = {
	promote1 = 20000, -- preço da primeira promotion
	promote2 = 10000000, -- preço da segunda promotion
	rookPromote1 = {13, 10000}, -- {id da vocação, preço}
	rookPromote2 = {14, 5000000} -- {id da vocação, preço}
}

local focus = 0
local talk_start = 0

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

function findmsg(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)
	local price = 0

  	if findmsg(msg, 'hi') and (focus == 0) and getDistanceToCreature(cid) < 4 then
 		selfSay('Hello ' .. creatureGetName(cid) .. '! I sell promotions.')
 		focus = cid
 		talk_start = os.clock()

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

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

		if findmsg(msg, 'promotion') or findmsg(msg, 'promote') then
 			if getPlayerVocation(cid) == 0 or getPlayerVocation(cid) == config.rookPromote1[1] then
				selfSay('Do you want to buy promotion for ' .. price .. ' gold coins?')
				talk_state = 2
			elseif getPlayerVocation(cid) > 8  and getPlayerVocation(cid) < config.rookPromote1[1] then
 				selfSay('Sorry, you are already promoted.')
 				talk_state = 0
			elseif not isPremium(cid) and ((getPlayerVocation(cid) > 4 and getPlayerVocation(cid) < config.rookPromote1[1]) or getPlayerVocation(cid) == config.rookPromote1[1]) then
				selfSay('Sorry, you must be premium to buy promotion.')
				talk_state = 0
			else
				if getPlayerVocation(cid) > 8 then
					price = config.promote2
				else
					price = config.promote1
				end
				selfSay('Do you want to buy promotion for ' .. price .. ' gold coins?')
				talk_state = 1
			end

		elseif talk_state == 1 then
			if findmsg(msg, 'yes') then
				if doPlayerRemoveMoney(cid, price) then
					doPlayerSetVocation(cid, getPlayerVocation(cid) + 4)
					selfSay('You are now promoted!')
				else
					selfSay('Sorry, you do not have enough money.')
				end
 			end
			talk_state = 0

		elseif talk_state == 2 then
			if getPlayerVocation(cid) == 0 then
				if doPlayerRemoveMoney(cid, config.rookPromote1[2]) then
					doPlayerSetVocation(cid, config.rookPromote1[1])
					selfSay('You are now promoted!')
				else
					selfSay('Sorry, you do not have enough money.')
				end
			elseif getPlayerVocation(cid) == config.rookPromote1[1] then
				if doPlayerRemoveMoney(cid, config.rookPromote2[2]) then
					doPlayerSetVocation(cid, config.rookPromote2[1])
					selfSay('You are now promoted!')
				else
					selfSay('Sorry, you do not have enough money.')
				end
			end
			talk_state = 0

  		elseif findmsg(msg, 'bye')  and getDistanceToCreature(cid) < 4 then
  			selfSay('Good bye, ' .. creatureGetName(cid) .. '!')
  			focus = 0
  			talk_start = 0
  		end
  	end
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

 

Link para o comentário
Compartilhar em outros sites

  • 0

@@gmstrikker,

 

XML:

<?xml version="1.0" encoding="UTF-8"?>
<npc name="Promotion VIP" script="data/npc/scripts/promotions.lua" walkinterval="2000" floorchange="0">
	<mana now="800" max="800"/>
	<health now="200" max="200"/>
	<look type="133" head="114" body="119" legs="132" feet="114"/>
</npc>
Script Lua (promotions.lua):

 

 

local config = {
	promote1 = 20000, -- preço da primeira promotion
	promote2 = 10000000, -- preço da segunda promotion
	rookPromote1 = {13, 10000}, -- {id da vocação, preço}
	rookPromote2 = {14, 5000000} -- {id da vocação, preço}
}

local focus = 0
local talk_start = 0

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

function findmsg(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)
	local price = 0

  	if findmsg(msg, 'hi') and (focus == 0) and getDistanceToCreature(cid) < 4 then
 		selfSay('Hello ' .. creatureGetName(cid) .. '! I sell promotions.')
 		focus = cid
 		talk_start = os.clock()

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

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

		if findmsg(msg, 'promotion') or findmsg(msg, 'promote') then
 			if getPlayerVocation(cid) == 0 or getPlayerVocation(cid) == config.rookPromote1[1] then
				selfSay('Do you want to buy promotion for ' .. price .. ' gold coins?')
				talk_state = 2
			elseif getPlayerVocation(cid) > 8  and getPlayerVocation(cid) < config.rookPromote1[1] then
 				selfSay('Sorry, you are already promoted.')
 				talk_state = 0
			elseif not isPremium(cid) and ((getPlayerVocation(cid) > 4 and getPlayerVocation(cid) < config.rookPromote1[1]) or getPlayerVocation(cid) == config.rookPromote1[1]) then
				selfSay('Sorry, you must be premium to buy promotion.')
				talk_state = 0
			else
				if getPlayerVocation(cid) > 8 then
					price = config.promote2
				else
					price = config.promote1
				end
				selfSay('Do you want to buy promotion for ' .. price .. ' gold coins?')
				talk_state = 1
			end

		elseif talk_state == 1 then
			if findmsg(msg, 'yes') then
				if doPlayerRemoveMoney(cid, price) then
					doPlayerSetVocation(cid, getPlayerVocation(cid) + 4)
					selfSay('You are now promoted!')
				else
					selfSay('Sorry, you do not have enough money.')
				end
 			end
			talk_state = 0

		elseif talk_state == 2 then
			if getPlayerVocation(cid) == 0 then
				if doPlayerRemoveMoney(cid, config.rookPromote1[2]) then
					doPlayerSetVocation(cid, config.rookPromote1[1])
					selfSay('You are now promoted!')
				else
					selfSay('Sorry, you do not have enough money.')
				end
			elseif getPlayerVocation(cid) == config.rookPromote1[1] then
				if doPlayerRemoveMoney(cid, config.rookPromote2[2]) then
					doPlayerSetVocation(cid, config.rookPromote2[1])
					selfSay('You are now promoted!')
				else
					selfSay('Sorry, you do not have enough money.')
				end
			end
			talk_state = 0

  		elseif findmsg(msg, 'bye')  and getDistanceToCreature(cid) < 4 then
  			selfSay('Good bye, ' .. creatureGetName(cid) .. '!')
  			focus = 0
  			talk_start = 0
  		end
  	end
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

 

Erro ao falar hi com o NPC:

 

v0qW6bN.png

Link para o comentário
Compartilhar em outros sites

  • 0

Erro ao falar hi com o NPC:

Segue:

 

local config = {
	promote1 = 20000, -- preço da primeira promotion
	promote2 = 10000000, -- preço da segunda promotion
	rookPromote1 = {13, 10000}, -- {id da vocação, preço}
	rookPromote2 = {14, 5000000} -- {id da vocação, preço}
}

local focus = 0
local talk_start = 0

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

function findmsg(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)
	local price = 0

  	if findmsg(msg, 'hi') and (focus == 0) and getDistanceToCreature(cid) < 4 then
 		selfSay('Hello ' .. getPlayerName(cid) .. '! I sell promotions.')
 		focus = cid
 		talk_start = os.clock()

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

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

		if findmsg(msg, 'promotion') or findmsg(msg, 'promote') then
 			if getPlayerVocation(cid) == 0 or getPlayerVocation(cid) == config.rookPromote1[1] then
				selfSay('Do you want to buy promotion for ' .. price .. ' gold coins?')
				talk_state = 2
			elseif getPlayerVocation(cid) > 8  and getPlayerVocation(cid) < config.rookPromote1[1] then
 				selfSay('Sorry, you are already promoted.')
 				talk_state = 0
			elseif not isPremium(cid) and ((getPlayerVocation(cid) > 4 and getPlayerVocation(cid) < config.rookPromote1[1]) or getPlayerVocation(cid) == config.rookPromote1[1]) then
				selfSay('Sorry, you must be premium to buy promotion.')
				talk_state = 0
			else
				if getPlayerVocation(cid) > 8 then
					price = config.promote2
				else
					price = config.promote1
				end
				selfSay('Do you want to buy promotion for ' .. price .. ' gold coins?')
				talk_state = 1
			end

		elseif talk_state == 1 then
			if findmsg(msg, 'yes') then
				if doPlayerRemoveMoney(cid, price) then
					doPlayerSetVocation(cid, getPlayerVocation(cid) + 4)
					selfSay('You are now promoted!')
				else
					selfSay('Sorry, you do not have enough money.')
				end
 			end
			talk_state = 0

		elseif talk_state == 2 then
			if getPlayerVocation(cid) == 0 then
				if doPlayerRemoveMoney(cid, config.rookPromote1[2]) then
					doPlayerSetVocation(cid, config.rookPromote1[1])
					selfSay('You are now promoted!')
				else
					selfSay('Sorry, you do not have enough money.')
				end
			elseif getPlayerVocation(cid) == config.rookPromote1[1] then
				if doPlayerRemoveMoney(cid, config.rookPromote2[2]) then
					doPlayerSetVocation(cid, config.rookPromote2[1])
					selfSay('You are now promoted!')
				else
					selfSay('Sorry, you do not have enough money.')
				end
			end
			talk_state = 0

  		elseif findmsg(msg, 'bye')  and getDistanceToCreature(cid) < 4 then
  			selfSay('Good bye, ' .. getPlayerName(cid) .. '!')
  			focus = 0
  			talk_start = 0
  		end
  	end
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

 

Link para o comentário
Compartilhar em outros sites

  • 0

Segue:

 

 

local config = {
	promote1 = 20000, -- preço da primeira promotion
	promote2 = 10000000, -- preço da segunda promotion
	rookPromote1 = {13, 10000}, -- {id da vocação, preço}
	rookPromote2 = {14, 5000000} -- {id da vocação, preço}
}

local focus = 0
local talk_start = 0

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

function findmsg(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)
	local price = 0

  	if findmsg(msg, 'hi') and (focus == 0) and getDistanceToCreature(cid) < 4 then
 		selfSay('Hello ' .. getPlayerName(cid) .. '! I sell promotions.')
 		focus = cid
 		talk_start = os.clock()

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

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

		if findmsg(msg, 'promotion') or findmsg(msg, 'promote') then
 			if getPlayerVocation(cid) == 0 or getPlayerVocation(cid) == config.rookPromote1[1] then
				selfSay('Do you want to buy promotion for ' .. price .. ' gold coins?')
				talk_state = 2
			elseif getPlayerVocation(cid) > 8  and getPlayerVocation(cid) < config.rookPromote1[1] then
 				selfSay('Sorry, you are already promoted.')
 				talk_state = 0
			elseif not isPremium(cid) and ((getPlayerVocation(cid) > 4 and getPlayerVocation(cid) < config.rookPromote1[1]) or getPlayerVocation(cid) == config.rookPromote1[1]) then
				selfSay('Sorry, you must be premium to buy promotion.')
				talk_state = 0
			else
				if getPlayerVocation(cid) > 8 then
					price = config.promote2
				else
					price = config.promote1
				end
				selfSay('Do you want to buy promotion for ' .. price .. ' gold coins?')
				talk_state = 1
			end

		elseif talk_state == 1 then
			if findmsg(msg, 'yes') then
				if doPlayerRemoveMoney(cid, price) then
					doPlayerSetVocation(cid, getPlayerVocation(cid) + 4)
					selfSay('You are now promoted!')
				else
					selfSay('Sorry, you do not have enough money.')
				end
 			end
			talk_state = 0

		elseif talk_state == 2 then
			if getPlayerVocation(cid) == 0 then
				if doPlayerRemoveMoney(cid, config.rookPromote1[2]) then
					doPlayerSetVocation(cid, config.rookPromote1[1])
					selfSay('You are now promoted!')
				else
					selfSay('Sorry, you do not have enough money.')
				end
			elseif getPlayerVocation(cid) == config.rookPromote1[1] then
				if doPlayerRemoveMoney(cid, config.rookPromote2[2]) then
					doPlayerSetVocation(cid, config.rookPromote2[1])
					selfSay('You are now promoted!')
				else
					selfSay('Sorry, you do not have enough money.')
				end
			end
			talk_state = 0

  		elseif findmsg(msg, 'bye')  and getDistanceToCreature(cid) < 4 then
  			selfSay('Good bye, ' .. getPlayerName(cid) .. '!')
  			focus = 0
  			talk_start = 0
  		end
  	end
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

 

 

 

Não posso dar mais REPS hoje :(

 

Ta meio bugado ainda, ele fala como um npc das versões antigas.. Tem problema?

E ele ta dando a promote, mesmo se o player não tem dinheiro..

 

 

Link para o comentário
Compartilhar em outros sites

  • 0

Não posso dar mais REPS hoje :(

 

Ta meio bugado ainda, ele fala como um npc das versões antigas.. Tem problema?

E ele ta dando a promote, mesmo se o player não tem dinheiro..

Tenta assim:

 

local config = {
	promote1 = 20000, -- preço da primeira promotion
	promote2 = 10000000, -- preço da segunda promotion
	rookPromote1 = {13, 10000}, -- {id da vocação, preço}
	rookPromote2 = {14, 5000000} -- {id da vocação, preço}
}

local focus = 0
local talk_start = 0

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

function findmsg(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 findmsg(msg, 'hi') and (focus == 0) and getDistanceToCreature(cid) < 4 then
 		selfSay('Hello ' .. getPlayerName(cid) .. '! I sell promotions.')
 		focus = cid
 		talk_start = os.clock()

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

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

		if findmsg(msg, 'promotion') or findmsg(msg, 'promote') then
 			if getPlayerVocation(cid) == 0 or getPlayerVocation(cid) == config.rookPromote1[1] then
				selfSay('Do you want to buy promotion for ' .. price .. ' gold coins?')
				talk_state = 2
			elseif getPlayerVocation(cid) > 8  and getPlayerVocation(cid) < config.rookPromote1[1] then
 				selfSay('Sorry, you are already promoted.')
 				talk_state = 0
			elseif not isPremium(cid) and ((getPlayerVocation(cid) > 4 and getPlayerVocation(cid) < config.rookPromote1[1]) or getPlayerVocation(cid) == config.rookPromote1[1]) then
				selfSay('Sorry, you must be premium to buy promotion.')
				talk_state = 0
			else
				selfSay('Do you want to buy promotion for ' .. price .. ' gold coins?')
				talk_state = 1
			end

		elseif talk_state == 1 then
			if findmsg(msg, 'yes') then
				local price = (getPlayerVocation(cid) > 8) and config.promote2 or config.promote1
				if doPlayerRemoveMoney(cid, price) then
					doPlayerSetVocation(cid, getPlayerVocation(cid) + 4)
					selfSay('You are now promoted!')
				else
					selfSay('Sorry, you do not have enough money.')
				end
 			end
			talk_state = 0

		elseif talk_state == 2 then
			if getPlayerVocation(cid) == 0 then
				if doPlayerRemoveMoney(cid, config.rookPromote1[2]) then
					doPlayerSetVocation(cid, config.rookPromote1[1])
					selfSay('You are now promoted!')
				else
					selfSay('Sorry, you do not have enough money.')
				end
			elseif getPlayerVocation(cid) == config.rookPromote1[1] then
				if doPlayerRemoveMoney(cid, config.rookPromote2[2]) then
					doPlayerSetVocation(cid, config.rookPromote2[1])
					selfSay('You are now promoted!')
				else
					selfSay('Sorry, you do not have enough money.')
				end
			end
			talk_state = 0

  		elseif findmsg(msg, 'bye')  and getDistanceToCreature(cid) < 4 then
  			selfSay('Good bye, ' .. getPlayerName(cid) .. '!')
  			focus = 0
  			talk_start = 0
  		end
  	end
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

 

Link para o comentário
Compartilhar em outros sites

  • 0

Tenta assim:

 

 

local config = {
	promote1 = 20000, -- preço da primeira promotion
	promote2 = 10000000, -- preço da segunda promotion
	rookPromote1 = {13, 10000}, -- {id da vocação, preço}
	rookPromote2 = {14, 5000000} -- {id da vocação, preço}
}

local focus = 0
local talk_start = 0

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

function findmsg(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 findmsg(msg, 'hi') and (focus == 0) and getDistanceToCreature(cid) < 4 then
 		selfSay('Hello ' .. getPlayerName(cid) .. '! I sell promotions.')
 		focus = cid
 		talk_start = os.clock()

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

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

		if findmsg(msg, 'promotion') or findmsg(msg, 'promote') then
 			if getPlayerVocation(cid) == 0 or getPlayerVocation(cid) == config.rookPromote1[1] then
				selfSay('Do you want to buy promotion for ' .. price .. ' gold coins?')
				talk_state = 2
			elseif getPlayerVocation(cid) > 8  and getPlayerVocation(cid) < config.rookPromote1[1] then
 				selfSay('Sorry, you are already promoted.')
 				talk_state = 0
			elseif not isPremium(cid) and ((getPlayerVocation(cid) > 4 and getPlayerVocation(cid) < config.rookPromote1[1]) or getPlayerVocation(cid) == config.rookPromote1[1]) then
				selfSay('Sorry, you must be premium to buy promotion.')
				talk_state = 0
			else
				selfSay('Do you want to buy promotion for ' .. price .. ' gold coins?')
				talk_state = 1
			end

		elseif talk_state == 1 then
			if findmsg(msg, 'yes') then
				local price = (getPlayerVocation(cid) > 8) and config.promote2 or config.promote1
				if doPlayerRemoveMoney(cid, price) then
					doPlayerSetVocation(cid, getPlayerVocation(cid) + 4)
					selfSay('You are now promoted!')
				else
					selfSay('Sorry, you do not have enough money.')
				end
 			end
			talk_state = 0

		elseif talk_state == 2 then
			if getPlayerVocation(cid) == 0 then
				if doPlayerRemoveMoney(cid, config.rookPromote1[2]) then
					doPlayerSetVocation(cid, config.rookPromote1[1])
					selfSay('You are now promoted!')
				else
					selfSay('Sorry, you do not have enough money.')
				end
			elseif getPlayerVocation(cid) == config.rookPromote1[1] then
				if doPlayerRemoveMoney(cid, config.rookPromote2[2]) then
					doPlayerSetVocation(cid, config.rookPromote2[1])
					selfSay('You are now promoted!')
				else
					selfSay('Sorry, you do not have enough money.')
				end
			end
			talk_state = 0

  		elseif findmsg(msg, 'bye')  and getDistanceToCreature(cid) < 4 then
  			selfSay('Good bye, ' .. getPlayerName(cid) .. '!')
  			focus = 0
  			talk_start = 0
  		end
  	end
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

 

 

Qnd fala promotion

 

DMKLtqp.png

Link para o comentário
Compartilhar em outros sites

  • 0

Qnd fala promotion

Foi uma definição incorreta, kkkk, ai está:

 

local config = {
	promote1 = 20000, -- preço da primeira promotion
	promote2 = 10000000, -- preço da segunda promotion
	rookPromote1 = {13, 10000}, -- {id da vocação, preço}
	rookPromote2 = {14, 5000000} -- {id da vocação, preço}
}

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 creatureSayCallback(cid, type, msg)
	msg = string.lower(msg)
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	
	if not npcHandler:isFocused(cid) then
		return false
	end

	local price = (getPlayerVocation(cid) > 8) and config.promote2 or config.promote1
	if msgcontains(msg, 'hi') then
 		selfSay('Hello ' .. getPlayerName(cid) .. '! I sell promotions.')

  	elseif msgcontains(msg, 'promotion') or msgcontains(msg, 'promote') then
		if getPlayerVocation(cid) == 0 or getPlayerVocation(cid) == config.rookPromote1[1] then
			selfSay('Do you want to buy promotion for ' .. price .. ' gold coins?')
			talkState[talkUser] = 2
		elseif getPlayerVocation(cid) > 8  and getPlayerVocation(cid) < config.rookPromote1[1] then
			selfSay('Sorry, you are already promoted.')
			talkState[talkUser] = 0
		elseif not isPremium(cid) and ((getPlayerVocation(cid) > 4 and getPlayerVocation(cid) < config.rookPromote1[1]) or getPlayerVocation(cid) == config.rookPromote1[1]) then
			selfSay('Sorry, you must be premium to buy promotion.')
			talkState[talkUser] = 0
		else
			selfSay('Do you want to buy promotion for ' .. price .. ' gold coins?')
			talkState[talkUser] = 1
		end

	elseif talkState[talkUser] == 1 then
		if msgcontains(msg, 'yes') then
			if doPlayerRemoveMoney(cid, price) then
				doPlayerSetVocation(cid, getPlayerVocation(cid) + 4)
				selfSay('You are now promoted!')
			else
				selfSay('Sorry, you do not have enough money.')
			end
		end
		talkState[talkUser] = 0

	elseif talkState[talkUser] == 2 then
		if getPlayerVocation(cid) == 0 then
			if doPlayerRemoveMoney(cid, config.rookPromote1[2]) then
				doPlayerSetVocation(cid, config.rookPromote1[1])
				selfSay('You are now promoted!')
			else
				selfSay('Sorry, you do not have enough money.')
			end
		elseif getPlayerVocation(cid) == config.rookPromote1[1] then
			if doPlayerRemoveMoney(cid, config.rookPromote2[2]) then
				doPlayerSetVocation(cid, config.rookPromote2[1])
				selfSay('You are now promoted!')
			else
				selfSay('Sorry, you do not have enough money.')
			end
		end
		talkState[talkUser] = 0

	elseif msgcontains(msg, 'bye') then
		selfSay('Good bye, ' .. getPlayerName(cid) .. '!')
		talkState[talkUser] = 0
	end	
	return true
end

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

 

Link para o comentário
Compartilhar em outros sites

  • 0

Foi uma definição incorreta, kkkk, ai está:

 

 

local config = {
	promote1 = 20000, -- preço da primeira promotion
	promote2 = 10000000, -- preço da segunda promotion
	rookPromote1 = {13, 10000}, -- {id da vocação, preço}
	rookPromote2 = {14, 5000000} -- {id da vocação, preço}
}

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 creatureSayCallback(cid, type, msg)
	msg = string.lower(msg)
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	
	if not npcHandler:isFocused(cid) then
		return false
	end

	local price = (getPlayerVocation(cid) > 8) and config.promote2 or config.promote1
	if msgcontains(msg, 'hi') then
 		selfSay('Hello ' .. getPlayerName(cid) .. '! I sell promotions.')

  	elseif msgcontains(msg, 'promotion') or msgcontains(msg, 'promote') then
		if getPlayerVocation(cid) == 0 or getPlayerVocation(cid) == config.rookPromote1[1] then
			selfSay('Do you want to buy promotion for ' .. price .. ' gold coins?')
			talkState[talkUser] = 2
		elseif getPlayerVocation(cid) > 8  and getPlayerVocation(cid) < config.rookPromote1[1] then
			selfSay('Sorry, you are already promoted.')
			talkState[talkUser] = 0
		elseif not isPremium(cid) and ((getPlayerVocation(cid) > 4 and getPlayerVocation(cid) < config.rookPromote1[1]) or getPlayerVocation(cid) == config.rookPromote1[1]) then
			selfSay('Sorry, you must be premium to buy promotion.')
			talkState[talkUser] = 0
		else
			selfSay('Do you want to buy promotion for ' .. price .. ' gold coins?')
			talkState[talkUser] = 1
		end

	elseif talkState[talkUser] == 1 then
		if msgcontains(msg, 'yes') then
			if doPlayerRemoveMoney(cid, price) then
				doPlayerSetVocation(cid, getPlayerVocation(cid) + 4)
				selfSay('You are now promoted!')
			else
				selfSay('Sorry, you do not have enough money.')
			end
		end
		talkState[talkUser] = 0

	elseif talkState[talkUser] == 2 then
		if getPlayerVocation(cid) == 0 then
			if doPlayerRemoveMoney(cid, config.rookPromote1[2]) then
				doPlayerSetVocation(cid, config.rookPromote1[1])
				selfSay('You are now promoted!')
			else
				selfSay('Sorry, you do not have enough money.')
			end
		elseif getPlayerVocation(cid) == config.rookPromote1[1] then
			if doPlayerRemoveMoney(cid, config.rookPromote2[2]) then
				doPlayerSetVocation(cid, config.rookPromote2[1])
				selfSay('You are now promoted!')
			else
				selfSay('Sorry, you do not have enough money.')
			end
		end
		talkState[talkUser] = 0

	elseif msgcontains(msg, 'bye') then
		selfSay('Good bye, ' .. getPlayerName(cid) .. '!')
		talkState[talkUser] = 0
	end	
	return true
end

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

 

 

Agora parece estar funcionando perfeitamente, irei terminar de te dar os reps!

 

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...