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
info
Grupo: Visconde
Registrado: 23/02/08
Posts: 273
Reputação: +101
Char no Tibia: Foxx Rookslayer
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 endEditado Setembro 3 por Byerne