Ir para conteúdo

Featured Replies

Postado

@luanluciano93 fiquei recebendo a mensagem de que eu já tinha um personagem participando do boss e tal mas os 2 receberam loot anyway, nenhum erro no console 

  • Respostas 92
  • Visualizações 22.4k
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • luanluciano93
    luanluciano93

    msg = msg .. " ".. (tabela_reward[x][2] > 1 and tabela_reward[x][2] or "") .." ".. getItemNameById(tabela_reward[x][1]) ..","  

  • luanluciano93
    luanluciano93

    pessoal, só final de semana para fixar

  • Coloquei em meu servidor 8.60 (TFS 0.4) e funcionou de primeira sem erros na distro ou algo parecido. Sistema perfeito. Rep + !! Uma dica para quem quer imitar o global com este sistema e ter uma

Posted Images

Postado
  • Autor
-- Sistema de recompensa criado por luanluciano93

dofile('data/sistemas/rewardchest.lua')

local function addRewardLoot(uid, bossName, tabela_reward)
	local money = math.random(10, 40)
	local msg = "The following items are available in your reward chest:"
	local chest = doCreateItemEx(REWARDCHEST.rewardBagId)

	doItemSetAttribute(chest, "description", "Reward System has kill the boss ".. bossName ..".")

	if table.maxn(tabela_reward) > 0 then
		for x = 1, table.maxn(tabela_reward) do
			local rand = math.random(100)
			if rand <= tabela_reward[x][3] then
				local count = math.random(1, tabela_reward[x][2])
				doAddContainerItem(chest, tabela_reward[x][1], count)
				msg = msg .. " ".. (count > 1 and count or "") .." "..getItemNameById(tabela_reward[x][1])..","
			end
		end
		doPlayerSendTextMessage(uid, MESSAGE_INFO_DESCR, msg .. " and ".. money .." platinum coins.")
	else
		doPlayerSendTextMessage(uid, MESSAGE_INFO_DESCR, msg .. " ".. money .." platinum coins.")
	end

	doAddContainerItem(chest, 2152, money)
	doPlayerSendMailByName(getPlayerName(uid), chest, REWARDCHEST.town_id)

	local boss = REWARDCHEST.bosses[bossName]
	setPlayerStorageValue(uid, boss.storage, 0)
	doSendMagicEffect(getPlayerPosition(uid), CONST_ME_MAGIC_BLUE)
end

local function addLoot(tabela_loot, tabela_reward, all_loot)
	if table.maxn(tabela_loot) > 0 then
		if all_loot then
			for x = 1, table.maxn(tabela_loot) do
				table.insert(tabela_reward, tabela_loot[x])
			end
		else
			table.insert(tabela_reward, tabela_loot[math.random(table.maxn(tabela_loot))])
		end
	end

	return tabela_reward
end

local function onMc(uid, storage)
	for _, mc in pairs(getPlayersOnline()) do
		if getPlayerIp(uid) == getPlayerIp(mc) and getPlayerStorageValue(mc, storage) > 0 then
			return false
		end
	end
	return true
end

local function rewardChestSystem(bossName)
	local players = {}
	local boss = REWARDCHEST.bosses[bossName]

	for _, uid in ipairs(getPlayersOnline()) do
		if getPlayerStorageValue(uid, boss.storage) > 0 then
			if onMc(uid, boss.storage) then
				table.insert(players, uid)
			end
		end
	end

	table.sort(players, function(a, b) return getPlayerStorageValue(a, boss.storage) > getPlayerStorageValue(b, boss.storage) end)

	local porcentagem = math.ceil(getPlayerStorageValue(players[1], boss.storage))

	for i = 1, table.maxn(players) do

		local tabela_reward = {}
		local pontos = getPlayerStorageValue(players[i], boss.storage)

		if i == 1 then
			addLoot(boss.comum, tabela_reward, false)
			addLoot(boss.semi_raro, tabela_reward, false)
			addLoot(boss.raro, tabela_reward, false)
			addLoot(boss.sempre, tabela_reward, true)
		elseif i >= 2 and pontos >= math.ceil((porcentagem * 0.8)) then
			addLoot(boss.comum, tabela_reward, false)
			addLoot(boss.semi_raro, tabela_reward, false)
			addLoot(boss.raro, tabela_reward, false)
			addLoot(boss.muito_raro, tabela_reward, false)
		elseif pontos < math.ceil((porcentagem * 0.8)) and pontos >= math.ceil((porcentagem * 0.6)) then
			addLoot(boss.comum, tabela_reward, false)
			addLoot(boss.semi_raro, tabela_reward, false)
			addLoot(boss.raro, tabela_reward, false)
		elseif pontos < math.ceil((porcentagem * 0.6)) and pontos >= math.ceil((porcentagem * 0.4)) then
			addLoot(boss.comum, tabela_reward, false)
			addLoot(boss.semi_raro, tabela_reward, false)
		elseif pontos < math.ceil((porcentagem * 0.4)) and pontos >= math.ceil((porcentagem * 0.1)) then
			addLoot(boss.comum, tabela_reward, false)
		end

		addRewardLoot(players[i], bossName, tabela_reward)
	end
