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

Annotation of /scrollmsg.sma

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (view) (download)

1 : ian 1 /* AMX Mod X
2 :     * Scrolling Message 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 SPEED 0.3
39 :     #define SCROLLMSG_SIZE 512
40 :    
41 :     new g_startPos
42 :     new g_endPos
43 :     new g_scrollMsg[SCROLLMSG_SIZE]
44 :     new g_displayMsg[SCROLLMSG_SIZE]
45 :     new Float:g_xPos
46 :     new g_Length
47 :     new g_Frequency
48 :    
49 :     public plugin_init()
50 :     {
51 :     register_plugin("Scrolling Message", AMXX_VERSION_STR, "AMXX Dev Team")
52 :     register_dictionary("scrollmsg.txt")
53 :     register_dictionary("common.txt")
54 :     register_srvcmd("amx_scrollmsg", "setMessage")
55 :     }
56 :    
57 :     public showMsg()
58 :     {
59 :     new a = g_startPos, i = 0
60 :    
61 :     while (a < g_endPos)
62 :     g_displayMsg[i++] = g_scrollMsg[a++]
63 :    
64 :     g_displayMsg[i] = 0
65 :    
66 :     if (g_endPos < g_Length)
67 :     g_endPos++
68 :    
69 :     if (g_xPos > 0.35)
70 :     g_xPos -= 0.0063
71 :     else
72 :     {
73 :     g_startPos++
74 :     g_xPos = 0.35
75 :     }
76 :    
77 :     set_hudmessage(200, 100, 0, g_xPos, 0.90, 0, SPEED, SPEED, 0.05, 0.05, 2)
78 :     show_hudmessage(0, "%s", g_displayMsg)
79 :     }
80 :    
81 :     public msgInit()
82 :     {
83 :     g_endPos = 1
84 :     g_startPos = 0
85 :     g_xPos = 0.65
86 :    
87 :     new hostname[64]
88 :    
89 :     get_cvar_string("hostname", hostname, 63)
90 :     replace(g_scrollMsg, SCROLLMSG_SIZE-1, "%hostname%", hostname)
91 :    
92 :     g_Length = strlen(g_scrollMsg)
93 :    
94 :     set_task(SPEED, "showMsg", 123, "", 0, "a", g_Length + 48)
95 :     client_print(0, print_console, "%s", g_scrollMsg)
96 :     }
97 :    
98 :     public setMessage()
99 :     {
100 :     remove_task(123) /* remove current messaging */
101 :     read_argv(1, g_scrollMsg, SCROLLMSG_SIZE-1)
102 :    
103 :     g_Length = strlen(g_scrollMsg)
104 :    
105 :     new mytime[32]
106 :    
107 :     read_argv(2, mytime, 31)
108 :    
109 :     g_Frequency = str_to_num(mytime)
110 :    
111 :     if (g_Frequency > 0)
112 :     {
113 :     new minimal = floatround((g_Length + 48) * (SPEED + 0.1))
114 :    
115 :     if (g_Frequency < minimal)
116 :     {
117 :     server_print("%L", LANG_SERVER, "MIN_FREQ", minimal)
118 :     g_Frequency = minimal
119 :     }
120 :    
121 :     server_print("%L", LANG_SERVER, "MSG_FREQ", g_Frequency / 60, g_Frequency % 60)
122 :     set_task(float(g_Frequency), "msgInit", 123, "", 0, "b")
123 :     }
124 :     else
125 :     server_print("%L", LANG_SERVER, "MSG_DISABLED")
126 :    
127 :     return PLUGIN_HANDLED
128 :     }

Contact
ViewVC Help
Powered by ViewVC 1.0.4