Ir para conteúdo
  • 0

cancelar effect assim q pegar battle


rohfagundes

Pergunta

é sobre um script de rest

ja coloquei pra n conseguir ativar se estiver com battle

porem n to conseguindo colocar pra se ele estiver com o rest ativo

e pegar battle n da pra desativar

 

queria algo assim se ele estiver com o rest ativa

e pegar battle desativa sozinho o rest

 

 

events = {}

config = {

sit = {hp = 5, mana = 5},

battle = true,

storage = 21211

}

 

function onUse(cid, item, fromPosition, item2, toPosition)

if config.battle == true and getCreatureCondition(cid, CONDITION_INFIGHT) == TRUE then

doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You can not rest in battle.")

return false

end

setPlayerStorageValue(cid, config.storage, getPlayerStorageValue(cid, config.storage) == -1 and 1 or -1)

doCreatureSetNoMove(cid, getPlayerStorageValue(cid, config.storage) == 1 and true or false)

if getPlayerStorageValue(cid, config.storage) == 1 then

doPlayerSendCancel(cid, "You are resting.")

doSendMagicEffect(getCreaturePosition(cid), 14)

doTransformItem(item.uid, 11443) -- item q vai virar depois de usar

doSitRelax(cid, config.sit)

else

doPlayerSendCancel(cid, "You stopped to rest.")

doTransformItem(item.uid, 11442) -- item antes de usar

stopEvent(events[getPlayerGUID(cid)])

end

return true

end

function doSitRelax(cid, formula)

if not isCreature(cid) then return LUA_ERROR end

doCreatureAddHealth(cid, formula.hp)

doCreatureAddMana(cid, formula.mana)

doSendMagicEffect(getCreaturePosition(cid), 14)

events[getPlayerGUID(cid)] = addEvent(doSitRelax, 5000, cid, formula)

end

 

Link para o comentário
Compartilhar em outros sites

14 respostass a esta questão

Posts Recomendados

  • 0

tenta assim..

 

events = {}
config = {
sit = {hp = 5, mana = 5},
battle = true,
storage = 21211
}

function onUse(cid, item, fromPosition, item2, toPosition)
if config.battle == true and getCreatureCondition(cid, CONDITION_INFIGHT) == TRUE then
  doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You can not rest in battle.")
  return false
end
setPlayerStorageValue(cid, config.storage, getPlayerStorageValue(cid, config.storage) == -1 and 1 or -1)
doCreatureSetNoMove(cid, getPlayerStorageValue(cid, config.storage) == 1 and true or false)
if getPlayerStorageValue(cid, config.storage) == 1 then
  doPlayerSendCancel(cid, "You are resting.")
  doSendMagicEffect(getCreaturePosition(cid), 14)
  doTransformItem(item.uid, 11443) -- item q vai virar depois de usar
  doSitRelax(cid, config.sit)
else
  doPlayerSendCancel(cid, "You stopped to rest.")
  doTransformItem(item.uid, 11442) -- item antes de usar
  stopEvent(events[getPlayerGUID(cid)])
end
return true
end
function doSitRelax(cid, formula)
if not isCreature(cid) then return LUA_ERROR end
if getCreatureCondition(cid, CONDITION_INFIGHT) and events[getPlayerGUID(cid)] then
  stopEvent(events[getPlayerGUID(cid)])
  events[getPlayerGUID(cid)] = nil
end
doCreatureAddHealth(cid, formula.hp)
doCreatureAddMana(cid, formula.mana)
doSendMagicEffect(getCreaturePosition(cid), 14)
events[getPlayerGUID(cid)] = addEvent(doSitRelax, 5000, cid, formula)
end

 

Link para o comentário
Compartilhar em outros sites

  • 0

if getCreatureCondition(cid, CONDITION_INFIGHT) and events[getPlayerGUID(cid)] then
  stopEvent(events[getPlayerGUID(cid)])
  events[getPlayerGUID(cid)] = nil
end

troca para..

if getCreatureCondition(cid, CONDITION_INFIGHT) and events[getPlayerGUID(cid)] then
  stopEvent(events[getPlayerGUID(cid)])
  events[getPlayerGUID(cid)] = nil
return true
end

vo nem comenta o erro bobo ;x

Editado por Slicer
Link para o comentário
Compartilhar em outros sites

  • 0

nem tinha reparado nisso...

tive q mudar os parametros e n garanto q o item va voltar ao q era ;x -mexer com uid eh uma droga...-

 

events = {}
config = {
sit = {hp = 5, mana = 5},
battle = true,
storage = 21211
}

function onUse(cid, item, fromPosition, item2, toPosition)
if config.battle == true and getCreatureCondition(cid, CONDITION_INFIGHT) == TRUE then
  doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You can not rest in battle.")
  return false
end
setPlayerStorageValue(cid, config.storage, getPlayerStorageValue(cid, config.storage) == -1 and 1 or -1)
doCreatureSetNoMove(cid, getPlayerStorageValue(cid, config.storage) == 1 and true or false)
if getPlayerStorageValue(cid, config.storage) == 1 then
  doPlayerSendCancel(cid, "You are resting.")
  doSendMagicEffect(getCreaturePosition(cid), 14)
  doTransformItem(item.uid, 11443) -- item q vai virar depois de usar
  doSitRelax(cid, config.sit, item)
else
  doPlayerSendCancel(cid, "You stopped to rest.")
  doTransformItem(item.uid, 11442) -- item antes de usar
  stopEvent(events[getPlayerGUID(cid)])
