Créditos
Skyforever(eu) e Vodkart
Como funciona?
É um script que manda uma mensagem animada dependendo do hit do player
Script
Primeiramente vá em /data/creaturescripts/scripts login.lua adicione essa linha la
registerCreatureEvent(cid, "Hitmsg")
em creaturescripts.xml adicione essas 2 linhas:
<event type="statschange" name="HitMessage" event="script" value="hitmsg.lua"/> <event type="combat" name="Hitmsg" event="script" value="hitmsg.lua"/>
depois na mesma pasta crie um arquivo chamado hitmsg e adicione isso dentro:
function onStatsChange(cid, attacker, type, combat, value)local tabble = {
[1] = {max = 15,msg = "Lower"},
[16] = {max= 50,msg = "Good"},
[51] = {max= 100,msg = "Mega"},
[101] = {max= 250,msg = "Epic"},
[251] = {max= 300,msg = "Perfect"},
[301] = {max= 600,msg = "Supreme"},
[601] = {max= 2000,msg = "Divine"},
[2001] = {max= 100000,msg = "Hs"}
}
if type == STATSCHANGE_HEALTHLOSS and isPlayer(attacker) then
if value == 0 then
doSendAnimatedText(getCreaturePosition(attacker), "MISS", math.random(1,255))
else
for min, hit in pairs(tabble) do
if value >= min and value <= hit.max then
local color = math.random(1,255)
doSendAnimatedText(getCreaturePosition(attacker), hit.msg, color)
local pos2 = {x=getCreaturePosition(attacker).x+1,y=getCreaturePosition(attacker).y,z=getCreaturePosition(attacker).z}
doSendAnimatedText(pos2, "HIT", color)
end
end
end
elseif type == STATSCHANGE_HEALTHGAIN then
return false
end
return true
end
function onCombat(cid, target)
registerCreatureEvent(target, "HitMessage")
return true
end
Versão com chance:
function onStatsChange(cid, attacker, type, combat, value)local chance = 25 -- aqui e chance esta em 25% de funcionar
local tabble = {
[1] = {max = 15,msg = "Lower"},
[16] = {max= 50,msg = "Good"},
[51] = {max= 100,msg = "Mega"},
[101] = {max= 250,msg = "Epic"},
[251] = {max= 300,msg = "Perfect"},
[301] = {max= 600,msg = "Supreme"},
[601] = {max= 2000,msg = "Divine"},
[2001] = {max= 100000,msg = "Hs"}
}
if type == STATSCHANGE_HEALTHLOSS and isPlayer(attacker) then
if (chance > math.random(1, 100)) then
if value == 0 then
doSendAnimatedText(getCreaturePosition(attacker), "MISS", math.random(1,255))
else
for min, hit in pairs(tabble) do
if value >= min and value <= hit.max then
local color = math.random(1,255)
doSendAnimatedText(getCreaturePosition(attacker), hit.msg, color)
local pos2 = {x=getCreaturePosition(attacker).x+1,y=getCreaturePosition(attacker).y,z=getCreaturePosition(attacker).z}
doSendAnimatedText(pos2, "HIT", color)
end
end
end
end
elseif type == STATSCHANGE_HEALTHGAIN then
return false
end
return true
end
function onCombat(cid, target)
registerCreatureEvent(target, "HitMessage")
return true
end
Explicando
local tabble = {[1] = {max = 15,msg = "Lower"},
[16] = {max= 50,msg = "Good"},
[51] = {max= 100,msg = "Mega"},
[101] = {max= 250,msg = "Epic"},
[251] = {max= 300,msg = "Perfect"},
[301] = {max= 600,msg = "Supreme"},
[601] = {max= 2000,msg = "Divine"},
[2001] = {max= 100000,msg = "Hs"}
}
Em colchetes e o dano minimo em max o dano máximo em msg a mensagem que ira mandar coloque só a primeira mensagem exemplo se você quiser colocar "waka hit" coloque só waka o hit ira sozinho
Versão com recompensa
function onStatsChange(cid, attacker, type, combat, value)local chance = 25 -- aqui e chance esta em 25% de funcionar
local tabble = { --- min hit,maxhit,mensagem,recompensa,quantidade,storage nao mecha,quantos hits desses ele tera que acertar para ganhar o premio
[1] = {max = 15,msg = "Lower", itemid = 2159 , quantidade = 5, storage = 187260, storqua = 1000},
[16] = {max= 50,msg = "Good", itemid = 2159 , quantidade = 10, storage = 187262, storqua = 750},
[51] = {max= 100,msg = "Mega", itemid = 2159 , quantidade = 15, storage = 187263, storqua = 500},
[101] = {max= 250,msg = "Epic", itemid = 2159 , quantidade = 50, storage = 187264, storqua = 250},
[251] = {max= 300,msg = "Perfect", itemid = 2159 , quantidade = 75, storage = 187265, storqua = 150},
[301] = {max= 600,msg = "Supreme", itemid = 2160 , quantidade = 1, storage = 187266, storqua = 100},
[601] = {max= 2000,msg = "Divine", itemid = 2160 , quantidade = 5, storage = 187267, storqua = 50},
[2001] = {max= 100000,msg = "Hs", itemid = 2160 , quantidade = 100, storage = 187268, storqua = 5}
}
if type == STATSCHANGE_HEALTHLOSS and isPlayer(attacker) then
if (chance > math.random(1, 100)) then
if value == 0 then
doSendAnimatedText(getCreaturePosition(attacker), "MISS", math.random(1,255))
else
for min, hit in pairs(tabble) do
if value >= min and value <= hit.max then
local contagem = getPlayerStorageValue(attacker, hit.storage)
if contagem == -1 then setPlayerStorageValue(attacker, hit.storage, 0) end
local color = math.random(1,255)
doSendAnimatedText(getCreaturePosition(attacker), hit.msg, color)
local pos2 = {x=getCreaturePosition(attacker).x+1,y=getCreaturePosition(attacker).y,z=getCreaturePosition(attacker).z}
doSendAnimatedText(pos2, "HIT", color)
setPlayerStorageValue(attacker, hit.storage, contagem+1)
if contagem == hit.storqua then
doPlayerAddItem(attacker, hit.itemid, hit.quantidade)
setPlayerStorageValue(attacker, hit.storage, 0)
end
end
end
end
end
elseif type == STATSCHANGE_HEALTHGAIN then
return false
end
return true
end
function onCombat(cid, target)
registerCreatureEvent(target, "HitMessage")
return true
end
Explicando versão com recompensa
em item id e o id do item que ele vai receber ,em quantidade e a quantidade de item,em storage não mecha,em storqua e quantos hits ele precisara dar para ganhar a recompensa
Imagen: