BE
pedido

Spell Get Item Id Em Bag

Por Bennyhappy, 26 de nov. de 2012 em Scripts

20
3.1k
BennyhappyB
26 de novembro de 2012 às 03:17

como fazer, para os jogadores só pode lançar um spell, se você tem um item específico, em dentro de um bag em específico.

 

 

 

dentro de item id=1992 name=yellow bag

 

mas meu backpack principal seria qualquer, o item tem de estar sozinho no meu yellow bag

LTKReturnsL
26 de novembro de 2012 às 03:28

Testa Esse

 

 

 

local combat = createCombatObject()

setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HEALING)

setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_GREEN)

setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, 1)

setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)

setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, 0, 15000, 0, 20000)

 

function onCastSpell(cid, var)

if getPlayerItemCount(cid, IDDOITEM) > 0 then

return doCombat(cid, combat, var)

end

return FALSE

end

 

 

Editado Novembro 26 por LTKReturns

BennyhappyB
26 de novembro de 2012 às 03:56

nao abre o spoiler

LTKReturnsL
26 de novembro de 2012 às 03:58

local combat = createCombatObject()

setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HEALING)

setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_GREEN)

setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, 1)

setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)

setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, 0, 15000, 0, 20000)

 

function onCastSpell(cid, var)

if getPlayerItemCount(cid, IDDOITEM) > 0 then

return doCombat(cid, combat, var)

end

return FALSE

end

BennyhappyB
26 de novembro de 2012 às 04:02

Mas isso script não necessariamente tem que ser na minha yellow bag :/

 

Não sei como poderia ser?

SlicerS
26 de novembro de 2012 às 11:07

n testei mas...

function getItemsInContainerById(container, itemid) -- Function By Kydrai
local items = {}
if isContainer(container) and getContainerSize(container) > 0 then
  for slot=0, (getContainerSize(container)-1) do
   local item = getContainerItem(container, slot)
   if isContainer(item.uid) then
	  local itemsbag = getItemsInContainerById(item.uid, itemid)
	  for i=0, #itemsbag do
		  table.insert(items, itemsbag[i])
	  end
   else
	  if itemid == item.itemid then
		 table.insert(items, item.uid)
	  end
   end
  end
end
return items
end


local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HEALING)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_GREEN)
setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, 1)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, 0, 15000, 0, 20000)

function onCastSpell(cid, var)
local YellowBag = getItemsInContainerById(getPlayerSlotItem(cid, 3).uid, 1992) --verifica se tem a yellow bag dentro da bag principal...
if #YellowBag >= 1 then
  for i = 1, #YellowBag do				 --coloque o id aki!
   local Item = getItemsInContainerById(YellowBag[i], ITEMID) --verifica se tem o item dentro de alguma yellow bag...
   if #Item >= 1 then
	  return doCombat(cid, combat, var)
   end
  end
end
return FALSE
end

Editado Novembro 26 por Slicer

BennyhappyB
30 de novembro de 2012 às 22:00

basta mudar o ID do item no yellow bag aqui?

 

local Item = getItemsInContainerById(YellowBag, ITEMID) ---?

 

Eu fiz isso, mas não funcionou, configure-o errado?

 

yellow bag IItemID: [1992].

 

poem scroll ItemID: [5952].

 

 

function getItemsInContainerById(container, itemid) -- Function By Kydrai
local items = {}
if isContainer(container) and getContainerSize(container) > 0 then
   for slot=0, (getContainerSize(container)-1) do
		   local item = getContainerItem(container, slot)
		   if isContainer(item.uid) then
				  local itemsbag = getItemsInContainerById(item.uid, itemid)
				  for i=0, #itemsbag do
						  table.insert(items, itemsbag[i])
				  end
		   else
				  if itemid == item.itemid then
						 table.insert(items, item.uid)
				  end
		   end
   end
end
return items
end


local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SUDDENDEATH)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -11, -80, -11, -120, 60, 60, 9.9, 9.9)

function onCastSpell(cid, var)
local YellowBag = getItemsInContainerById(getPlayerSlotItem(cid, 3).uid, 1992) --verifica se tem a yellow bag dentro da bag

principal...
if #YellowBag >= 1 then

   for i = 1, #YellowBag do							  --coloque o id aki!
		   local Item = getItemsInContainerById(YellowBag[i], 5952) --verifica se tem o item dentro de alguma yellow bag...
		   if #Item >= 1 then
				  return doCombat(cid, combat, var)
		   end
   end
