MI
dúvida

Maximo de Sumon

Por milbradt, 29 de jan. de 2013 em Scripts

11
1.4k
milbradtM
29 de janeiro de 2013 às 20:57

Olá, eu fui infeliz em tentar add uma condição na spell.

Gostaria que a mesma verifica-se se o player ja tem mais de 2 summon, caso tiver, não fazer mais.

 

local spells = {
[1] = {used = 0, text = '<attack name="melee" interval="2000" chance="100" range="5" radius="1" target="0"><attribute key="areaEffect" value="fire"/></attack>'},
[2] = {used = 0, text = '<attack name="melee" interval="1200" chance="100" range="5" radius="1" target="0"><attribute key="areaEffect" value="energyarea"/></attack>'},
[3] = {used = 0, text = '<attack name="melee" interval="700" chance="100" range="5" radius="1" target="0"><attribute key="areaEffect" value="mortarea"/></attack>'}
}
local spellsNumber = 2
function randomNum(range)
local rand = 0
good = false
math.randomseed( os.time() )
math.random()
math.random()
math.random()
while (not good) do
    rand = math.random(range)

    if (spells[rand].used == 0) then
		    spells[rand].used = 1
		    good = true
    else
		    good = false
    end

end
return rand
end

function onSay(cid, words)
    local attacks = "<a>"
    local num

    for i=1,spellsNumber,1 do
		    num = randomNum(table.getn(spells))
		    attacks = attacks .. spells[num].text
    end

    attacks = attacks .. "</a>"
    doCreateCustomMonster(getCreatureName(cid), getCreaturePosition(cid), getCreatureOutfit(cid), getCreatureMaxHealth(cid), attacks, 6324, 1, 100)

    for i=1,table.getn(spells),1 do
		    spells[i].used = 0
    end

    attacks = ""

    return true
end

 

Eu tentei add

local summons = getCreatureSummons(cid)
if(table.maxn(summons) < MaximoSummon) then

Mas não obtive sucesso... Help-me Plz =)

LuckOakeL
29 de janeiro de 2013 às 20:59

Nossa, que preguiça de ler o script, muito bagunçado.

 

Mas ai, só fazer assim:

 

if #getCreatureSummons(cid) < MaximoSummon then
doPlayerSendCancel(cid, "Você só pode ter no máximo 2 summons.") return true
end

milbradtM
29 de janeiro de 2013 às 21:10

Pois então, não funfo tambem ;/

Não da erro algum, simplesmente da para fazer + summons ;x

LuckOakeL
29 de janeiro de 2013 às 22:25

Você deve ter colocado no lugar errado. Tó:

 

 

local spells = {
[1] = {used = 0, text = '<attack name="melee" interval="2000" chance="100" range="5" radius="1" target="0"><attribute key="areaEffect" value="fire"/></attack>'},
[2] = {used = 0, text = '<attack name="melee" interval="1200" chance="100" range="5" radius="1" target="0"><attribute key="areaEffect" value="energyarea"/></attack>'},
[3] = {used = 0, text = '<attack name="melee" interval="700" chance="100" range="5" radius="1" target="0"><attribute key="areaEffect" value="mortarea"/></attack>'},
}

local spellsNumber = 2
function randomNum(range)
local rand = 0
good = false
math.randomseed( os.time() )
math.random()
math.random()
math.random()
while (not good) do
rand = math.random(range)

if (spells[rand].used == 0) then
	spells[rand].used = 1
	good = true
else
	good = false
end

end
return rand
end

local MaximoSummon = 2

function onSay(cid, words)
if #getCreatureSummons(cid) < MaximoSummon then
	doPlayerSendCancel(cid, "Você só pode ter no máximo 2 summons.") return true
end
local attacks = "<a>"
local num

for i=1,spellsNumber,1 do
	num = randomNum(table.getn(spells))
	attacks = attacks .. spells[num].text
end

