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

Annotation of /imessage.sma

Parent Directory Parent Directory | Revision Log Revision Log


Revision 17 - (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 X_POS -1.0
39 :     #define Y_POS 0.20
40 :     #define HOLD_TIME 12.0
41 :    
42 : ian 17 new Array:g_Values
43 :     new Array:g_Messages
44 : ian 1 new g_MessagesNum
45 :     new g_Current
46 :    
47 : ian 17 #define charsof(%1) (sizeof(%1)-1)
48 :    
49 :     new amx_freq_imessage;
50 :    
51 : ian 1 public plugin_init()
52 :     {
53 : ian 17 g_Messages=ArrayCreate(384);
54 :     g_Values=ArrayCreate(3);
55 : ian 1 register_plugin("Info. Messages", AMXX_VERSION_STR, "AMXX Dev Team")
56 :     register_dictionary("imessage.txt")
57 :     register_dictionary("common.txt")
58 :     register_srvcmd("amx_imessage", "setMessage")
59 : ian 17 amx_freq_imessage=register_cvar("amx_freq_imessage", "10")
60 : ian 1
61 :     new lastinfo[8]
62 :     get_localinfo("lastinfomsg", lastinfo, 7)
63 :     g_Current = str_to_num(lastinfo)
64 :     set_localinfo("lastinfomsg", "")
65 :     }
66 :    
67 :     public infoMessage()
68 :     {
69 :     if (g_Current >= g_MessagesNum)
70 :     g_Current = 0
71 :    
72 : ian 17 // No messages, just get out of here
73 :     if (g_MessagesNum==0)
74 :     {
75 :     return;
76 :     }
77 : ian 1
78 : ian 17 new values[3];
79 :     new Message[384];
80 : ian 1
81 : ian 17 ArrayGetString(g_Messages, g_Current, Message, charsof(Message));
82 :     ArrayGetArray(g_Values, g_Current, values);
83 : ian 1
84 : ian 17 new hostname[64];
85 : ian 1
86 : ian 17 get_cvar_string("hostname", hostname, 63);
87 :     replace(Message, 380, "%hostname%", hostname);
88 :    
89 :     set_hudmessage(values[0], values[1], values[2], X_POS, Y_POS, 0, 0.5, HOLD_TIME, 2.0, 2.0, -1);
90 :    
91 :     show_hudmessage(0, "%s", Message);
92 :    
93 :     client_print(0, print_console, "%s", Message);
94 :     ++g_Current;
95 :    
96 :     new Float:freq_im = get_pcvar_float(amx_freq_imessage);
97 :    
98 : ian 1 if (freq_im > 0.0)
99 : ian 17 set_task(freq_im, "infoMessage", 12345);
100 : ian 1 }
101 :    
102 :     public setMessage()
103 :     {
104 :    
105 : ian 17 new Message[384];
106 :    
107 : ian 1 remove_task(12345)
108 : ian 17 read_argv(1, Message, 380)
109 : ian 1
110 : ian 17 while (replace(Message, 380, "\n", "^n")) {}
111 : ian 1
112 :     new mycol[12]
113 : ian 17 new vals[3];
114 : ian 1
115 :     read_argv(2, mycol, 11) // RRRGGGBBB
116 : ian 17 vals[2] = str_to_num(mycol[6])
117 : ian 1
118 :     mycol[6] = 0
119 : ian 17 vals[1] = str_to_num(mycol[3])
120 : ian 1
121 :     mycol[3] = 0
122 : ian 17 vals[0] = str_to_num(mycol[0])
123 : ian 1
124 :     g_MessagesNum++
125 :    
126 : ian 17 new Float:freq_im = get_pcvar_float(amx_freq_imessage)
127 : ian 1
128 : ian 17 ArrayPushString(g_Messages, Message);
129 :     ArrayPushArray(g_Values, vals);
130 :    
131 : ian 1 if (freq_im > 0.0)
132 :     set_task(freq_im, "infoMessage", 12345)
133 :    
134 :     return PLUGIN_HANDLED
135 :     }
136 :    
137 :     public plugin_end()
138 :     {
139 :     new lastinfo[8]
140 :    
141 :     num_to_str(g_Current, lastinfo, 7)
142 :     set_localinfo("lastinfomsg", lastinfo)
143 :     }

Contact
ViewVC Help
Powered by ViewVC 1.0.4