end
return FALSE
end

 

ajuda

 

BUMP

 

ajudaaaaaaaaaaaaaaaaaa

 

bump

Yan OliveiraY
30 de novembro de 2012 às 22:07

Tenta assim:

 

function getItemsInContainerById(container, itemid) -- Function By Kydrai
	local items = {}
	if isContainer(container) and getContainerSize(container) > 0 then
	   for slot=0, (getContainerSize(container)-1) do
					   local item = getContainerItem(container, slot)
					   if isContainer(item.uid) then
									  local itemsbag = getItemsInContainerById(item.uid, itemid)
									  for i=0, #itemsbag do
													  table.insert(items, itemsbag[i])
									  end
					   else
									  if itemid == item.itemid then
													 table.insert(items, item.uid)
									  end
					   end
	   end
	end
	return items
	end


	local combat = createCombatObject()
	setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
	setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
	setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SUDDENDEATH)
	setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -11, -80, -11, -120, 60, 60, 9.9, 9.9)

	function onCastSpell(cid, var)
	local YellowBag = getItemsInContainerById(getPlayerSlotItem(cid, 3).uid, 1992) --verifica se tem a yellow bag dentro da bag

	if #YellowBag >= 1 then

	   for i = 1, #YellowBag do													   --coloque o id aki!
					   local Item = getItemsInContainerById(YellowBag[i], 5952) --verifica se tem o item dentro de alguma yellow bag...
					   if #Item >= 1 then
									  return doCombat(cid, combat, var)
					   end
	   end
	end
	return FALSE
	end

 

Obs: Só arrumei um bug que tinha do Slicer.

Editado Novembro 30 por Yan18

SlicerS
30 de novembro de 2012 às 22:14

mano se tas flando disso..

local items = {1992,5952} 

o certo eh como estava e n desse jeito o.O

essa tabela items vai conter os UIDs dos itens na bag... n tem pq por os itemid ae... isso ja eh da propria funçao do kydrai...

 

@topic

a tua bag esta no slot 3? ;x

pq o script parece esta correto... ;/

Editado Novembro 30 por Slicer

Yan OliveiraY
30 de novembro de 2012 às 22:16

mano se tas flando disso..

local items = {1992,5952} 

o certo eh como estava e n desse jeito o.O

essa tabela items vai conter os UIDs dos itens na bag... n tem pq por os itemid ae... isso ja eh da propria funçao do kydrai...

 

Não foi isso q arrumei, eu tirei isso

 

principal...

 

tava dano error.

SlicerS
30 de novembro de 2012 às 22:49

tava dando erro pq o

 q o cara ali posto, bugou o script.. no meu acima estava certo.. ;D
BennyhappyB
01 de dezembro de 2012 às 16:57

Eu ainda tenho o mesmo problema, eu estou fazendo errado?

 

 

function getItemsInContainerById(container, itemid) -- Function By Kydrai
local items = {1992,5952}
if isContainer(container) and getContainerSize(container) > 0 then
   for slot=0, (getContainerSize(container)-1) do
		   local item = getContainerItem(container, slot)
		   if isContainer(item.uid) then
				  local itemsbag = getItemsInContainerById(item.uid, itemid)
				  for i=0, #itemsbag do
						  table.insert(items, itemsbag[i])
				  end
		   else
				  if itemid == item.itemid then
						 table.insert(items, item.uid)
				  end
		   end
   end
end
return items
end


local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HEALING)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_GREEN)
setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, 1)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, 0, 15000, 0, 20000)

function onCastSpell(cid, var)
local YellowBag = getItemsInContainerById(getPlayerSlotItem(cid, 3).uid, 1992) --verifica se tem a yellow bag dentro da bag

principal...
if #YellowBag >= 1 then
   for i = 1, #YellowBag do							  --coloque o id aki!
		   local Item = getItemsInContainerById(YellowBag[i], ITEMID) --verifica se tem o item dentro de alguma yellow bag...
		   if #Item >= 1 then
				  return doCombat(cid, combat, var)
		   end
   end
end
return FALSE
end

 

bump

Yan OliveiraY
01 de dezembro de 2012 às 17:01

Nessa parte vc tem q colocar o id da Bag:

 

local Item = getItemsInContainerById(YellowBag[i], ITEMID) --verifica se tem o item dentro de alguma yellow bag...

 

