SK

[Dúvida]

Por Skymagnum, 17 de mar. de 2013 em Clients

5
900
SkymagnumS
17 de março de 2013 às 00:41

Como faço uma nova cooldown bar, checando uma condição do player tipo quero que nessa cooldown mostre isso

 

 

getPlayerFood(cid) / 2500

 

alguém ajuda por favor.

BananaFightB
17 de março de 2013 às 01:31

Creio que isso resolva seu problema.

 

  local player = g_game.getLocalPlayer()
 if g_game.getFeature(GamePlayerRegenerationTime) then
if player:getRegenerationTime() < 600 then
  g_game.useInventoryItem(itemId)
end
 end

 

só pra constar, itemid, é o id do data do item. e não do arquivo item.xml.

Editado Março 17 por BananaFight

SlicerS
17 de março de 2013 às 16:33

achu q tu n intendeu banana ;x

achu q ele quer uma barra, tpw a de life, q fique atualizando com a fome do player... monstrando qnt de fome o player ta e o maximo q pode chegar... ;x

 

esse RegenerationTime eh a food?

BananaFightB
17 de março de 2013 às 18:15

Você pode usar um progress bar

 

 ProgressBar
   id: foodBar
   background-color: #ff4444
   anchors.top: parent.top
   anchors.left: parent.left
   anchors.right: parent.right
   margin: 1

 

ai você usa uma função que vai adicionar os valores dentro do progress bar, como por exempo o do health

 

healthBar = healthInfoWindow:recursiveGetChildById('healthBar')


function onHealthChange(localPlayer, health, maxHealth)
 healthBar:setText(health .. ' / ' .. maxHealth)
 healthBar:setTooltip(tr(healthTooltip, health, maxHealth))
 healthBar:setValue(health, 0, maxHealth)
end


function setHealthTooltip(tooltip)
 healthTooltip = tooltip

 local localPlayer = g_game.getLocalPlayer()
 if localPlayer then
   healthBar:setTooltip(tr(healthTooltip, localPlayer:getHealth(), localPlayer:getMaxHealth()))
 end
end

 

no int você deixa assim, mais com o nome da sua função

 

 connect(LocalPlayer, { onHealthChange = onHealthChange })


 if g_game.isOnline() then
   local localPlayer = g_game.getLocalPlayer()
   onHealthChange(localPlayer, localPlayer:getHealth(), localPlayer:getMaxHealth())
 end

 

e em terminate a mesma coisa.

 

 disconnect(LocalPlayer, { onHealthChange = onHealthChange })

SkymagnumS
17 de março de 2013 às 22:51

Era isso mesmo banana valeu, quando tiver eu dou rep+.