Parent Directory | Revision Log
Revision 1 - (view) (download)
1 : | ian | 1 | /* AMX Mod X |
2 : | * Info. Messages 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 : | #define MAX_MESSAGES 6 | ||
39 : | #define X_POS -1.0 | ||
40 : | #define Y_POS 0.20 | ||
41 : | #define HOLD_TIME 12.0 | ||
42 : | |||
43 : | new g_Values[MAX_MESSAGES][3] | ||
44 : | new g_Messages[MAX_MESSAGES][384] | ||
45 : | new g_MessagesNum | ||
46 : | new g_Current | ||
47 : | |||
48 : | public plugin_init() | ||
49 : | { | ||
50 : | register_plugin("Info. Messages", AMXX_VERSION_STR, "AMXX Dev Team") | ||
51 : | register_dictionary("imessage.txt") | ||
52 : | register_dictionary("common.txt") | ||
53 : | register_srvcmd("amx_imessage", "setMessage") | ||
54 : | register_cvar("amx_freq_imessage", "10") | ||
55 : | |||
56 : | new lastinfo[8] | ||
57 : | get_localinfo("lastinfomsg", lastinfo, 7) | ||
58 : | g_Current = str_to_num(lastinfo) | ||
59 : | set_localinfo("lastinfomsg", "") | ||
60 : | } | ||
61 : | |||
62 : | public infoMessage() | ||
63 : | { | ||
64 : | if (g_Current >= g_MessagesNum) | ||
65 : | g_Current = 0 | ||
66 : | |||
67 : | new hostname[64] | ||
68 : | |||
69 : | get_cvar_string("hostname", hostname, 63) | ||
70 : | replace(g_Messages[g_Current], 380, "%hostname%", hostname) | ||
71 : | |||
72 : | set_hudmessage(g_Values[g_Current][0], g_Values[g_Current][1], g_Values[g_Current][2], X_POS, Y_POS, 0, 0.5, HOLD_TIME, 2.0, 2.0, -1) | ||
73 : | show_hudmessage(0, "%s", g_Messages[g_Current]) | ||
74 : | client_print(0, print_console, "%s", g_Messages[g_Current]) | ||
75 : | ++g_Current | ||
76 : | |||
77 : | new Float:freq_im = get_cvar_float("amx_freq_imessage") | ||
78 : | |||
79 : | if (freq_im > 0.0) | ||
80 : | set_task(freq_im, "infoMessage", 12345) | ||
81 : | } | ||
82 : | |||
83 : | public setMessage() | ||
84 : | { | ||
85 : | if (g_MessagesNum >= MAX_MESSAGES) | ||
86 : | { | ||
87 : | server_print("%L", LANG_SERVER, "INF_REACH") | ||
88 : | return PLUGIN_HANDLED | ||
89 : | } | ||
90 : | |||
91 : | remove_task(12345) | ||
92 : | read_argv(1, g_Messages[g_MessagesNum], 380) | ||
93 : | |||
94 : | while (replace(g_Messages[g_MessagesNum], 380, "\n", "^n")) {} | ||
95 : | |||
96 : | new mycol[12] | ||
97 : | |||
98 : | read_argv(2, mycol, 11) // RRRGGGBBB | ||
99 : | g_Values[g_MessagesNum][2] = str_to_num(mycol[6]) | ||
100 : | |||
101 : | mycol[6] = 0 | ||
102 : | g_Values[g_MessagesNum][1] = str_to_num(mycol[3]) | ||
103 : | |||
104 : | mycol[3] = 0 | ||
105 : | g_Values[g_MessagesNum][0] = str_to_num(mycol[0]) | ||
106 : | |||
107 : | g_MessagesNum++ | ||
108 : | |||
109 : | new Float:freq_im = get_cvar_float("amx_freq_imessage") | ||
110 : | |||
111 : | if (freq_im > 0.0) | ||
112 : | set_task(freq_im, "infoMessage", 12345) | ||
113 : | |||
114 : | return PLUGIN_HANDLED | ||
115 : | } | ||
116 : | |||
117 : | public plugin_end() | ||
118 : | { | ||
119 : | new lastinfo[8] | ||
120 : | |||
121 : | num_to_str(g_Current, lastinfo, 7) | ||
122 : | set_localinfo("lastinfomsg", lastinfo) | ||
123 : | } |
Contact | ViewVC Help |
Powered by ViewVC 1.0.4 |