Ir para conteúdo
Banner com Efeitos

Featured Replies

Postado

Boa tarde,

 

Estou tentando implementar um sistema novo no meu servidor com base no script anexado. Estou tendo problema, porém não sei o porquê.

Alguem poderia verificar e me dar uma ajuda, por favor?

 

Estou usando o OTX3. Os scripts .lua funcionam igual aos do TFS? Me refiro as funções, elas são iguais, certo?

 

Script abaixo:

local storage_skill_level = 10002
local storage_skill_try = 10003

local config = {
	
	level = {
		level = {0,9}, quant = {1,2}, percent = 5},
		level = {10,19}, quant = {2,4}, percent = 10},
		level = {20,29}, quant = {3,6}, percent = 15},
		level = {30,39}, quant = {4,8}, percent = 20},
		level = {40,49}, quant = {5,10}, percent = 25},
		level = {50,59}, quant = {6,12}, percent = 30},
		level = {60,69}, quant = {7,14}, percent = 35},
		level = {70,79}, quant = {8,16}, percent = 40},
		level = {80,89}, quant = {9,18}, percent = 45},
		level = {90,99}, quant = {10,20}, percent = 50},
		level = {100}, quant = {11,22}, percent = 55}
	},

	rocks = {1356, 1285, 3607, 3616}, --rochas
	stone = {},
	default_stone = 2157,
	rock_delay = 480,
	bonus_chance = 3,
	bonus_exp = 1
}

function getmininglevel(cid)
	return getplayerstoragevalue(cid, storage_skill_level)
end

function setplayermininglevel(cid, n)
	setplayerstoragevalue(cid, storage_skill_level, n)
end

function addmininglevel(cid, n)
	setplayermininglevel(cid, getmininglevel(cid) + (isnumber(n) and n or 1))
	setminingtry(cid, 0)
end

function getmininginfo(cid)
	for i = 1
		min = config.levels[i].level[1]; max = config.levels[i].level[2]
		if(getmininglevel(cid) >= min and getmininglevel(cid) <= max) then 
			return {quantity = {min = config.levels[i].quant[1], max = config.levels[i].quant}[2], chance = config.levels[i].percent}
		end
	end
end

function getstonebyrock(rockid)
	for i = 1, #condig.stones do
		if (config.stones[2] == rockid)
			then return config.stones[1]
		end
	end
	return config.default_stone
end

function setminingtry(cid, n)
	setplayerstoragevalue(cid, storage_skill_try, n)
end

function addminingtry (cid, bonus)
	setminingtry(cid, getminingtries(cid) + 1 + (bonus and config.bonus_exp or 0))
	if(getminingtries(cid) >= getminingexpto(getmininglevel(cid))) then
		doplayersendtextmessage(cid, 22, "You advanced from level " .. getmininglevel(cid) .. " to level " .. (getmininglevel(cid) + 1) .. " in mining.")
		if((getmininglevel(cid) + 1) == getminingmaxlevel()) then
			doplayersendtextmessage(cid, 22, "Max level reached in mining.")
		end
		addmininglevel(cid)
		dosendmagiceffect(getcreatureposition(cid), math.random(28,30))
		setminingtry(cid, 0)
	end
end

function getminingexpto(level)
	return((level * 1.5) + ((level + 1) * 7))
end

function getminingmaxlevel()
	return config levels[#config.levels].level[#config.levels[#config.levels].level]
end

function onuse(cid, item, fromposition, itemex, toposition)
	rock = {id = itemx.itemid, uid = itemex.uid, position = toposition}
	player = {position = getcreatureposition(cid)}
	if(getmininglevel(cid) < 0) then
		setplayermininglevel(cid, 0)
	end 
	if (isinarray(config.rocks, rock.id)) then
		addminingtry(cid)
		if (math.random(1, 100) <= getmininginfo(cid).chance) then
			local collected = math.random(getmininginfo(cid).quantity.min,
			getmininginfo(cid).quantity.max)
			doplayeradditem(cid, getstonebyrock(rock.id), collected)
			doplayersendtextmessage(cid, 22, "You got " .. collected .. " gold" .. (collected > 1 and "s" or "") .. " nuggets.")
			if(math.random(1,100) <= config.bonus_chance) then
				addminingtry(cid, true)
				dosendanimatedtext(player.position, "BONUS!", color_orange)
			end
		event_rockcut(rock)
		elseif (math.random(1,100) <= (10 - getmininginfo(cid).chance / 10)) then
			doplayersendtextmessage(cid, 22, "You got nothing.")
			event_rockcut(rock)
		else
			dosendmagiceffect(rock.position, 3)
			dosendanimatedtext(rock.position, "PIM!", color_orange)
		end
	end

function event_rockcut(rock)
	addevent(event_rockgrow, config.rock_delay * 1000, rock.position, rock.id)
	dosendmagiceffect(rock.position, 3)
	dosendanimatedtext(rock.position, "Tack!", color_orange)
	doitemsetattribute(rock.uid, "name", "a trunk of " .. getitemnamebyid(rock.id))
end

function event_rockgrow(rockpos, old_id)
	local rock = getthingfrompos(rockpos).uid
	dotransformitem(rock, old_id)
	doitemsetattribute(rock, "Name", getitemnamebyid(old_id))
	dosendmagiceffect(rockpos, 3)
end
	 

 

Você tem alguma imagem que possa auxiliar no problema? Se sim, coloque-a aqui.

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

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.

Conteúdo Similar

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo