Ir para conteúdo

Featured Replies

Postado

aí galera quem poder ajudar vou agradecer, qual o problema dessa script ? bom ela está quase 100% o unico problema dela que quando vc coloca o item no chão, o book fica infinito com isso o player fica usando infinitamente, aí ele vai ficar ganhando item sem parar.

 

local config = {
exhausttime = 7200, -- time in seconds
exhauststorage = 2301,
level = 50 -- level minimo para usar o book
}



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

local rewarditems = {
{id = 2492, chance = 10, count = 1}, -- id da demon legs
{id = 2498, chance = 10, count = 1}, -- id da demon armor
{id = 2488, chance = 10, count = 1}, -- id do demon shield
{id = 2488, chance = 20, count = 1}, -- id do demon helmet
{id = 2488, chance = 50, count = 1} -- id stell boots
}

if getPlayerLevel(cid) < config.level then
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
doPlayerSendCancel(cid, "Voce precisa estar ser level "..config.level.." para usar o livro.")
return true
end

if exhaustion.check(cid, config.exhauststorage) then
local time = exhaustion.get(cid, config.exhauststorage)
local hours, minutes, seconds = math.floor (time / 3600), math.floor ((time - ((math.floor (time / 3600)) * 3600))/ 60), time - ((math.floor (time/60)) * 60)
if time >= 3600 then
text = hours.." "..(hours > 1 and "hours" or "hour")..", "..minutes.." "..(minutes > 1 and "minutes" or "minute").." and "..seconds.." "..(seconds > 1 and "seconds" or "second")
elseif time >= 120 then
text = minutes.." "..(minutes > 1 and "minutes" or "minute").." and "..seconds.." "..(seconds > 1 and "seconds" or "second")
else
text = seconds.." "..(seconds > 1 and "seconds" or "second")
end
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Esta vazio, voce precisa esperar "..text.." antes de usar o livro novamente.")
return true
end



local chance = math.random(1,100)
for i = 1, #rewarditems, 1 do
if chance < rewarditems[i].chance then
local info = getItemInfo(rewarditems[i].id)
if rewarditems[i].count > 1 then
text = rewarditems[i].count .. " " .. info.plural
else
                 text = info.article .. " " .. info.name
end



	local item = doCreateItemEx(rewarditems[i].id, rewarditems[i].count)
	if(doPlayerAddItemEx(cid, item, false) ~= RETURNVALUE_NOERROR) then
	doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
	text = "Voce encontrou uma recompensa, mas voce nao tem cap ou espaco na bp para ganha-la."
	else
	local book = 1950
	doPlayerRemoveItem(cid, book, 1)
	text = "Voce encontrou " .. text .. "."
	exhaustion.set(cid, config.exhauststorage, config.exhausttime)
	end

	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, text)
	return true

else
chance = chance - rewarditems[i].chance
end
end
end
Postado

Tente assim:

local config = {
exhausttime = 7200, -- time in seconds
exhauststorage = 2301,
level = 50 -- level minimo para usar o book
}



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

local rewarditems = {
{id = 2492, chance = 10, count = 1}, -- id da demon legs
{id = 2498, chance = 10, count = 1}, -- id da demon armor
{id = 2488, chance = 10, count = 1}, -- id do demon shield
{id = 2488, chance = 20, count = 1}, -- id do demon helmet
{id = 2488, chance = 50, count = 1} -- id stell boots
}

if getPlayerLevel(cid) < config.level then
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
doPlayerSendCancel(cid, "Voce precisa estar ser level "..config.level.." para usar o livro.")
return true
end

if exhaustion.check(cid, config.exhauststorage) then
local time = exhaustion.get(cid, config.exhauststorage)
local hours, minutes, seconds = math.floor (time / 3600), math.floor ((time - ((math.floor (time / 3600)) * 3600))/ 60), time - ((math.floor (time/60)) * 60)
if time >= 3600 then
text = hours.." "..(hours > 1 and "hours" or "hour")..", "..minutes.." "..(minutes > 1 and "minutes" or "minute").." and "..seconds.." "..(seconds > 1 and "seconds" or "second")
elseif time >= 120 then
text = minutes.." "..(minutes > 1 and "minutes" or "minute").." and "..seconds.." "..(seconds > 1 and "seconds" or "second")
else
text = seconds.." "..(seconds > 1 and "seconds" or "second")
end
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Esta vazio, voce precisa esperar "..text.." antes de usar o livro novamente.")
return true
end



local chance = math.random(1,100)
for i = 1, #rewarditems, 1 do
if chance < rewarditems[i].chance then
local info = getItemInfo(rewarditems[i].id)
if rewarditems[i].count > 1 then
text = rewarditems[i].count .. " " .. info.plural
else
                 text = info.article .. " " .. info.name
end



	local item = doCreateItemEx(rewarditems[i].id, rewarditems[i].count)
	if(doPlayerAddItemEx(cid, item, false) ~= RETURNVALUE_NOERROR) then
	doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
	text = "Voce encontrou uma recompensa, mas voce nao tem cap ou espaco na bp para ganha-la."
	else
	doRemoveItem(item.uid, 1)
	text = "Voce encontrou " .. text .. "."
	exhaustion.set(cid, config.exhauststorage, config.exhausttime)
	end

	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, text)
	return true

else
chance = chance - rewarditems[i].chance
end
end
end

 

Postado
  • Autor
1 hora atrás, Wakon disse:

Tente assim:


local config = {
exhausttime = 7200, -- time in seconds
exhauststorage = 2301,
level = 50 -- level minimo para usar o book
}



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

local rewarditems = {
{id = 2492, chance = 10, count = 1}, -- id da demon legs
{id = 2498, chance = 10, count = 1}, -- id da demon armor
{id = 2488, chance = 10, count = 1}, -- id do demon shield
{id = 2488, chance = 20, count = 1}, -- id do demon helmet
{id = 2488, chance = 50, count = 1} -- id stell boots
}

if getPlayerLevel(cid) < config.level then
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
doPlayerSendCancel(cid, "Voce precisa estar ser level "..config.level.." para usar o livro.")
return true
end

if exhaustion.check(cid, config.exhauststorage) then
local time = exhaustion.get(cid, config.exhauststorage)
local hours, minutes, seconds = math.floor (time / 3600), math.floor ((time - ((math.floor (time / 3600)) * 3600))/ 60), time - ((math.floor (time/60)) * 60)
if time >= 3600 then
text = hours.." "..(hours > 1 and "hours" or "hour")..", "..minutes.." "..(minutes > 1 and "minutes" or "minute").." and "..seconds.." "..(seconds > 1 and "seconds" or "second")
elseif time >= 120 then
text = minutes.." "..(minutes > 1 and "minutes" or "minute").." and "..seconds.." "..(seconds > 1 and "seconds" or "second")
else
text = seconds.." "..(seconds > 1 and "seconds" or "second")
end
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Esta vazio, voce precisa esperar "..text.." antes de usar o livro novamente.")
return true
end



local chance = math.random(1,100)
for i = 1, #rewarditems, 1 do
if chance < rewarditems[i].chance then
local info = getItemInfo(rewarditems[i].id)
if rewarditems[i].count > 1 then
text = rewarditems[i].count .. " " .. info.plural
else
                 text = info.article .. " " .. info.name
end



	local item = doCreateItemEx(rewarditems[i].id, rewarditems[i].count)
	if(doPlayerAddItemEx(cid, item, false) ~= RETURNVALUE_NOERROR) then
	doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
	text = "Voce encontrou uma recompensa, mas voce nao tem cap ou espaco na bp para ganha-la."
	else
	doRemoveItem(item.uid, 1)
	text = "Voce encontrou " .. text .. "."
	exhaustion.set(cid, config.exhauststorage, config.exhausttime)
	end

	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, text)
	return true

else
chance = chance - rewarditems[i].chance
end
end
end

 

Sem título.png

aí cara, infelizmente não funcionou. Quando clika pra ganhar o item o book abre e da um item, e nem remove. :( 

Editado por helix758 (veja o histórico de edições)

Postado

Pronto:

local config = {
    exhausttime = 7200, -- time in seconds
    exhauststorage = 2302,
    level = 50 -- level minimo para usar o book
}

local rewarditems = {
    {id = 2492, chance = 10, count = 1}, -- id da demon legs
    {id = 2498, chance = 10, count = 1}, -- id da demon armor
    {id = 2488, chance = 10, count = 1}, -- id do demon shield
    {id = 2488, chance = 20, count = 1}, -- id do demon helmet
    {id = 2488, chance = 50, count = 1} -- id stell boots
}

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

    if getPlayerLevel(cid) < config.level then
        doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
        return doPlayerSendCancel(cid, "Você precisa ser level "..config.level.." para usar o livro.") and true
    end

    if exhaustion.check(cid, config.exhauststorage) then
        local time = exhaustion.get(cid, config.exhauststorage)
        local hours, minutes, seconds = math.floor (time / 3600), math.floor ((time - ((math.floor (time / 3600)) * 3600))/ 60), time - ((math.floor (time/60)) * 60)
        if time >= 3600 then
            text = hours.." "..(hours > 1 and "horas" or "hora")..", "..minutes.." "..(minutes > 1 and "minutos" or "minuto").." e "..seconds.." "..(seconds > 1 and "segundos" or "segundo")
        elseif time >= 120 then
            text = minutes.." "..(minutes > 1 and "minutos" or "minuto").." and "..seconds.." "..(seconds > 1 and "segundos" or "segundo")
        else
            text = seconds.." "..(seconds > 1 and "segundos" or "segundo")
        end
        doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Você precisa esperar "..text.." antes de usar o livro novamente.")
       return true
    end



    local chance = math.random(1,100)
    for i = 1, #rewarditems, 1 do
        if chance < rewarditems[i].chance then
        local info = getItemInfo(rewarditems[i].id)
            if rewarditems[i].count > 1 then
                text = rewarditems[i].count .. " " .. info.plural
            else
                 text = info.article .. " " .. info.name
            end
        local reward = doCreateItemEx(rewarditems[i].id, rewarditems[i].count)
        if(doPlayerAddItemEx(cid, reward, false) ~= RETURNVALUE_NOERROR) then
            doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
            text = "Você não tem cap ou espaço em sua backpack para receber o item."
        else
            doRemoveItem(item.uid, 1)
            text = "Você encontrou 1 ".. text .."."
            exhaustion.set(cid, config.exhauststorage, config.exhausttime)
        end
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, text)
           return true
        else
            chance = chance - rewarditems[i].chance
        end
    end
return true
end

E @helix758, evite de criar tópicos com títulos inadequados, leia as regras:

 

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo