• 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!

onDeath ?

WiLDTuRTLE

Member
Joined
Feb 26, 2011
Messages
478
Reaction score
5
I want the monster to be only owned by the last hitter , if you dont understand let me know lol, im pretty much asking where i could find a script or where im supose to change things to make it work like that

-ced
 
Add in your creaturescripts.xml
XML:
<event type="death" name="LastKiller" script="LastKiller.lua"/>

Create a LastKiller.lua data in the scripts folder
LUA:
function onDeath(cid, corpse, lasthitkiller, mostdamagekiller, lasthitunjustified, mostdamageunjustified)
	if isPlayer(lasthitkiller) == TRUE then
		doCreatureSay(lasthitkiller, "You just killed something, with the last hit.", TALKTYPE_ORANGE_1)
	end
    return TRUE
end

Into your login.lua add
LUA:
registerCreatureEvent(cid, "LastKiller")
 
Okay testing it atm, but i just got an error, can u tell me whats wrong? it says something wrong around 'players' line 6 ,

LUA:
function onLogin(cid)
    local playerid = getPlayerGUID(cid)
    if isKnight(cid) then
        if getPlayerMagicLevel(cid) > 61 then
            doRemoveCreature(cid)
            db.executeQuery('UPDATE 'players' SET 'maglevel' = "61" WHERE 'id' = "' .. playerid .. '"')
        elseif getPlayerMagicLevel(cid) == 61 then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have the maximum magic level.")
            doPlayerSetMagicRate(cid, 0)
        end
    end
    return true
end


EDIT; Most damage still gets the loot, D:? maybe u didnt catch what i said xD, but like, anybody could come and steal the loot by lasthit

Maybe i did something wrong, no errors tho, it didnt say the creaturedosay msg when hydra died
 
Last edited by a moderator:
Back
Top