• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

how to check who has done a higher damage in a monster?

Joe Rod

Discord: joerod1
Joined
Mar 16, 2011
Messages
499
Solutions
2
Reaction score
172
GitHub
joerod1
Hi guys, i need know how to check what player has done a higher damage attacking a monster, the same of "You are not the owner" but checking an alive monster.
thanks in advance
Regards.
 
Example of usage onStatsChange:

LUA:
function onStatsChange(cid, attacker, type, combat, value)
	string = string.explode(toString(getGlobalStorageValue(cid)), ",")
	if(type == STATSCHANGE_HEALTHLOSS and isMonster(cid) and value > toNumber(string[2])) then
		setGlobalStorageValue(cid, attacker .. "," .. value)
		print("Combat Value: " .. string[2] .. " and Attacker: " .. getCreatureName(toNumber(string[1])) .. " have been stored in " .. cid .. " storage.")
	end
	return true
end

function onKill(cid, target)
	string = string.explode(toString(getGlobalStorageValue(target)), ",")
	if(cid == toNumber(string[1])) then
		doPlayerSendCancel(cid, "Congratulations, you've hit the monster with the biggest power.")
		doPlayerAddExp(cid, toNumber(string[2]))
	end
	return true
end
 
Code:
I corrected some errors, check the next page.

This will store the damage in the storage '1234', after u just need a PHP or talkaction to rank it.
If u do not know how to create, just take a look at reset system.
 
Last edited:
Code:
function onStatsChange(cid, attacker, type, combat, value)
local storage = 1234
local monsterName = "Demon"
	if(type == STATSCHANGE_HEALTHLOSS and isMonster(cid) getCreatureName(cid) == monsterName and isPlayer(attacker)) then
		doCreatureSetStorage(attacker, storage, getCreatureStorage(cid, attacker)+value)
	end
	return true
end

This will store the damage in the storage '1234', after u just need a PHP or talkaction to rank it.
If u do not know how to create, just take a look at reset system.

Your code will store the whole damage done on the creature with no owner of the damage.
 
Your code will store the whole damage done on the creature with no owner of the damage.

??

It will store in a PLAYER STORAGE. How not ?
doCreatureSetStorage(attacker, storage, getCreatureStorage(cid, attacker)+value)

Ex:
DMG given is 500
It will set 500 to the 'storage' of 'attacker'.
 
Two litte mistakes.
Code:
function onStatsChange(cid, attacker, type, combat, value)
local storage = 1234
local monsterName = "Demon"
	if type == STATSCHANGE_HEALTHLOSS and isMonster(cid) and getCreatureName(cid) == monsterName and isPlayer(attacker) then
		doCreatureSetStorage(attacker, storage, getCreatureStorage(cid, storage)+value)
	end
	return true
end
 
Back
Top