Ir para conteúdo
  • 0

Poder usar o Item somente 1x


atakashi

Pergunta

Alguém pode me ajudar.
eu tenho um script aqui de box prize de pokemon, e quero que o jogador só possa abrir essa box 1x por personagem.
caso ele adquirir outra ele não possa abrir denovo.
local a = {
[13769] = {balltype = "ultra", ballid = 11829,
        pokemons = {"Shiny Charizard"}},


}
      


function onUse(cid, item, frompos, item2, topos)


         local b = a[item.itemid]                                    
               if not b then return true end
         local pokemon = b.pokemons[math.random(#b.pokemons)]
         local btype = b.balltype
               if not pokeballs[btype] then return true end
         local gender = getRandomGenderByName(pokemon)
         local happy = 220
         
         local ball = 0
         local sendToDepot = false                                                        --alterado v1.6
	     if getCreatureMana(cid) >= 6 or not hasSpaceInContainer(getPlayerSlotItem(cid, 3).uid) then
               sendToDepot = true
               ball = doCreateItemEx(b.ballid)   --alterado v1.3
         else
               ball = item.uid
         end 
         
           doItemSetAttribute(ball, "poke", pokemon)
           doItemSetAttribute(ball, "hp", 1)
		   doItemSetAttribute(ball, "happy", happy)
		   doItemSetAttribute(ball, "gender", gender)
		   if pokemon == "Hitmonchan" or pokemon == "Shiny Hitmonchan" then
		      doItemSetAttribute(ball, "hands", 0)
           end
		   doItemSetAttribute(ball, "description", "Contains a "..pokemon..".")
		   doItemSetAttribute(ball, "fakedesc", "Contains a "..pokemon..".")

		   doItemSetAttribute(ball, "boost", 50)    


	local nick = "".. getPlayerName(cid) ..""
	local description = "Contains a "..getItemAttribute(ball, "poke").."."
	doItemSetAttribute(ball, "nick", nick)
	local newdes = description.."\nIt's nickname is: ".. getPlayerName(cid) .."."
	doItemSetAttribute(ball, "description", newdes)
	local hp = getItemAttribute(ball, "happy")
	doItemSetAttribute(ball, "happy", hp + 25)
  
    
         doPlayerSendTextMessage(cid, 27, "You opened a pokemon prize box +"..item.itemid - (11637).."!")
	     doPlayerSendTextMessage(cid, 27, "The prize pokemon was a "..pokemon..", congratulations!")
	     






	     if sendToDepot then
            doPlayerSendMailByName(getCreatureName(cid), ball, 1)    --alterado v1.3
            doPlayerSendTextMessage(cid, 27, "You are already holding six pokemons, so your new pokemon was sent to your depot.")
           setPlayerStorageValue(cid, 85552, os.time () + 9999)
            doRemoveItem(item.uid)
         else
             doTransformItem(ball, pokeballs[btype].on)
	     end


	     
	     doSendMagicEffect(getThingPos(cid), 29)
return true
end


 

Link para o comentário
Compartilhar em outros sites

5 respostass a esta questão

Posts Recomendados

  • 0

Tente assim

 

local a = {
[13769] = {balltype = "ultra", ballid = 11829,
pokemons = {"Shiny Charizard"}},


}



function onUse(cid, item, frompos, item2, topos)

 

if getCreatureStorageValue(cid, 8465) == 1 then

return 0

end

local b = a[item.itemid]
if not b then return true end
local pokemon = b.pokemons[math.random(#b.pokemons)]
local btype = b.balltype
if not pokeballs[btype] then return true end
local gender = getRandomGenderByName(pokemon)
local happy = 220

local ball = 0
local sendToDepot = false --alterado v1.6
if getCreatureMana(cid) >= 6 or not hasSpaceInContainer(getPlayerSlotItem(cid, 3).uid) then
sendToDepot = true
ball = doCreateItemEx(b.ballid) --alterado v1.3
else
ball = item.uid
end

doItemSetAttribute(ball, "poke", pokemon)
doItemSetAttribute(ball, "hp", 1)
doItemSetAttribute(ball, "happy", happy)
doItemSetAttribute(ball, "gender", gender)
if pokemon == "Hitmonchan" or pokemon == "Shiny Hitmonchan" then
doItemSetAttribute(ball, "hands", 0)
end
doItemSetAttribute(ball, "description", "Contains a "..pokemon..".")
doItemSetAttribute(ball, "fakedesc", "Contains a "..pokemon..".")

doItemSetAttribute(ball, "boost", 50)


local nick = "".. getPlayerName(cid) ..""
local description = "Contains a "..getItemAttribute(ball, "poke").."."
doItemSetAttribute(ball, "nick", nick)
local newdes = description.."\nIt's nickname is: ".. getPlayerName(cid) .."."
doItemSetAttribute(ball, "description", newdes)
local hp = getItemAttribute(ball, "happy")
doItemSetAttribute(ball, "happy", hp + 25)


doPlayerSendTextMessage(cid, 27, "You opened a pokemon prize box +"..item.itemid - (11637).."!")
doPlayerSendTextMessage(cid, 27, "The prize pokemon was a "..pokemon..", congratulations!")







if sendToDepot then
doPlayerSendMailByName(getCreatureName(cid), ball, 1) --alterado v1.3
doPlayerSendTextMessage(cid, 27, "You are already holding six pokemons, so your new pokemon was sent to your depot.")
setPlayerStorageValue(cid, 85552, os.time () + 9999)

setPlayerStorageValue(cid, 8465, 1)
doRemoveItem(item.uid)
else
doTransformItem(ball,pokeballs[btype].on)
end



doSendMagicEffect
(getThingPos(cid), 29)
return true
end

 

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

  • 0

Tenta assim:

local a = {
[13769] = {balltype = "ultra", ballid = 11829,
        pokemons = {"Shiny Charizard"}},


}
      


function onUse(cid, item, frompos, item2, topos)
local stor = 213654
 if getPlayerStorageValue(cid, stor) == 1 then
 doPlayerSendCancel(cid, "Você não pode usar novamente!")
 return true
 end

         local b = a[item.itemid]                                    
               if not b then return true end
         local pokemon = b.pokemons[math.random(#b.pokemons)]
         local btype = b.balltype
               if not pokeballs[btype] then return true end
         local gender = getRandomGenderByName(pokemon)
         local happy = 220
         
         local ball = 0
         local sendToDepot = false                                                        --alterado v1.6
	     if getCreatureMana(cid) >= 6 or not hasSpaceInContainer(getPlayerSlotItem(cid, 3).uid) then
               sendToDepot = true
               ball = doCreateItemEx(b.ballid)   --alterado v1.3
         else
               ball = item.uid
         end 
         
           doItemSetAttribute(ball, "poke", pokemon)
           doItemSetAttribute(ball, "hp", 1)
		   doItemSetAttribute(ball, "happy", happy)
		   doItemSetAttribute(ball, "gender", gender)
		   if pokemon == "Hitmonchan" or pokemon == "Shiny Hitmonchan" then
		      doItemSetAttribute(ball, "hands", 0)
           end
		   doItemSetAttribute(ball, "description", "Contains a "..pokemon..".")
		   doItemSetAttribute(ball, "fakedesc", "Contains a "..pokemon..".")

		   doItemSetAttribute(ball, "boost", 50)    


	local nick = "".. getPlayerName(cid) ..""
	local description = "Contains a "..getItemAttribute(ball, "poke").."."
	doItemSetAttribute(ball, "nick", nick)
	local newdes = description.."\nIt's nickname is: ".. getPlayerName(cid) .."."
	doItemSetAttribute(ball, "description", newdes)
	local hp = getItemAttribute(ball, "happy")
	doItemSetAttribute(ball, "happy", hp + 25)
  
    
         doPlayerSendTextMessage(cid, 27, "You opened a pokemon prize box +"..item.itemid - (11637).."!")
	     doPlayerSendTextMessage(cid, 27, "The prize pokemon was a "..pokemon..", congratulations!")
	     






	     if sendToDepot then
            doPlayerSendMailByName(getCreatureName(cid), ball, 1)    --alterado v1.3
            doPlayerSendTextMessage(cid, 27, "You are already holding six pokemons, so your new pokemon was sent to your depot.")
           setPlayerStorageValue(cid, 85552, os.time () + 9999)
            doRemoveItem(item.uid)
         else
             doTransformItem(ball, pokeballs[btype].on)
	     end


	     setPlayerStorageValue(cid, stor, 1)
	     doSendMagicEffect(getThingPos(cid), 29)
return true
end
Editado por Alencar522
Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...