MA
pedido

Knight ganhar item da arena

Por maikons, 20 de set. de 2013 em Scripts

resolvido
script
8
974
maikonsM
20 de setembro de 2013 às 23:15

Bom galera eu tenho um baiak, entao se eu coloca-se a arena em si ninguem iria saber, pq os caras q jogam baiak são mais noobs e tal, e queria um script q eu vi num baiak MUITO bacana! Qnd vc chega no lvl 60, dependendo da sua skill mais alta tipo, se sua skill mais alta é axe, vc ganha um heroic axe, se sua skill maior for sword vc ganha uma sword do lvl 60 e no lvl 80 a msm coisa só q com os itens mais fortes, alguem sabe fazer? Ia ajudar mt gente!

 

Pra facilitar eu vou colocar aqui no spoiler o nome das armas e os ids

 

 


Knight

Lvl 60
maior skill sword:

Mystic Blade (7384)

 

maior skill axe:

Heroic Axe (7389)

 

maior skill club:

Cranial Basher (7415)

 

Lvl 80

maior skill sword:

Justice Seeker (7390)

 

maior skill axe:

Royal Axe (7434)

 

maior skill club:

Blessed Sceptre (7429)

OmegaO
21 de setembro de 2013 às 03:04

Salve esse código (creaturescripts/scripts/arenaitems.lua)

	function getPlayerTopMeleeSkill(cid)
		local skill = 0
		local value = 10
		for i = 1, 4 do
			if getPlayerSkillLevel(cid, i) > value then
				value = getPlayerSkillLevel(cid, i)
				skill = i
			end
		end
		return {skill = skill, value = value}
	end

	function onAdvance(cid, skill, oldLevel, newLevel)
		local weap = {7415, 7390, 7434}
		if skill == 8 and newLevel >= 60 and getPlayerStorageValue(cid, 876125) == -1 then
			local topskill = getPlayerTopMeleeSkill(cid)
			if doPlayerAddItem(cid, weap[topskill.skill], 1, false) then
				doPlayerSendTextMessage(cid, 25, "Parabens, voce ganhou uma arma especial por passar do level 60!")
				setPlayerStorageValue(cid, 876125, 1)
			end
		end
		return true
	end

Adicione essa tag em creaturescripts.xml

<event type="advance" name="AdvanceItems" event="script" value="arenaitems.lua"/>

E isso em login.lua (embaixo dos outros registerCreatureEvent)

registerCreatureEvent(cid, "AdvanceItems")

E seja feliz =D

maikonsM
21 de setembro de 2013 às 19:05

Poxa cara nem pegou =\

Dos mage online e a distro já ta lotando de erro:

 

[Error - CreatureScript Interface]
data/creaturescripts/scripts/arenaitems.lua:onAdvance
Description
<luaDoPlayerAddItem> Item not found

OmegaO
22 de setembro de 2013 às 23:35


function getPlayerTopMeleeSkill(cid)

local skill = 0

local value = 10

for i = 1, 4 do

if getPlayerSkillLevel(cid, i) > value then

value = getPlayerSkillLevel(cid, i)

skill = i

end

end

return {skill = skill, value = value}

end

 

function onAdvance(cid, skill, oldLevel, newLevel)

if not isKnight(cid) then return true end

if getPlayerTopMeleeSkill(cid).skill > 3 then return true end

local weap = {7415, 7390, 7434}

if skill == 8 and newLevel >= 60 and getPlayerStorageValue(cid, 876125) == -1 then

local topskill = getPlayerTopMeleeSkill(cid)

if doPlayerAddItem(cid, weap[topskill.skill], 1, false) then

doPlayerSendTextMessage(cid, 25, "Parabens, voce ganhou uma arma especial por passar do level 60!")

setPlayerStorageValue(cid, 876125, 1)

end

end

return true

end

maikonsM
23 de setembro de 2013 às 02:37

Dei +rep por me ajudar de novo, mas n funcionou, continua com erro =(
Só q agora parece ser outro

 

[Error - CreatureScript Interface]
data/creaturescripts/scripts/arenaitems.lua:onAdvance
Description:
data/creaturescripts/scripts/arenaitems.lua:14: attempt to call gflobal 'isKnight' <a nil value>
stack traceback:
data/creaturescripts/scripts/arenaitems.lua:14: in function <data/creaturescripts/scripts/arenaitems.lua:13>


[C]: in function 'doPlayerAddExperience'
data/creatrescripts/sctrips....

OmegaO
23 de setembro de 2013 às 09:51
function getPlayerTopMeleeSkill(cid)
		local skill = 0
		local value = 10
		for i = 1, 4 do
			if getPlayerSkillLevel(cid, i) > value then
				value = getPlayerSkillLevel(cid, i)
				skill = i
			end
		end
		return {skill = skill, value = value}
	end
	
function isKnight(cid)
	local knight = {4, 8}
	if isPlayer(cid) then
		return isInArray(knight, getPlayerVocation(cid))
	end
	return false
end

function onAdvance(cid, skill, oldLevel, newLevel)
    if not isKnight(cid) then return true end
    if getPlayerTopMeleeSkill(cid).skill > 3 then return true end
	local weap = {7415, 7390, 7434}
	if skill == 8 and newLevel >= 60 and getPlayerStorageValue(cid, 876125) == -1 then
		local topskill = getPlayerTopMeleeSkill(cid)
		if doPlayerAddItem(cid, weap[topskill.skill], 1, false) then
			doPlayerSendTextMessage(cid, 25, "Parabens, voce ganhou uma arma especial por passar do level 60!")
			setPlayerStorageValue(cid, 876125, 1)
		end
	end
	return true
end

Tá funcionando agora?

Editado Setembro 24 por omega blueheaven

maikonsM
25 de setembro de 2013 às 12:15

Agora acho que tá, vlw sem erros obrigadao

RoksasR
25 de setembro de 2013 às 15:55

Tópico movido para a seção de dúvidas e pedidos resolvidos.