How do i make this?
I know i need to be in cg_scoreboard.c
WM_TeamScoreboard
But i have no idea how to make. Could someone help me with this?
Thanks
Average xp & ping
What exactly would you mean by average XP? Ping, that’s quite understandable, I’ll try to explain that later. But Av. XP, would you mean Average XP gained per round? That would require your server to keep a database of ALL players EVER, detect them when they come back, and keep their XP for every match they finish. I’d think that’d be a waste of your effort, because it won’t really make the game more fun if you’d ask me.
Average Ping would be quite more easy to register, and you could just throw it away when the player disconnects, and reg the ping of the player every # heartbeats. You could just throw it away because it only takes a few minutes to build up a good average, whereas XP per match would require the player to play at least one whole map (you should, of course, if you’d decide to do it anyway ;), integrate a bit preventing the server from saving the player’s XP from 5 minutes as the XP of a whole match, otherwise this sort of thing would drop the player’s AvXP to the ground). Back to AvPing: I have never looked at the source of ET, so don’t assume my words are the absolute thruth (assuming what I say makes sense is always a bad thing :D).
First a bit of background. When you hit TAB while playing, you see everybody’s Ping among some other stats. You are NOT able to measure their pings yourself, since you don’t have a direct connection to any of the other players. The Server is also unable to get the player’s pings without sending extra data to players, which I’m sure it doesn’t. The conclusion that follows from these facts is that, probably, the players send not only their location, aim etc. but also their Ping as the players themselves measure it (if you don’t get why the server can’t measure the ping of players itself, ask me ;)). So there’s a string every player sends to the server every time they “ping”, so that would be a little bit slower than 1/(0.001*ping) times a second. What you need to do at the server is intercept this string either from where it comes into the socket listener, you probably don’t want to do that because it will decrease server performance a little bit, or the other option is intercept it at the point this ping data is sent to other players so they can see it in their [TAB] UI screen.
This piece of code will, indeed, probably be in cg_scoreboard.c, but about TeamScoreboard I would be less sure. I’d figure the name means it only handles the scores (XP, accuracy, class stats etc), and no pings. Can’t help you much further, as said before I haven’t ever actually looked at the code ;). Try to follow the following steps to find out more:
- Thoroughly examine the UI script from pak0.pk3 that draws the [TAB] menu, this should tell you whether the player sends a command to the server so the server will start sending it the req’d data, or the player always received this stuff. In case the server wants a command before it starts sending players the stats, look for the handler of that command within the source code for the server. If the server always sends it, you have to find the function that gets excutes when the server does this. In both cases, you want to intercept the data t’s about to send to the user, and throw it into an array for later processing.
That’s my theory, but as always it will prove to be wrong for at least 50%
I want to show it in scoreboard during the match,
So you got it like this:
AXIS [TOTAL XP] x PLAYERS
Avg. ping: x
Avg. xp: x
AXIS [TOTAL XP] x PLAYERS
Avg. ping: x
Avg. xp: x
From that, it seems to me that all you would need to do to get the avg XP would be to take the total xp and divide it by the number of players on the team (assuming you’ve already found the total xp)