LU
dúvida

Função Para Obter Slots Livres Do Player

Por LuckOake, 25 de ago. de 2012 em Scripts

6
1.1k
LuckOakeL
25 de agosto de 2012 às 18:13

Olá olá :)

 

Como todos sabem, sempre tem um babaca que fica dando use em platinum coins estando sem espaço na backpack, e então cai 100 gold coins no chão e suja o templo todo.

 

Eu gostaria de saber se existe alguma função que obtenha os slots livres do player, e se ele não tiver nenhum, ser bloqueado de usar.

VodkartV
25 de agosto de 2012 às 18:49

você pode usar o seguinte:

 

 

 

function getContainerSlotsFree(container) -- by vodka
return getContainerCap(container)-getContainerSize(container)
end

 

vai retornar quantos slots tem sobrando no contêiner

Editado Agosto 25 por Vodkart

brun123B
25 de agosto de 2012 às 19:17

Substitua o seu changegold com esse:

 

 

local coins = {
   [iTEM_GOLD_COIN] = {
       to = ITEM_PLATINUM_COIN, effect = TEXTCOLOR_YELLOW
   },
   [iTEM_PLATINUM_COIN] = {
       from = ITEM_GOLD_COIN, to = ITEM_CRYSTAL_COIN, effect = TEXTCOLOR_LIGHTBLUE
   },
   [iTEM_CRYSTAL_COIN] = {
       from = ITEM_PLATINUM_COIN, effect = TEXTCOLOR_TEAL
   }
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
   if(getPlayerFlagValue(cid, PLAYERFLAG_CANNOTPICKUPITEM)) then
       return false
   end

   local coin = coins[item.itemid]
   if(not coin) then
       return false
   end

   if(coin.to ~= nil and item.type == ITEMCOUNT_MAX) then
     if not doPlayerAddItem(cid, coin.to, 1, false) then
     return doPlayerSendCancel(cid, "You don't have enough space in your backpack.")
     end
       doChangeTypeItem(item.uid, item.type - item.type)
       doSendAnimatedText(fromPosition, "$$$", coins[coin.to].effect)
   elseif(coin.from ~= nil) then
     if not doPlayerAddItem(cid, coin.from, ITEMCOUNT_MAX, false) then
     return doPlayerSendCancel(cid, "You don't have enough space in your backpack.")
     end
       doChangeTypeItem(item.uid, item.type - 1)
       doSendAnimatedText(fromPosition, "$$$", coins[coin.from].effect)
   end
   return true
end

 

LuckOakeL
25 de agosto de 2012 às 19:20

@brun123

 

Então é só colocar isso aqui, né:

 

if not doPlayerAddItem(cid, coin.from, 1, false) then
return doPlayerSendCancel(cid, "You don't have enough space in your backpack.")
end

 

if not doPlayerAddItem(cid, coin.from, ITEMCOUNT_MAX, false) then
return doPlayerSendCancel(cid, "You don't have enough space in your backpack.")
end

 

~~ Edit ~~

 

Agora os items estão se clonando.

Editado Agosto 25 por LuckOake

brun123B
25 de agosto de 2012 às 19:31

Porque você colocou com ordem errada, não é só colocar esse código, tem que tirar outra linha e inverter a ordem das coisas acontecerem. Experimenta pegar meu script

LuckOakeL
25 de agosto de 2012 às 19:36

Certo, deu. Só não entendi a parte do "inverter a ordem das coisas acontecerem". Explica?

Editado Agosto 25 por LuckOake