K/D with LUA ?


(ETdemin) #1

Hello

Please is there a way to get the K/D of a player with LUA ?
Have you an example of script ?

Thank you :slight_smile:


(jemstar) #2

Thanks Sol, the version 2 of your logger works great!!


(Kynval) #3

Hey guys… I add:

set lua_modules "dbstats.lua dbstat.lua

i changed dbinfo in all used lua

i put in console, and rcon… all the ways

!sqlcreate

and i see no info about creating db, and !cmds doesn’t work.
any ideas?
should i add some [command] ?


(ailmanki) #4

Afaik there is no such script. Maybe someone wrote one, but I don’t know.

Its not that simple in any case, you need to keep track of a player. And then just count his deaths and kills.
Kmod has those things, but I think it does not calculate k/d ratio.

You can check these 2 places for scripts and infos:
http://wolfwiki.anime.net/index.php/Category:ETPro:Mods


(dutchmeat) #5

It’s not that hard, basicly you keep a record of all players using a table of some sorts, with all their kills and deaths.
You can ‘record’ those records by hooking into the EV_OBITUARY event and get the killer and target Ids.
With those Ids you can update the playertable’s kills and deaths.

I don’t have a LUA example, but we did something similar with GMSM.


(phisherman) #6

This can be realized easily: Depending on what you want the script to do, you can either (as previously mentioned) use et_Obituary() to count the kills & deaths, or read the client entity fields sess.kills & sess.deaths.

If you need any help with your script, contact me.


(ETdemin) #7

cool Thank you for the answers

I have checked many LUA scripts, but I have not find for the moment
What is interesting me is to get the “permanent k/d” of the players

I just want to make something that be able to calculate and show the Total of Player’s K/D on a side.

examples :

Axis side
player 0 : k/d 1000
player 1 : k/d 1152

Total of all K/D AXIS players = 2152

Allies side
player 2 : k/d 2235
player 3 : k/d 1238
Total of all K/D ALLIES players = 3473

More the script is simple, less it eat some resources…
I do not want to track too much players because on some low powered servers it make server bad frags
Prefer something that can be punctually called by a command

The difficulty come from the fact I need to understand how to get the K/D values
I will try to work on what you said…
But there is perhaps already a simple way to find that total somewhere ?
Or have you a script that can provide the player’s K/D ?

thanks :slight_smile:


(Patriotqube) #8

if you want to show it on a site, why not use vsp stats then?

like this http://et.qubenet.net/stats-et07.php


(ETdemin) #9

thank but I do not search an offline solution

I search to display a pure K/D online (during the gaming) [not offline] :slight_smile:
Something clean “not polluted” like was the !howfair
and too because some features seems broken on some versions of ETPub servers


(solchanel) #10

There is simply K/D LUA Script coded by myself, I use it just for own server. http://polish-frags.pl/staty.php
You can test in on our server, just enter on your console !ratio ( your ratio (kills/deaths) + rank on server )
The script works with MySQL.


(ETdemin) #11

Thank :slight_smile: But is there no solution that could work without the necessity of using PHP ???

Because I do not want to manage PHP.
Something that work with the Native LUA ??


(solchanel) #12

Like I said, You can simply enter !ratio on the server, player stats are saved into database, PHP displays it only.

Its a LuaSQL

[QUOTE=ETdemin;394551]
More the script is simple, less it eat some resources…
I do not want to track too much players because on some low powered servers it make server bad frags
Prefer something that can be punctually called by a command
The difficulty come from the fact I need to understand how to get the K/D values[/QUOTE]
Like Phishermans said, it’s really easy to values from sess.kills & sess.deaths.


(ETdemin) #13

Thanks but if I am not wrong sess.kills & sess.deaths is only for the Match : it do not give the persistant K/D values. What I search is to get the persistant K/D :slight_smile:


(phisherman) #14