Em ITEMID.

BennyhappyB
01 de dezembro de 2012 às 20:25

aqui nesta linha

 

 

local Item = getItemsInContainerById(YellowBag, ITEMID) --verifica se tem o item dentro de alguma yellow bag...

 

 

colocar o ID 1992 do bag asim:

[color=#282828][size=2]local[/size][/color][color=#282828][size=2] [/size][/color][color=#282828][size=2]Item[/size][/color][color=#282828][size=2] [/size][/color][color=#282828][size=2]=[/size][/color][color=#282828][size=2] getItemsInContainerById[/size][/color][color=#282828][size=2]([/size][/color][color=#282828][size=2]YellowBag[/size][/color][color=#282828][size=2][[/size][/color][color=#282828][size=2]i[/size][/color][color=#282828][size=2]],[/size][/color][color=#282828][size=2] 1992[/size][/color][color=#282828][size=2])[/size][/color][color=#282828][size=2] [/size][/color][color=#282828][size=2]--[/size][/color][color=#282828][size=2]verifica se tem o item dentro de alguma yellow bag[/size][/color][color=#282828][size=2]...[/size][/color]

 

 

e também tentar o ID 5952 do scroll asim:

[color=#282828][size=2]local[/size][/color][color=#282828][size=2] [/size][/color][color=#282828][size=2]Item[/size][/color][color=#282828][size=2] [/size][/color][color=#282828][size=2]=[/size][/color][color=#282828][size=2] getItemsInContainerById[/size][/color][color=#282828][size=2]([/size][/color][color=#282828][size=2]YellowBag[/size][/color][color=#282828][size=2][[/size][/color][color=#282828][size=2]i[/size][/color][color=#282828][size=2]],[/size][/color][color=#282828][size=2]5952[/size][/color][color=#282828][size=2])[/size][/color][color=#282828][size=2] [/size][/color][color=#282828][size=2]--[/size][/color][color=#282828][size=2]verifica se tem o item dentro de alguma yellow bag[/size][/color][color=#282828][size=2]...[/size][/color]

 

 

mas não consegue fazê-lo funcionar

 

colocar o ID 1992 do bag asim:

aqui nesta linha:

 

local Item = getItemsInContainerById(YellowBag[i], 5952) --verifica se tem o item dentro de alguma yellow bag...

 

 

colocar o ID 1992 do bag asim:

[/size][size=4]local Item = getItemsInContainerById(YellowBag[i], [/size][color=#282828][font=helvetica, arial, sans-serif]1992[/font][/color][size=4]) --verifica se tem o item dentro de alguma yellow bag...[/size]
[size=4]

 

 

e também tentar o ID 5952 do scroll asim:

[/size][size=4]local Item = getItemsInContainerById(YellowBag[i], 5952) --verifica se tem o item dentro de alguma yellow bag...[/size]
[size=4]

 

mas não consegue fazê-lo funcionar

 

Eu não posso editar o meu post errado

Yan OliveiraY
01 de dezembro de 2012 às 20:29

Testa ae:

 

function getItemsInContainerById(container, itemid) -- Function By Kydrai
       local items = {1992,5952}
       if isContainer(container) and getContainerSize(container) > 0 then
          for slot=0, (getContainerSize(container)-1) do
                          local item = getContainerItem(container, slot)
                          if isContainer(item.uid) then
                                         local itemsbag = getItemsInContainerById(item.uid, itemid)
                                         for i=0, #itemsbag do
                                                         table.insert(items, itemsbag[i])
                                         end
                          else
                                         if itemid == item.itemid then
                                                        table.insert(items, item.uid)
                                         end
                          end
          end
       end
       return items
       end


       local combat = createCombatObject()
       setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HEALING)
       setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_GREEN)
       setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, 1)
       setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)
       setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, 0, 15000, 0, 20000)

       function onCastSpell(cid, var)
       local YellowBag = getItemsInContainerById(getPlayerSlotItem(cid, 3).uid, 1992) --verifica se tem a yellow bag dentro da bag

       principal...
       if #YellowBag >= 1 then
          for i = 1, #YellowBag do 5952                                                      --coloque o id aki!
                          local Item = getItemsInContainerById(YellowBag[i], 1992) --verifica se tem o item dentro de alguma yellow bag...
                          if #Item >= 1 then
                                         return doCombat(cid, combat, var)
                          end
          end
       end
       return FALSE
       end