end
return true
end
function doSitRelax(cid, formula, item)
if not isCreature(cid) then return LUA_ERROR end
if getCreatureCondition(cid, CONDITION_INFIGHT) and events[getPlayerGUID(cid)] then
  stopEvent(events[getPlayerGUID(cid)])
  events[getPlayerGUID(cid)] = nil
  setPlayerStorageValue(cid, config.storage, -1)
  doCreatureSetNoMove(cid, false)
  doTransformItem(item.uid, 11442)
  return true
end
doCreatureAddHealth(cid, formula.hp)
doCreatureAddMana(cid, formula.mana)
doSendMagicEffect(getCreaturePosition(cid), 14)
events[getPlayerGUID(cid)] = addEvent(doSitRelax, 5000, cid, formula, item)
end

 

 

-se o item n voltar ao id 11442 dai vo ter q complicar teu script kkk-

Editado por Slicer
Link para o comentário
Compartilhar em outros sites

  • 0

eh foi oq eu pensei...

eu n sei se o item ae fica na bag ou nos slots do set... qlqr coisa se n funcionar avisa..

 

local 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 function doSitRelax(cid, formula, itemID)
if not isCreature(cid) then return LUA_ERROR end
if getCreatureCondition(cid, CONDITION_INFIGHT) and events[getPlayerGUID(cid)] then
  stopEvent(events[getPlayerGUID(cid)])
  events[getPlayerGUID(cid)] = nil
  setPlayerStorageValue(cid, config.storage, -1)
  doCreatureSetNoMove(cid, false)
  --
  local itens = getItemsInContainerById(getPlayerSlotItem(cid, 3).uid, itemID)
  if #itens >= 1 then
  for _, item in ipairs(itens) do
	  doTransformItem(item, 11442)
  end
  end
  return true
end
doCreatureAddHealth(cid, formula.hp)
doCreatureAddMana(cid, formula.mana)
doSendMagicEffect(getCreaturePosition(cid), 14)
events[getPlayerGUID(cid)] = addEvent(doSitRelax, 5000, cid, formula, itemID)
end

events = {}
config = {
sit = {hp = 5, mana = 5},
battle = true,
storage = 21211
}

function onUse(cid, item, fromPosition, item2, toPosition)
if config.battle == true and getCreatureCondition(cid, CONDITION_INFIGHT) == TRUE then
  doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You can not rest in battle.")
  return false
end
setPlayerStorageValue(cid, config.storage, getPlayerStorageValue(cid, config.storage) == -1 and 1 or -1)
doCreatureSetNoMove(cid, getPlayerStorageValue(cid, config.storage) == 1 and true or false)
if getPlayerStorageValue(cid, config.storage) == 1 then
  doPlayerSendCancel(cid, "You are resting.")
  doSendMagicEffect(getCreaturePosition(cid), 14)
  doTransformItem(item.uid, 11443) -- item q vai virar depois de usar
  doSitRelax(cid, config.sit, 11443)
else
  doPlayerSendCancel(cid, "You stopped to rest.")
  doTransformItem(item.uid, 11442) -- item antes de usar
  stopEvent(events[getPlayerGUID(cid)])
end
return true
end

 

Link para o comentário
Compartilhar em outros sites

  • 0

ah blz, entao achu q agora vai..

 

local 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 function doSitRelax(cid, formula, itemID)
if not isCreature(cid) then return LUA_ERROR end
if getCreatureCondition(cid, CONDITION_INFIGHT) and events[getPlayerGUID(cid)] then
  stopEvent(events[getPlayerGUID(cid)])
  events[getPlayerGUID(cid)] = nil
  setPlayerStorageValue(cid, config.storage, -1)
  doCreatureSetNoMove(cid, false)
  --
  local itens = getItemsInContainerById(getPlayerSlotItem(cid, CONST_SLOT_RING).uid, itemID)
  if #itens >= 1 then
  for _, item in ipairs(itens) do
	  doTransformItem(item, 11442)
  end
  end
  return true
end
doCreatureAddHealth(cid, formula.hp)
doCreatureAddMana(cid, formula.mana)
doSendMagicEffect(getCreaturePosition(cid), 14)
events[getPlayerGUID(cid)] = addEvent(doSitRelax, 5000, cid, formula, itemID)
end

events = {}
config = {
sit = {hp = 5, mana = 5},
battle = true,
storage = 21211
}

function onUse(cid, item, fromPosition, item2, toPosition)
if config.battle == true and getCreatureCondition(cid, CONDITION_INFIGHT) == TRUE then
  doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You can not rest in battle.")
  return false
end
setPlayerStorageValue(cid, config.storage, getPlayerStorageValue(cid, config.storage) == -1 and 1 or -1)
doCreatureSetNoMove(cid, getPlayerStorageValue(cid, config.storage) == 1 and true or false)
if getPlayerStorageValue(cid, config.storage) == 1 then
  doPlayerSendCancel(cid, "You are resting.")
  doSendMagicEffect(getCreaturePosition(cid), 14)
  doTransformItem(item.uid, 11443) -- item q vai virar depois de usar
  doSitRelax(cid, config.sit, 11443)
else
  doPlayerSendCancel(cid, "You stopped to rest.")
  doTransformItem(item.uid, 11442) -- item antes de usar
  stopEvent(events[getPlayerGUID(cid)])
end
return true
end

 

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...