[QUOTE=ETdemin;394582]What I search is to get the persistant K/D[/QUOTE]What is a “persistent K/D”? Like from the second the server went online until now? What would that be for?
Anyway, there’s no way to access this directly, if you wanted that you would need to save the K/D somewhere at the end of a round and read it at the beginning of the next.


(Indloon) #15

You have understood the K/D total wrongly. :slight_smile:

It should look like this:

  1. [li]Axis team Player 1 has[/li][ul]
    [li]Kills: 45[/li][li]Deaths: 20[/li][li] K/D = (45/20) = 2.25[/li][/ul]

    [li]Axis team Player 2 has[/li][ul]
    [li]Kills: 20[/li][li]Deaths: 25[/li][li] K/D = (20/25) = 0.8[/li][/ul]

Total Axis team K/D is 1.444…
Here is the math:
(P1K + P2K) / (P1K + P2K) = Global K/D

P1 marks Player 1
P2 marks Player 2
K and D are Kills and Deaths.


(ETdemin) #16

thank you for your answer I know for the divide but possible only if get stored value
persistant = stored like XP this term is used in many part of the LUA docuementation
Persistant is the stored permanent (in the files) in formation stored like for example it is the case for XP
(By the same way it is impossible to get it by LUA too same problem !)

I search a way to get those informations without managing any PHP and without managing any the necessity to go to look in the file system of xpsave.cfg

Thank you but when you just connect you get with ETPUB 0.9.1 mods :

sess.kills & sess.deaths = 0

Please what kind of division by zero should I do ? :slight_smile:
Please check by yourself that what I said is true :slight_smile:

I am not interested to get the value for the last X minutes but for the whole shown K/D
Including if I need to divide it by myself :slight_smile:

Values of the last X minutes have not interest… the permanent value shown when you press the TAB key is useful… and sure if I can get Killed & Death datas I can divide to find the good value…
But I cannot get the values stored in TAB :slight_smile: I get only in return 0… mean no persitant
(If I am not wrong I need a way to get the values from Userinfo )

In that case is there a way to get those informations without the necessity to access the xpsave files or without using php & co ? :

thank you for your support :slight_smile:


(stealth6) #17

The best advice so far was to take a look at Kmod and this http://wolfwiki.anime.net/index.php/Lua_Mod_API
Use this as a start:


function et_Obituary( victim, killer, meansOfDeath )
end

With that function you can track kills. (it’s called every time a player is killed)
With that knowledge I could come up with this:


teams = {}
teams[1] = {}
teams[2] = {}

function et_Obituary( victim, killer, meansOfDeath )
	local victimteam = tonumber(et.gentity_get(victim, "sess.sessionTeam")) 
    local killerteam = tonumber(et.gentity_get(killer, "sess.sessionTeam"))
	if victimteam ~= killerteam and killer ~= 1022 and killer ~= victim then
		teams[killerteam][1]++
		teams[victimteam][2]++
	end
end

function getKd()
	local kd1 = teams[1][1] / teams[1][2]
	local kd2 = teams[2][1] / teams[2][2]
end

Which won’t do anything in the game, but it’s a start. By doing some googling I discovered there are 2 teams so I thought a matrix would be an easy solution to store the kills[1] and deaths[2].
The if statement is checking for teamkills, deaths by “The world” and suicides in that order. I deducted this from kmod.lua

Good luck!

EDIT: It is possible that my lua script has some syntax mistakes since I don’t know any LUA :smiley:


(solchanel) #18

This is my solution, I published it http://mygamingtalk.com/forums/files/file/18-sql-stats-logger/
Anyway its 1.0 version, but I already built better 3.0 version. I will publish it soon.


(ETdemin) #19

Thank you for you help :slight_smile:
It seems the only way… while Modders will not add the persistant “XP and K/D” support…


(Indloon) #20

[QUOTE=ETdemin;394824]
It seems the only way… while Modders will not add the persistant “XP and K/D” support…[/QUOTE]

You sure that they will not? :slight_smile: