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

TFS 1.X+ get player kills in tibia 12+?

zerox4365x

New Member
Joined
Apr 6, 2015
Messages
13
Solutions
2
Reaction score
1
Location
Chile
Good morning, afternoon, evening, night, whenever you see this post haha.

Resources:

  • TFS Version: 1.x+
  • Server Type: Canary (Click Here!)
  • Client Version: 12.x+

The thing is the following,..
I don't know if someone has the idea of how to take the player_kills as a value, like the old !frags command that was used in the 8.6 servers to be able to see the frags.


(here is a screenshot from player_kills)
Screenshot_372.png
I tried to create a function, but I have no idea how querys work, then... Here is my humble atrocious creation o_O
function Player.getKillsPlayer(self)
local Info = db.storeQuery("SELECT * FROM player_kills WHERE player_id = " .. self:getGuid() .. " AND unavenged = 1")
local frags = result.getDataInt(Info, 'frags')
result.free(Info)
return frags
end

Can someone help me hhhhhh?
 
Solution
I have already solved it, at the moment of observing slaw comment in the thread "[SQL/Gesior/TFS 1.5] Display Players Frag Count", I created this function:
function Player.getPlayerKills(self)
local query = db.storeQuery("SELECT COUNT(pd.killed_by) AS count FROM player_deaths pd WHERE pd.killed_by = " .. db.escapeString(self:getName()) .. " AND is_player = 1 AND unjustified = 1")
if not query then
return false
end

local count = result.getDataInt(query, "count")
result.free(query)
return count
end

Transformation performed from this .php code:
$frags = $SQL->query("SELECT COUNT(pd.killed_by) AS count FROM player_deaths pd WHERE pd.killed_by = ".$SQL->quote($player->getName())." AND...
Well, I found this function, which makes place the players by list and show their frags according to "player_deaths", but still no idea how to transform it to check the "player_kills" and count all the frags that are "unavenged"... So this is not working for me.

function getTopFraggers(vocs)
local fraggers = {}
local resultId = db.storeQuery("SELECT player_id, killed_by FROM player_deaths WHERE is_player = 1")
if resultId then
repeat
table.insert(fraggers, result.getDataString(resultId, "killed_by"))
until not result.next(resultId)
result.free(resultId)
end

local fraggers_names = {}
for i = 1, #fraggers do
if not table.find(fraggers_names, fraggers) then
table.insert(fraggers_names, fraggers)
end
end

local fraggers_total = {}
for i = 1, #fraggers do
for j = 1, #fraggers_names do
if fraggers_names[j] == fraggers then
if not fraggers_total[fraggers_names[j]] then fraggers_total[fraggers_names[j]] = 0 end
fraggers_total[fraggers_names[j]] = fraggers_total[fraggers_names[j]] + 1
end
end
end

local place = 0
local fraggers_top = {}
repeat
local v = getHighest(fraggers_total, fraggers_names)
if not v[2] then
break
end

if vocs then
local resultId = db.storeQuery("SELECT vocation FROM players WHERE name = '" .. v[2] .. "' LIMIT 1")
if isInArray(vocs, result.getDataInt(resultId, "vocation")) then
place = place + 1
table.insert(fraggers_top, {v[1], v[2]})
end
else
place = place + 1
table.insert(fraggers_top, {v[1], v[2]})
end
table.remove(fraggers_names, v[3])
until (place == top) or (not v[3])

local msg = ""
for i = 1, #fraggers_top do
if fraggers_top[2] then
msg = msg .. "\n[" .. i .. "] [" .. fraggers_top[2] .. "] [" .. fraggers_top[1] .. "]"
else
break
end
end
return msg
end


Any help?:eek:
 
I have already solved it, at the moment of observing slaw comment in the thread "[SQL/Gesior/TFS 1.5] Display Players Frag Count", I created this function:
function Player.getPlayerKills(self)
local query = db.storeQuery("SELECT COUNT(pd.killed_by) AS count FROM player_deaths pd WHERE pd.killed_by = " .. db.escapeString(self:getName()) .. " AND is_player = 1 AND unjustified = 1")
if not query then
return false
end

local count = result.getDataInt(query, "count")
result.free(query)
return count
end

Transformation performed from this .php code:
$frags = $SQL->query("SELECT COUNT(pd.killed_by) AS count FROM player_deaths pd WHERE pd.killed_by = ".$SQL->quote($player->getName())." AND is_player = 1 AND unjustified = 1;")->fetch();

WARNING!!
Something you should know...

The skull system is being handled by player_kills and not by player_deaths, so player_deaths would simply be used as a counter, after that the kills for red and black are being stored in player_kills, and player_kills reloads kills or raises them only when the player disconnects.

That's it 😁
Thread SOLVED!
 
Solution
Back
Top