Hello! I got error in console when players are killed by monsters, but its work fine when they are killed by other players.
Code:
[08/05/2010 11:14:11] [Error - CreatureScript Interface]
[08/05/2010 11:14:11] data/creaturescripts/scripts/reward.lua:onDeath
[08/05/2010 11:14:11] Description:
[08/05/2010 11:14:11] (internalGetPlayerInfo) Player not found when requesting player info #3
Code:
function onDeath(cid, corpse, deathList)
local corpse_ids = {
[0] = 3065,
[1] = 3058
}
local v = { killer_name = getCreatureName(deathList[1]), killer_level = getPlayerLevel(deathList[1]), target_name = getCreatureName(cid), target_level = getPlayerLevel(cid) }
local reward = doAddContainerItem(corpse.uid, 5943, 1)
if isPlayer(cid) then
for i = 1, #deathList do
if(isPlayer(deathList[i])) then
doItemSetAttribute(reward, "description", "" .. (getPlayerSex(cid) == 0 and "She" or "He") .. " was killed at level " .. v.target_level .. " by " .. v.killer_name .. " who was level " .. v.killer_level .. " at the time. " .. (getCreatureSkullType(cid) <= SKULL_GREEN and "[Unjustified]" or "[Justified]"))
local corpse, killers = doCreateItem(corpse_ids[getPlayerSex(cid)], 1, getThingPos(cid)), ""
for i = 1, math.min(getConfigInfo('deathAssistCount') + 1, #deathList) do
killers = killers .. (i == 1 and "" or ", ") .. (isMonster(deathList[i]) and "a " or "") .. getCreatureName(deathList[i])
end
end
doItemSetAttribute(reward, "name", v.target_name .."'s Heart")
end
end
return true
end