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

onPreparedeath(cid,deathList)

Doggynub

LUA / C++
Joined
Sep 28, 2008
Messages
2,541
Reaction score
186
I want to know when values is started to be inserted in the deathList param, and these values return what? last hitter or ?
 
sources, creatureevent.cpp, check:
Code:
            scriptstream << "local cid = " << env->addThing(creature) << std::endl;

            scriptstream << "local deathList = {}" << std::endl;
[COLOR=red]            for(DeathList::iterator it = deathList.begin(); it != deathList.end(); ++it)
            {
                scriptstream << "deathList:insert(";
                if(it->isCreatureKill())
                    scriptstream << env->addThing(it->getKillerCreature());
                else
                    scriptstream << it->getKillerName();

                scriptstream << ")" << std::endl;
            }
[/COLOR]
I think it depends of amount of killers, deathList[0] is lasthit(I think) or else it's deathList[1]
then deathList[2], deathList[3] etc would be the other killers(if there are)
 
I know i have searched in the the creature.cpp but i wanted to know i see functions creaturekill, getcreaturekiller , but isnt this supposed to be excuted be fore he die?so he isnt killed yet or what?
 
Why not? It should. Death entries are not created after creature dies, but they're always stored for every creature/player that attacked another creature/player. Calling this function only makes TFS push them from the map :p
 
cause i have been trying to use that no luck, is there somthng wrong.. ?
LUA:
function onPrepareDeath(cid, deathList)
	local attacker = deathList[1]
	if isInRange(getCreaturePosition(cid), arena.frompos, arena.topos) then
		doItemSetAttribute(doCreateItem(corpse_ids[getPlayerSex(cid)], 1, getThingPos(cid)), "description", "You recognize "..getCreatureName(cid)..". He was killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item")..".\n[War-Event kill]") 
		doTeleportThing(cid, out_place, FALSE)
		doSendMagicEffect(getCreaturePosition(cid), 10)
		doRemoveConditions(cid, FALSE)
		doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid))
		doCreatureAddMana(cid, getCreatureMaxMana(cid) - getCreatureMana(cid))
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You got killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item").." in the war event.")
			if isPlayer(attacker) then
				doPlayerSendTextMessage(attacker, MESSAGE_STATUS_CONSOLE_BLUE, "You killed "..getCreatureName(cid).." in the war event.")
			end
			if getPlayerStorageValue(cid,joined) == 1 then
				addRed()
				setPlayerStorageValue(cid,10000,-1)
			elseif getPlayerStorageValue(cid,joined) == 2 then
				addBlue()
				setPlayerStorageValue(cid,10000,-1)
			end
			return false
	end
	return true
end
 
In onPrepareDeath 'cid' is the killer, isn't it?
You should use onKill(cid, target, lastHit):
cid is lastHit killer and target the dead person..

or
onDeath(cid, corpse, deathList)
cid is dead person and deathList[1] is lasthitter

I never liked to use onPrepareDeath
 
Ahh^^
In older versions that worked well with onPrepareDeath but in newer ones it doesn't anymore.

If you want to prevent him from dying use:
LUA:
function onStatsChange(cid, attacker, type, combat, value)
if value >= getPlayerHealth(cid) then
    return false
end

return true
end
 
Ye i know i always use stats change but on that guy server returnning false in any of creaturescript function dont work ,wierd huh!!
 
Back
Top