Hello.. i'm back with other function.. simple but very useful...
Based in the talk-action command to see the deathlist of any player..
Here is :]
Well.. you can use it like this:
Based in the talk-action command to see the deathlist of any player..
Here is :]
Code:
function getPlayerDeathList(cid)
local player = db.getResult("SELECT `name`, `id` FROM `players` WHERE `name` = " .. db.escapeString(getCreatureName(cid)) .. ";")
if(player:getID() ~= -1) then
local playerName = player:getDataString("name")
local playerGUID = player:getDataInt("id")
player:free()
local str = ""
local deaths = db.getResult("SELECT `time`, `level`, `killed_by`, `altkilled_by` FROM `player_deaths` WHERE `player_id` = " .. playerGUID .. " ORDER BY `time` DESC;")
if(deaths:getID() ~= -1) then
local breakline = ""
while(true) do
if(str ~= "") then
breakline = "\n"
end
local time = os.date("%d %B %Y %X ", deaths:getDataInt("time"))
local level = deaths:getDataInt("level")
local killed = ""
local lastHitKiller = deaths:getDataString("killed_by")
local mostDamageKiller = deaths:getDataString("altkilled_by")
if(tonumber(lastHitKiller)) then
killed = getPlayerNameByGUID(tonumber(lastHitKiller))
else
killed = getArticle(lastHitKiller) .. " " .. string.lower(lastHitKiller)
end
if(mostDamageKiller ~= "") then
if(tonumber(mostDamageKiller)) then
killed = killed .. " and by " .. getPlayerNameByGUID(tonumber(mostDamageKiller))
else
killed = killed .. " and by " .. getArticle(mostDamageKiller) .. " " .. string.lower(mostDamageKiller)
end
end
str = str .. breakline .. " " .. time .. " Died at Level " .. level .. " by " .. killed .. "."
if not(deaths:next()) then
break
end
end
deaths:free()
else
str = "No deaths recorded."
end
return str
else
doPlayerSendCancel(cid, "A player with that name does not exist.")
end
return TRUE
end
Well.. you can use it like this:
Code:
local text = getPlayerDeathList(cid)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, text)