<event type="statschange" name="BestHit" event="script" value="bestHit.lua"/>
local bestMelee = 4500 -- free storage
local bestSpell = 4501 -- free storage
function onStatsChange(cid, attacker, type, combat, value)
if isPlayer(attacker) then
if combat == COMBAT_PHYSICALDAMAGE then
if getCreatureStorage(attacker, bestMelee) < value then
doCreatureSetStorage(attacker, bestMelee, value)
end
else
if combat ~= COMBAT_NONE and combat ~= COMBAT_UNDEFINEDDAMAGE then
if getCreatureStorage(attacker, bestSpell) < value then
doCreatureSetStorage(attacker, bestSpell, value)
end
end
end
end
return true
end
function onLogin(cid)
registerCreatureEvent(cid, "BestHit") -- add this line to login.lua
return true
end
.
<script>
<event name="BestHit"/>
</script>
<talkaction words="!bestbloodhit" event="script" value="bestMelee.lua"/>
local bestMelee = 4500 -- [same in onStatsChange script]
function onSay(cid, words, param, channel)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Your best damage dealt as melee attack: '..math.max(0, getCreatureStorage(cid, bestMelee))..'.')
return true
end
<talkaction words="!bestspellhit" event="script" value="bestSpell.lua"/>
local bestSpell = 4501 -- [same in onStatsChange script]
function onSay(cid, words, param, channel)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Your best damage dealt as spell attack: '..math.max(0, getCreatureStorage(cid, bestSpell))..'.')
return true
end
This is fail
yes this is why its fail :
1- states change occur when players stats is changed (he is hit, healed, etc..)
2- this script gives the most damage that was dealt to the player not by the player
3- if you tried to check if the attacker is player and increase the attacker max hit value then this will lack the attack values of players on monsters.
1- so why I checking combat (or you can heal yourself as physical damage, so here it won't work)
2- i don't get you. to the player/monster damage = the attacker dealt damage <- and it is checking
3- so why you need to add line to every monster which I posted above