end

function onDeath(cid, corpse, killer)
	local boss = REWARDCHEST.bosses[getCreatureName(cid):lower()]
	if boss then
		addEvent(rewardChestSystem, 1000, getCreatureName(cid):lower())
	end
	return true
end

function onStatsChange(cid, attacker, type, combat, value)
	if isMonster(cid) and type == STATSCHANGE_HEALTHLOSS and isPlayer(attacker) then
		local boss = REWARDCHEST.bosses[getCreatureName(cid):lower()]
		if boss and attacker then
			setPlayerStorageValue(attacker, boss.storage, getPlayerStorageValue(attacker, boss.storage) + math.ceil((value / REWARDCHEST.formula.hit)))
		end
	end
	return true
end

 

Postado

agr nenhum dos 2 ganham premios, erro no console:

[15:1:01.683] [Error - CreatureScript Interface]
[15:1:01.695] In a timer event called from:
[15:1:01.696] data/creaturescripts/scripts/rewardchest_boss.lua:onDeath
[15:1:01.698] Description:
[15:1:01.699] (LuaInterface::luaGetCreatureStorage) Creature not found

[15:1:01.712] [Error - CreatureScript Interface]
[15:1:01.714] In a timer event called from:
[15:1:01.715] data/creaturescripts/scripts/rewardchest_boss.lua:onDeath
[15:1:01.716] Description:
[15:1:01.718] data/creaturescripts/scripts/rewardchest_boss.lua:71: bad argument #1 to 'ceil' (number expected, got boolean)
[15:1:01.791] stack traceback:
[15:1:01.793]   [C]: in function 'ceil'
[15:1:01.794]   data/creaturescripts/scripts/rewardchest_boss.lua:71: in function <data/creaturescripts/scripts/rewardchest_boss.lua:57>

 

Postado
  • Autor
5 minutos atrás, Gabrieldsadaxas disse:

agr nenhum dos 2 ganham premios, erro no console:


[15:1:01.683] [Error - CreatureScript Interface]
[15:1:01.695] In a timer event called from:
[15:1:01.696] data/creaturescripts/scripts/rewardchest_boss.lua:onDeath
[15:1:01.698] Description:
[15:1:01.699] (LuaInterface::luaGetCreatureStorage) Creature not found

[15:1:01.712] [Error - CreatureScript Interface]
[15:1:01.714] In a timer event called from:
[15:1:01.715] data/creaturescripts/scripts/rewardchest_boss.lua:onDeath
[15:1:01.716] Description:
[15:1:01.718] data/creaturescripts/scripts/rewardchest_boss.lua:71: bad argument #1 to 'ceil' (number expected, got boolean)
[15:1:01.791] stack traceback:
[15:1:01.793]   [C]: in function 'ceil'
[15:1:01.794]   data/creaturescripts/scripts/rewardchest_boss.lua:71: in function <data/creaturescripts/scripts/rewardchest_boss.lua:57>

 

 

Não mexi nessa linha

Postado

refiz tudo do 0 e agora continua aparecendo a msg de que tenho mais de 1 char no sistema mas os 2 ainda recebem o loot

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 520.3k

Informação Importante

Confirmação de Termo