[Half-Life AMXX] / stats_logging.sma Repository:
ViewVC logotype

Annotation of /stats_logging.sma

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (view) (download)

1 : ian 1 /* AMX Mod X
2 :     * Stats Logging Plugin
3 :     *
4 :     * by the AMX Mod X Development Team
5 :     * originally developed by JustinHoMi
6 :     *
7 :     * This file is part of AMX Mod X.
8 :     *
9 :     *
10 :     * This program is free software; you can redistribute it and/or modify it
11 :     * under the terms of the GNU General Public License as published by the
12 :     * Free Software Foundation; either version 2 of the License, or (at
13 :     * your option) any later version.
14 :     *
15 :     * This program is distributed in the hope that it will be useful, but
16 :     * WITHOUT ANY WARRANTY; without even the implied warranty of
17 :     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 :     * General Public License for more details.
19 :     *
20 :     * You should have received a copy of the GNU General Public License
21 :     * along with this program; if not, write to the Free Software Foundation,
22 :     * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 :     *
24 :     * In addition, as a special exception, the author gives permission to
25 :     * link the code of this program with the Half-Life Game Engine ("HL
26 :     * Engine") and Modified Game Libraries ("MODs") developed by Valve,
27 :     * L.L.C ("Valve"). You must obey the GNU General Public License in all
28 :     * respects for all of the code used other than the HL Engine and MODs
29 :     * from Valve. If you modify this file, you may extend this exception
30 :     * to your version of the file, but you are not obligated to do so. If
31 :     * you do not wish to do so, delete this exception statement from your
32 :     * version.
33 :     */
34 :    
35 :     #include <amxmodx>
36 :     #include <csx>
37 :    
38 :     new g_pingSum[33]
39 :     new g_pingCount[33]
40 :     new g_inGame[33]
41 :    
42 :     public plugin_init()
43 :     {
44 :     register_plugin("CS Stats Logging", AMXX_VERSION_STR, "AMXX Dev Team")
45 :     }
46 :    
47 :     public client_disconnect(id)
48 :     {
49 :     if (!g_inGame[id])
50 :     return
51 :    
52 :     g_inGame[id] = 0
53 :    
54 :     if (is_user_bot(id))
55 :     {
56 :     return
57 :     }
58 :    
59 :     remove_task(id)
60 :    
61 :     new szTeam[16], szName[32], szAuthid[32], iStats[8], iHits[8], szWeapon[24]
62 :     new iUserid = get_user_userid(id)
63 :     new _max = xmod_get_maxweapons()
64 :    
65 :     get_user_team(id, szTeam, 15)
66 :     get_user_name(id, szName, 31)
67 :     get_user_authid(id, szAuthid, 31)
68 :    
69 :     for (new i = 1 ; i < _max ; ++i)
70 :     {
71 :     if (get_user_wstats(id, i, iStats, iHits))
72 :     {
73 :     xmod_get_wpnname(i, szWeapon, 23)
74 :    
75 :     log_message("^"%s<%d><%s><%s>^" triggered ^"weaponstats^" (weapon ^"%s^") (shots ^"%d^") (hits ^"%d^") (kills ^"%d^") (headshots ^"%d^") (tks ^"%d^") (damage ^"%d^") (deaths ^"%d^")",
76 :     szName, iUserid, szAuthid, szTeam, szWeapon, iStats[4], iStats[5], iStats[0], iStats[2], iStats[3], iStats[6], iStats[1])
77 :     log_message("^"%s<%d><%s><%s>^" triggered ^"weaponstats2^" (weapon ^"%s^") (head ^"%d^") (chest ^"%d^") (stomach ^"%d^") (leftarm ^"%d^") (rightarm ^"%d^") (leftleg ^"%d^") (rightleg ^"%d^")",
78 :     szName, iUserid, szAuthid, szTeam, szWeapon, iHits[1], iHits[2], iHits[3], iHits[4], iHits[5], iHits[6], iHits[7])
79 :     }
80 :     }
81 :    
82 :     new iTime = get_user_time(id, 1)
83 :    
84 :     log_message("^"%s<%d><%s><%s>^" triggered ^"time^" (time ^"%d:%02d^")", szName, iUserid, szAuthid, szTeam, (iTime / 60), (iTime % 60))
85 :     log_message("^"%s<%d><%s><%s>^" triggered ^"latency^" (ping ^"%d^")", szName, iUserid, szAuthid, szTeam, (g_pingSum[id] / (g_pingCount[id] ? g_pingCount[id] : 1)))
86 :     }
87 :    
88 :     public client_connect(id)
89 :     {
90 :     g_inGame[id] = 0
91 :     }
92 :    
93 :     public client_putinserver(id)
94 :     {
95 :     g_inGame[id] = 1
96 :     if (!is_user_bot(id))
97 :     {
98 :     g_pingSum[id] = g_pingCount[id] = 0
99 :     if (task_exists(id))
100 :     remove_task(id)
101 :     set_task(19.5, "getPing", id, "", 0, "b")
102 :     }
103 :     }
104 :    
105 :     public getPing(id)
106 :     {
107 :     new iPing, iLoss
108 :    
109 :     get_user_ping(id, iPing, iLoss)
110 :     g_pingSum[id] += iPing
111 :     ++g_pingCount[id]
112 :     }

Contact
ViewVC Help
Powered by ViewVC 1.0.4