BE

[Function] Isbetween

Por bepokemon, 03 de set. de 2011 em Mods, funções e outros

script
1
812
bepokemonB
03 de setembro de 2011 às 17:59

function isBetween(n, num1, num2)
return n >= num1 and n <= num2
end

 

Exemplo de como usaria.

teste = {min = 1, max = 5}

if isBetween(3, teste.min, teste.max)

 

Isso vai verificar se 3 esta entre o minimo e o maximo.

 

Usado em um script:

function onUse(cid, item)
loteria = {chmin = getPlayerLevel(cid)*0.9, chmax = getPlayerLevel(cid)*1.1}

if isBetween(math.random(0,100), loteria.chmin, loteria.chmax) then
doPlayerSendCancel(cid, "Congratulations! You won the lottery!
else
doPlayerSendCancel(cid, "You lost!")
end
return TRUE
end

Editado Setembro 3 por Byerne