Antes de ler, verifique se está no XTibia!
Introdução:
Esse script, (não é bem um script, porém ajuda!) ensina como fazer a vida que a potion healou!
Como fazer:
☻Vá em seu script da potion;
☻Você encontrará algo assim:
function onUse(cid, item, frompos, item2, topos)
playerpos = {x=topos.x, y=topos.y, z=topos.z, stackpos=253}
player = getThingfromPos(playerpos)
ml = getPlayerMagLevel(cid)
lvl = getPlayerLevel(cid)
voc = getPlayerVocation(cid)
ex = getPlayerStorageValue(cid,4862)
r1 = math.random(500,900)
params = { [1]=cid, [2]=lvl, [3]=voc, [4]=ml }
if item2.itemid == 1 then
if item.itemid == 7635 then
doPlayerSendCancel(cid,"It is empty.")
else
if item2.uid == cid then
if lvl >= 80 then
if voc == 4 or voc == 8 then
if ex == -1 then
doPlayerAddHealth(cid,r1)
doSendMagicEffect(playerpos,12)
addEvent(ums,1000,params)
setPlayerStorageValue(cid,4862, 1)
doTransformItem(item.uid,7635)
doSendAnimatedText(getPlayerPosition(cid), "Aaaah...", TEXTCOLOR_ORANGE)
else
doPlayerSendCancel(cid,'You are exhausted.')
doSendMagicEffect(playerpos,2)
end
else
doPlayerSendCancel(cid, 'Somente Knights de level 80 ou superior podem consumir essa potion.')
end
else
doPlayerSendCancel(cid,'Somente Knights de level 80 ou superior podem consumir essa potion.')
end
else
splash = doCreateItem(2025,10,topos)
doTransformItem(item.uid,7635)
doDecayItem(splash)
end
end
else
if item.itemid == 7635 then
doPlayerSendCancel(cid,"It is empty.")
else
splash = doCreateItem(2025,10,topos)
doTransformItem(item.uid,7635)
doDecayItem(splash)
end
end
return 1
end
function ums(params)
cid = params[1]
setPlayerStorageValue(cid,4862, -1)
end
[b](Esse é o exemplo da Great Health Potion)[/b]
☻Agora, procure pela linha:
[u]r1 = math.random(500,900)[/u]
Está vendo? Vou explicar:
r1 = É o termo usado, significa que r1 será algum número entre 500 e 900
math.random = É a função que usamos para escolher randomicamente entre 500 e 900
OBS¹ = Esse math.random, está definindo quanto de vida a potion irá curar. (Entre 500 e 900)
☻Agora, procure essa seguinte linha:
[u]doSendAnimatedText(getPlayerPosition(cid), "Aaaah...", TEXTCOLOR_ORANGE)[/u]
está vendo ? Vou explicar:
doSendAnimatedText = Enviar texto animado
getPlayerPosition(cid) = Posição do Player que usou o item, no caso: ([color=#FF0000]cid[/color])
"Aaaah..." = Texto que foi enviado
TEXTCOLOR_ORANGE = Cor do texto..
☻ Agora, pegue a linha:
[u]doSendAnimatedText(getPlayerPosition(cid), "Aaaah...", TEXTCOLOR_ORANGE)[/u]
e substitua por
[u]doSendAnimatedText(getPlayerPosition(cid), ""..r1.."", TEXTCOLOR_ORANGE)[/u]
☻Pronto!
[b]REEXPLICANDO![/b]
Primeiro, ache a função que define quanto de vida a potion vai healar (no meu caso [u]r1[/u])
Depois, Substitua o "Aaah..." por ""..r1..""