Ir para conteúdo

Posts Recomendados

Né mais facil fazer isso por .xml?

 

<movevent type="Equip" itemid="7886;2456;+ID's" slot="hand;feet;ring;head;necklace;backpack;legs;armor" level="5" event="function" value="onEquipItem">
<vocation id="2"/> -- Vocações que pode usar o item
</movevent>
Link para o comentário
https://xtibia.com/forum/topic/234078-script-proibe-itens/#findComment-1652581
Compartilhar em outros sites

 

Né mais facil fazer isso por .xml?

<movevent type="Equip" itemid="7886;2456;+ID's" slot="hand;feet;ring;head;necklace;backpack;legs;armor" level="5" event="function" value="onEquipItem">
<vocation id="2"/> -- Vocações que pode usar o item
</movevent>

Seria um saco por serem muitos IDs

Por isso pedi um script pra fazer uma lista..

up ;v

up worriedsmiley.gif

Link para o comentário
https://xtibia.com/forum/topic/234078-script-proibe-itens/#findComment-1652583
Compartilhar em outros sites

Vamos fazer o teste...

 

Em data/movements/scripts crie um arquivo chamado byVocation.lua com o seguinte conteúdo:

 

 

local vocations = {
	['sorcerer']            = {2160, 3063, 3040},
	['druid']                = {3080, 2400, 8453},
	['paladin']             = {2410, 3023, 3160},
	['knight']               = {2400, 2340, 3031},
	['master sorcerer']  = {2160, 3063, 3040},
	['elder druid']         = {3080, 2400, 8453},
	['royal paladin']      = {2410, 3023, 3160},
	['elite knight']        = {2400, 2340, 3031}
}

-- Não mexa em nada abaixo
function onEquip(cid, item, slot)
	local vocation = getPlayerVocationName(cid)
	local items = {}

	for i = 1, #vocations[vocation] do
		table.insert(items, vocations[vocation][i])
	end

	if not isInArray(items, item.itemid) then
		doPlayerSendCancel(cid, 'Este item nao pode ser usado por sua vocacao.')
	end

	return true
end
Basta colocar os id's em suas respectivas arrays.

 

 

 

Agora em data/movements/movements.xml adicione a seguinte linha:

<movevent type="Equip" itemid="3063;3040;3080;2400; todos os ids;" slot="hand;feet;ring;head;necklace;backpack;legs;armor" event="script" value="byVocation.lua" />
Tem necessidade de colocar id por id no xml, para que ele reconheça o script...

 

Qualquer erro me fale.

Link para o comentário
https://xtibia.com/forum/topic/234078-script-proibe-itens/#findComment-1653168
Compartilhar em outros sites

 

Vamos fazer o teste...

Em data/movements/scripts crie um arquivo chamado byVocation.lua com o seguinte conteúdo:

 

local vocations = {
	['sorcerer']            = {2160, 3063, 3040},
	['druid']                = {3080, 2400, 8453},
	['paladin']             = {2410, 3023, 3160},
	['knight']               = {2400, 2340, 3031},
	['master sorcerer']  = {2160, 3063, 3040},
	['elder druid']         = {3080, 2400, 8453},
	['royal paladin']      = {2410, 3023, 3160},
	['elite knight']        = {2400, 2340, 3031}
}

-- Não mexa em nada abaixo
function onEquip(cid, item, slot)
	local vocation = getPlayerVocationName(cid)
	local items = {}

	for i = 1, #vocations[vocation] do
		table.insert(items, vocations[vocation][i])
	end

	if not isInArray(items, item.itemid) then
		doPlayerSendCancel(cid, 'Este item nao pode ser usado por sua vocacao.')
	end

	return true
end
Basta colocar os id's em suas respectivas arrays.



Agora em data/movements/movements.xml adicione a seguinte linha:

<movevent type="Equip" itemid="3063;3040;3080;2400; todos os ids;" slot="hand;feet;ring;head;necklace;backpack;legs;armor" event="script" value="byVocation.lua" />
Tem necessidade de colocar id por id no xml, para que ele reconheça o script...

Qualquer erro me fale.

 

Deu esse erro no xml

 

 

data/movements/movements.xml:574: parser error : Opening and ending tag mismatch

: movements line 2 and movevent
</movevent>
^
data/movements/movements.xml:575: parser error : Extra content at the end of the
document
<movevent type="DeEquip" itemid="8819" slot="armor" event="function" val
ue="onD
^
[Warning - BaseEvents::loadFromXml] Cannot open movements.xml file.
Line: 575, Info: Extra content at the end of the document
> ERROR: Unable to load MoveEvents!

Link para o comentário
https://xtibia.com/forum/topic/234078-script-proibe-itens/#findComment-1654520
Compartilhar em outros sites

Deu esse erro no xml

 

 

data/movements/movements.xml:574: parser error : Opening and ending tag mismatch

: movements line 2 and movevent

</movevent>

^

data/movements/movements.xml:575: parser error : Extra content at the end of the

document

<movevent type="DeEquip" itemid="8819" slot="armor" event="function" val

ue="onD

^

[Warning - BaseEvents::loadFromXml] Cannot open movements.xml file.

Line: 575, Info: Extra content at the end of the document

 

 

> ERROR: Unable to load MoveEvents!

 

Coloca a linha toda do xml que você colocou

Link para o comentário
https://xtibia.com/forum/topic/234078-script-proibe-itens/#findComment-1654525
Compartilhar em outros sites

  • 4 weeks later...

Coloca a linha toda do xml que você colocou

 

 

 

<movevent type="Equip" itemid="2520;2515;2512" slot="hand;feet;ring;head;necklace;backpack;legs;armor" event="script" value="itens.lua"/>

Sim nomeei o .lua como "itens"

 

e aqui o script

local vocations = {

['dark warrior'] = {2520, 2515, 2512},

}

 

-- Não mexa em nada abaixo

function onEquip(cid, item, slot)

local vocation = getPlayerVocationName(cid)

local items = {}

 

for i = 1, #vocations[vocation] do

table.insert(items, vocations[vocation])

end

 

if not isInArray(items, item.itemid) then

doPlayerSendCancel(cid, 'Este item nao pode ser usado por sua vocacao.')

end

 

return true

end

 

up

Link para o comentário
https://xtibia.com/forum/topic/234078-script-proibe-itens/#findComment-1657953
Compartilhar em outros sites

  • 3 weeks later...
Visitante
Este tópico está impedido de receber novos posts.
×
×
  • Criar Novo...