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

Lua //onDeath(cid, corpse, deathList)

QuaS

Cykotitan Pwned =/
Joined
Sep 11, 2008
Messages
838
Reaction score
28
Location
Poland/ Wroclaw
Hello! How to use deathList from //onDeath(cid, corpse, deathList)? This is a table of killers, how can i get the first one?(the most demage)?

deathList[1] ?
 
i tried it before, but i always get it:

s6qc5v.jpg
 
well, now we know that deathList returns table xD 05BA~ part, it's first object in table(you probably killed someone with 1 char), so
LUA:
if isPlayer(deathList[1].uid) == true then
setPlayerStorageValue(deathList[1].uid, value, 1)
end
should work :<
post full script, so i will see whats error about
 
ireied do it before and it didn't work... i just want to know wtf is with this xD

okay get it:!

LUA:
local config = {
	message = "You now have 30 seconds to exit this room.",
	message1 = "You have killed one of two brothers. Kill the second and enter to the teleport.",
	posit1 = { x = 2652, y = 1369, z = 5, stackpos = 1 }, 
	acti1 = 48563,
	timeToRemove = 30, -- seconds
	teleportId = 3688,
	bosses = { -- Monster Name, Tp To Pos, Teleport Position, Action Id
		["Ungreez"] = { { x = 1411, y = 1580, z = 12, stackpos = 1 }, 0},




			}
}

local function removal(position)
	if getThingfromPos(position).itemid == config.teleportId then
		doRemoveItem(getThingfromPos(position).uid)
	end
	return TRUE
end

function onDeath(cid, corpse, deathList)
	local position = getCreaturePosition(cid)
	for name, pos in pairs(config.bosses) do
		if name == getCreatureName(cid) then
			teleport = doCreateItem(config.teleportId,1,pos[1])
			doBroadcastMessage(tostring(deathList), 21)
			if isPlayer(deathList[1].uid) then
			setPlayerStorageValue(deathList[1].uid, 46680, 2)
			end 
			doCreatureSay(cid, config.message, TALKTYPE_ORANGE_1)
			addEvent(removal, config.timeToRemove * 1000, pos[1])
		end
	end
	return TRUE
end
 
i don't think that changing value of storagevalue help me to get player from table... humm...

First time in my lua scripting history i am really empty xD
 
This may help:
Code:
function onPrepareDeath(cid, deathList)
	lastHitKiller = deathList[1]
	mostDamageKiller = deathList[2]
deathList returns an array, that contains creatures that killed creature with id of cid. First place in this array is lastHitKiller, second is mostDamageKiller
Also, you should notice that deathList contains ID of character, like cid).
If you want to check name of player with certain id, that can be done in this way:
Code:
lastHitKillerName = getCreatureName(deathList[1])
mostDamageKillerName = getCreatureName(deathList[2])
Moreover, you should check isPlayer(deathList[1]) == true or isPlayer(deathList[2]) == true if you want to make sure that player killed creature.

So, sample usage of setting storage value of mostDamageKiller.
Code:
function onPrepareDeath(cid, deathList)
	-- I need to make sure I am setting storage value to player, not monster,
	-- and to make sure that player wasn't most damage killer (for example,
	-- with own field you deal damage to yourself.
	if(isPlayer(deathList[2]) and deathList[2] ~= cid) then
		-- deathList contains IDs, so I have to use this instead of cid
		setPlayerStorageValue(deathList[2], 12345, 10)
	end
	-- I don't want to disable entire death script (if player's health gone
	-- to 0, player dies, window appears, corpse with description, blood etc.
	-- so it won't interrupt if I will return TRUE
	return TRUE
end
Regards,
Hermes
 
Last edited:
Nice hermes , my script works perfect now.
Late i had it with onKill function but i had a problem with that function beacuse if guy with townid more then +2 kills other guys it didnt work.

rep+ !
 
Back
Top