attacks = attacks .. "</a>"
doCreateCustomMonster(getCreatureName(cid), getCreaturePosition(cid), getCreatureOutfit(cid), getCreatureMaxHealth(cid), attacks, 6324, 1, 100)

for i=1,table.getn(spells),1 do
	spells[i].used = 0
end

attacks = ""

return true
end

 

Editado Janeiro 29 por LuckOake

LTKReturnsL
30 de janeiro de 2013 às 00:35

Mais Fácil Ir Em Config.lua e procurar essa parte maxPlayerSummons = 2 E Colocar Quantos Monstros Se Quer Que O Player Summone No Maximo No Caso Ali Ta 2

milbradtM
30 de janeiro de 2013 às 03:36

Mais Fácil Ir Em Config.lua e procurar essa parte maxPlayerSummons = 2 E Colocar Quantos Monstros Se Quer Que O Player Summone No Maximo No Caso Ali Ta 2

 

Isso não funfa, isso seria para o utevo res.

 

Eu até agora não entendi o por que não funcionou oq vc disse LuckOake, eu fis igual vc postou tbm, msm assim não deu certo, e para tirar todas minhas duvidas, colei o script inteiro que vc postou agora.. mesmo assim posso continuar fazendo mais do que 2 summons.

E não da erro algum...

 

Mesmo assim, vlw pela ajuda camarada, tem que refazer esse script do zero mesmo ;x

Editado Janeiro 30 por milbradt

LuckOakeL
30 de janeiro de 2013 às 12:01

Putz cara, agora que vi a besteira que eu fiz. Coloquei a verificação errada. Tá ai o script corrigido:

 

 

local spells = {
       [1] = {used = 0, text = '<attack name="melee" interval="2000" chance="100" range="5" radius="1" target="0"><attribute key="areaEffect" value="fire"/></attack>'},
       [2] = {used = 0, text = '<attack name="melee" interval="1200" chance="100" range="5" radius="1" target="0"><attribute key="areaEffect" value="energyarea"/></attack>'},
       [3] = {used = 0, text = '<attack name="melee" interval="700" chance="100" range="5" radius="1" target="0"><attribute key="areaEffect" value="mortarea"/></attack>'},
}

local spellsNumber = 2
function randomNum(range)
local rand = 0
good = false
math.randomseed( os.time() )
math.random()
math.random()
math.random()
while (not good) do
       rand = math.random(range)

       if (spells[rand].used == 0) then
               spells[rand].used = 1
               good = true
       else
               good = false
       end

end
return rand
end

local MaximoSummon = 2

function onSay(cid, words)
       if #getCreatureSummons(cid) >= MaximoSummon then
               doPlayerSendCancel(cid, "Você só pode ter no máximo 2 summons.") return true
       end
       local attacks = "<a>"
       local num

       for i=1,spellsNumber,1 do
               num = randomNum(table.getn(spells))
               attacks = attacks .. spells[num].text
       end

       attacks = attacks .. "</a>"
       doCreateCustomMonster(getCreatureName(cid), getCreaturePosition(cid), getCreatureOutfit(cid), getCreatureMaxHealth(cid), attacks, 6324, 1, 100)

       for i=1,table.getn(spells),1 do
               spells[i].used = 0
       end

       attacks = ""

return true
end

 

milbradtM
01 de fevereiro de 2013 às 01:26

Poisé, eu ja tinha reparado nisso, mas não era esse o problema, na verdade eu tinha um outro script que estava em talkactions e estava dando conflito.. USHIAUSHAUI

Foda que esse script da dando crash no server... ;x

 

Vlw ae LuckOake

LuckOakeL
01 de fevereiro de 2013 às 10:52

Beleza, posso mover o tópico ou tem alguma outra dúvida?

milbradtM
01 de fevereiro de 2013 às 15:57

Opa, desculpe, pode mover sim, dúvida e pedido sanado.

SlicerS
01 de fevereiro de 2013 às 16:01

movido