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

Annotation of /adminslots.sma

Parent Directory Parent Directory | Revision Log Revision Log


Revision 17 - (view) (download)

1 : ian 1 /* AMX Mod X
2 :     * Slots Reservation Plugin
3 :     *
4 :     * by the AMX Mod X Development Team
5 :     * originally developed by OLO
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 <amxmisc>
37 :    
38 :     new g_cmdLoopback[16]
39 :     new g_ResPtr
40 :     new g_HidePtr
41 :    
42 :     public plugin_init()
43 :     {
44 :     register_plugin("Slots Reservation", AMXX_VERSION_STR, "AMXX Dev Team")
45 :     register_dictionary("adminslots.txt")
46 :     register_dictionary("common.txt")
47 :     g_ResPtr = register_cvar("amx_reservation", "0")
48 :     g_HidePtr = register_cvar("amx_hideslots", "0")
49 :    
50 :     format(g_cmdLoopback, 15, "amxres%c%c%c%c", random_num('A', 'Z'), random_num('A', 'Z'), random_num('A', 'Z'), random_num('A', 'Z'))
51 :     register_clcmd(g_cmdLoopback, "ackSignal")
52 :     }
53 :    
54 :     public plugin_cfg()
55 :     {
56 :     set_task(3.0, "MapLoaded")
57 :     }
58 :    
59 :     public MapLoaded()
60 :     {
61 :     if (!get_pcvar_num(g_HidePtr))
62 :     return
63 :    
64 :     new maxplayers = get_maxplayers()
65 :     new players = get_playersnum(1)
66 :     new limit = maxplayers - get_pcvar_num(g_ResPtr)
67 :     setVisibleSlots(players, maxplayers, limit)
68 :     }
69 :    
70 :     public ackSignal(id)
71 :     {
72 :     new lReason[64]
73 :     format(lReason, 63, "%L", id, "DROPPED_RES")
74 :     server_cmd("kick #%d ^"%s^"", get_user_userid(id), lReason)
75 : ian 17
76 :     return PLUGIN_HANDLED
77 : ian 1 }
78 :    
79 :     public client_authorized(id)
80 :     {
81 :     new maxplayers = get_maxplayers()
82 :     new players = get_playersnum(1)
83 :     new limit = maxplayers - get_pcvar_num(g_ResPtr)
84 :    
85 :     if (access(id, ADMIN_RESERVATION) || (players <= limit))
86 :     {
87 :     if (get_pcvar_num(g_HidePtr) == 1)
88 :     setVisibleSlots(players, maxplayers, limit)
89 :     return PLUGIN_CONTINUE
90 :     }
91 :    
92 :     client_cmd(id, "%s", g_cmdLoopback)
93 :    
94 :     return PLUGIN_HANDLED
95 :     }
96 :    
97 :     public client_disconnect(id)
98 :     {
99 :     if (!get_pcvar_num(g_HidePtr))
100 :     return PLUGIN_CONTINUE
101 :    
102 :     new maxplayers = get_maxplayers()
103 :    
104 :     setVisibleSlots(get_playersnum(1) - 1, maxplayers, maxplayers - get_pcvar_num(g_ResPtr))
105 :     return PLUGIN_CONTINUE
106 :     }
107 :    
108 :     setVisibleSlots(players, maxplayers, limit)
109 :     {
110 :     new num = players + 1
111 :    
112 :     if (players == maxplayers)
113 :     num = maxplayers
114 :     else if (players < limit)
115 :     num = limit
116 :    
117 :     set_cvar_num("sv_visiblemaxplayers", num)
118 :     }

Contact
ViewVC Help
Powered by ViewVC 1.0.4