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

Annotation of /easy_speech_plugin.sma

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (view) (download)

1 : ian 1 /***********************************************************************
2 :     * amx_ejl_easyspeech.sma version 1.4c November 28/2002
3 :     * By: Eric Lidman Alias: Ludwig van ejlmozart@hotmail.com
4 :     * Upgrade: http://lidmanmusic.com/cs/plugins.html
5 :     *
6 :     * This plugin makes using half-life speech much easier and more fun.
7 :     * Speech commands can now be done through the chat without using the
8 :     * console. The commands themselves have been shortened too for the
9 :     * console. For example, in the chat, or console simply preceed you
10 :     * your speech words with yy. Also shortcuts have been added to make it
11 :     * easier to use the speech vocabulary from directories other than the
12 :     * default (/vox).
13 :     *
14 :     * UPDATED: CAN BE DONE AS THROUGH SERVER CONSOLE TOO
15 :     *
16 :     * Commands (console or chat):
17 :     *
18 :     * yy_help <search target>
19 :     * uu_help <search target>
20 :     * tt_help <search target>
21 :     * ii_help <search target>
22 :     * rr_help <search target>
23 :     * yy <speech words from the /vox directory>
24 :     * uu <speech words from the /fvox directory>
25 :     * tt <speech words from the /hgrunt directory>
26 :     * ii <speech words from the /scientist directory>
27 :     * rr <speech words from the /barney directory>
28 :     * amx_speak <part of nick> --- speak words to one
29 :     * amx_speakteam <Team> --- speak words to all on a team
30 :     * ams_speakall --- speak words to all
31 :     * amx_stopallsounds --- in case you need to stop looping sounds
32 :     *
33 :     * Example (try this out):
34 :     *
35 :     * say: yy the administration will control you
36 :     *
37 :     * Additionally, I have included a search engine, also useable from
38 :     * the chat. This way you can find the vocabulary words you are looking
39 :     * for from right within the game. For example, say yy_help ad
40 :     * and the search will return up to 20 words containing "ad" that you
41 :     * can say with half-life speech, such as "administration".
42 :     *
43 :     * SETUP
44 :     * Same as all other AMX plugins, but in order for the search
45 :     * engine to work you need to have the five text files in your
46 :     * ../addons/amx folder
47 :     * Those files are yy_search.txt, tt_search.txt, uu_search.txt
48 :     * ii_search.txt, and rr_search.txt Please go to the thread for this
49 :     * plugin on the amx forums to get the files which are attached there.
50 :     * Or you may go to: http://lidmanmusic.com/cs/plugins.html
51 :     * and grab them off my site.
52 :     *
53 :     *********************************************************************/
54 :    
55 :     #include <amxmod>
56 :     #include <amxmisc>
57 :    
58 :     new numword
59 :     new numword_yy
60 :     new numword_uu
61 :     new numword_tt
62 :     new numword_rr
63 :     new numword_ii
64 :     new T_TrigWords_yy[650][25]
65 :     new T_TrigWords_uu[150][25]
66 :     new T_TrigWords_tt[350][25]
67 :     new T_TrigWords_rr[200][25]
68 :     new T_TrigWords_ii[400][25]
69 :    
70 :     public sp_shrtcut(id,level,cid) {
71 :     if (!cmd_access(id,level,cid,2))
72 :     return PLUGIN_HANDLED
73 :    
74 :     new name[32]
75 :     new Speech[192]
76 :     new voicedir[32]
77 :     new arg[20]
78 :     read_argv(0,arg,19)
79 :    
80 :     if(equal(arg,"uu"))
81 :     copy(voicedir,32,"fvox/")
82 :     else if(equal(arg,"tt"))
83 :     copy(voicedir,32,"hgrunt/")
84 :     else if(equal(arg,"rr"))
85 :     copy(voicedir,32,"barney/")
86 :     else if(equal(arg,"ii"))
87 :     copy(voicedir,32,"scientist/")
88 :    
89 :     read_args(Speech,191)
90 :     get_user_name(id,name,31)
91 :    
92 :     if(safety_check(Speech)){
93 :     console_print(id,"[AMX] Illegal input. Speech command aborted.")
94 :     return PLUGIN_HANDLED
95 :     }
96 :    
97 :     if(equal(arg,"amx_speak")){
98 :     new arg1[32]
99 :     read_argv(1,arg1,31)
100 :     new player = cmd_target(id,arg1,1)
101 :     if (!player) return PLUGIN_HANDLED
102 :     new name2[32]
103 :     get_user_name(player,name2,31)
104 :     client_cmd(player,"spk ^"%s^"",Speech[strlen(arg1) + 1])
105 :     console_print(id,"To %s YOU SPOKE: %s",name2,Speech[strlen(arg1) + 1])
106 :     console_print(player,"%s SPOKE TO YOU: %s",name,Speech[strlen(arg1) + 1])
107 :     return PLUGIN_HANDLED
108 :     }
109 :    
110 :     if(equal(arg,"amx_speakteam")){
111 :     new players[32], inum, teamname[32]
112 :     read_argv(1,teamname,31)
113 :     get_players(players,inum,"e",teamname)
114 :     for(new i = 0 ;i < inum ;i++) {
115 :     client_cmd(players[i],"spk ^"%s^"",Speech[strlen(teamname) +1])
116 :     }
117 :     if (inum){
118 :     console_print(id,"[AMX] All clients from ^"%s^" team have been spoken to",teamname)
119 :     }else{
120 :     console_print(id,"[AMX] No clients in such team")
121 :     }
122 :     return PLUGIN_HANDLED
123 :     }
124 :    
125 :     if(strlen(voicedir) > 0){
126 :     client_cmd(0,"spk ^"%s%s^"",voicedir,Speech)
127 :     }else{
128 :     client_cmd(0,"spk ^"%s^"",Speech)
129 :     }
130 :     client_print(0,print_console,"%s SPOKE %s",name,Speech)
131 :     server_print("%s SPOKE %s",name,Speech)
132 :     return PLUGIN_HANDLED
133 :     }
134 :    
135 :     public handle_say(id) {
136 :    
137 :     if ((get_user_flags(id)&ADMIN_VOTE)){
138 :     new name[32]
139 :     new Speech[192]
140 :     new voicedir[32]
141 :     new arg[100]
142 :     new cmd[10]
143 :     new argx[32]
144 :     read_argv(1,arg,99)
145 :     parse(arg,cmd,9,argx,31)
146 :    
147 :     if(equal(arg,"yy_help",7)){
148 :     search_engine(id,0,argx)
149 :     return PLUGIN_HANDLED
150 :     }
151 :     else if(equal(arg,"uu_help",7)){
152 :     search_engine(id,1,argx)
153 :     return PLUGIN_HANDLED
154 :     }
155 :     else if(equal(arg,"tt_help",7)){
156 :     search_engine(id,2,argx)
157 :     return PLUGIN_HANDLED
158 :     }
159 :     else if(equal(arg,"rr_help",7)){
160 :     search_engine(id,3,argx)
161 :     return PLUGIN_HANDLED
162 :     }
163 :     else if(equal(arg,"ii_help",7)){
164 :     search_engine(id,4,argx)
165 :     return PLUGIN_HANDLED
166 :     }
167 :     else if(equal(arg,"uu",2))
168 :     copy(voicedir,32,"fvox/")
169 :     else if(equal(arg,"tt",2))
170 :     copy(voicedir,32,"hgrunt/")
171 :     else if(equal(arg,"rr",2))
172 :     copy(voicedir,32,"barney/")
173 :     else if(equal(arg,"ii",2))
174 :     copy(voicedir,32,"scientist/")
175 :     else if(equal(arg,"yy",2))
176 :     copy(voicedir,32,"")
177 :     else
178 :     return PLUGIN_CONTINUE
179 :    
180 :     read_args(Speech,191)
181 :     remove_quotes(Speech)
182 :     get_user_name(id,name,31)
183 :    
184 :     if(safety_check(Speech)){
185 :     client_print(id,print_chat,"[AMX] Illegal input. Speech command aborted.")
186 :     return PLUGIN_HANDLED
187 :     }
188 :    
189 :     if(strlen(voicedir) > 0){
190 :     client_cmd(0,"spk ^"%s%s^"",voicedir,Speech[3])
191 :     }else{
192 :     client_cmd(0,"spk ^"%s^"",Speech[3])
193 :     }
194 :     client_print(0,print_console,"%s SPOKE %s",name,Speech[3])
195 :     server_print("%s SPOKE %s",name,Speech[3])
196 :     return PLUGIN_HANDLED
197 :     }
198 :     return PLUGIN_CONTINUE
199 :     }
200 :    
201 :     safety_check(Speech[]){
202 :     new wordlen
203 :     new ill = 0
204 :     for(new i=0; i<strlen(Speech);i++){
205 :     if( (Speech[i] < 'a' || Speech[i] > 'z') && (Speech[i] < '0' || Speech[i] > '9') ){
206 :     if( (!equal(Speech[i]," ",1)) && (!equal(Speech[i],"!",1)) && (!equal(Speech[i],"/",1)) &&
207 :     (!equal(Speech[i],"_",1)) && (!equal(Speech[i],",",1)) && (!equal(Speech[i],".",1)) )
208 :     ill = 1
209 :     }
210 :     if(equal(Speech[i]," ",1)){
211 :     wordlen = 0
212 :     }else{
213 :     wordlen++
214 :     if(wordlen > 30){
215 :     ill = 1
216 :     }
217 :     }
218 :     }
219 :     return ill
220 :     }
221 :    
222 :     public admin_ssearch(id) {
223 :     new arg[32]
224 :     new argx[32]
225 :     read_argv(0,arg,31)
226 :     read_argv(1,argx,31)
227 :     if(equal(arg,"yy_help",7)){
228 :     search_engine(id,0,argx)
229 :     }
230 :     else if(equal(arg,"uu_help",7)){
231 :     search_engine(id,1,argx)
232 :     }
233 :     else if(equal(arg,"tt_help",7)){
234 :     search_engine(id,2,argx)
235 :     }
236 :     else if(equal(arg,"rr_help",7)){
237 :     search_engine(id,3,argx)
238 :     }
239 :     else if(equal(arg,"ii_help",7)){
240 :     search_engine(id,4,argx)
241 :     }
242 :     return PLUGIN_HANDLED
243 :     }
244 :    
245 :     search_engine(id,type,argx[]){
246 :     new TrigWords[20][25]
247 :     new b
248 :     new stype[10]
249 :    
250 :     if(type == 0){
251 :     copy(stype,10,"vox")
252 :     numword = numword_yy
253 :     for(new a = 0; a < numword; a++) {
254 :     if (containi(T_TrigWords_yy[a],argx) != -1) {
255 :     if(b < 20){
256 :     copy(TrigWords[b], 25, T_TrigWords_yy[a])
257 :     b++
258 :     }
259 :     }
260 :     }
261 :     }
262 :     else if(type == 1){
263 :     copy(stype,10,"fvox")
264 :     numword = numword_uu
265 :     for(new a = 0; a < numword; a++) {
266 :     if (containi(T_TrigWords_uu[a],argx) != -1) {
267 :     if(b < 20){
268 :     copy(TrigWords[b], 25, T_TrigWords_uu[a])
269 :     b++
270 :     }
271 :     }
272 :     }
273 :     }
274 :     else if(type == 2){
275 :     copy(stype,10,"hgrunt")
276 :     numword = numword_tt
277 :     for(new a = 0; a < numword; a++) {
278 :     if (containi(T_TrigWords_tt[a],argx) != -1) {
279 :     if(b < 20){
280 :     copy(TrigWords[b], 25, T_TrigWords_tt[a])
281 :     b++
282 :     }
283 :     }
284 :     }
285 :     }
286 :     else if(type == 3){
287 :     copy(stype,10,"barney")
288 :     numword = numword_rr
289 :     for(new a = 0; a < numword; a++) {
290 :     if (containi(T_TrigWords_rr[a],argx) != -1) {
291 :     if(b < 20){
292 :     copy(TrigWords[b], 25, T_TrigWords_rr[a])
293 :     b++
294 :     }
295 :     }
296 :     }
297 :     }
298 :     else if(type == 4){
299 :     copy(stype,10,"scientist")
300 :     numword = numword_ii
301 :     for(new a = 0; a < numword; a++) {
302 :     if (containi(T_TrigWords_ii[a],argx) != -1) {
303 :     if(b < 20){
304 :     copy(TrigWords[b], 25, T_TrigWords_ii[a])
305 :     b++
306 :     }
307 :     }
308 :     }
309 :     }
310 :     new msg[800]
311 :     if(b > 0){
312 :     format(msg,800,"%d %s sounds.^nHere are search results,^nonly 1st 20 shown:^n^n %s^n %s^n %s^n %s^n %s^n %s^n %s^n %s^n %s^n %s^n %s^n %s^n %s^n %s^n %s^n %s^n %s^n %s^n %s^n %s^n",numword, stype, TrigWords[0],TrigWords[1],TrigWords[2],TrigWords[3],
313 :     TrigWords[4],TrigWords[5],TrigWords[6],TrigWords[7],TrigWords[8],TrigWords[9],TrigWords[10],TrigWords[11],TrigWords[12],TrigWords[13],TrigWords[14],TrigWords[15],
314 :     TrigWords[16],TrigWords[17],TrigWords[18],TrigWords[19])
315 :     set_hudmessage(10,100,150, 0.75, 0.10, 2, 0.02, 14.0, 0.01, 0.1, 4)
316 :     show_hudmessage(id,"%s",msg)
317 :     client_print(id,print_chat,"[AMX] Sound search results: See right side of screen.")
318 :     }else{
319 :     set_hudmessage(10,100,150, 0.75, 0.10, 2, 0.02, 9.0, 0.01, 0.1, 4)
320 :     show_hudmessage(id,"No match to your search,^n%d %s sounds.",numword,stype)
321 :     client_print(id,print_chat,"[AMX] Sound search results: See right side of screen.")
322 :     }
323 :     return PLUGIN_CONTINUE
324 :     }
325 :    
326 :     public admin_stopallsounds(id,level,cid) {
327 :     if (!cmd_access(id,level,cid,1))
328 :     return PLUGIN_HANDLED
329 :     client_cmd(0,"stopsound")
330 :     client_print(0,print_console,"[AMX] 'stopsound' executed on all clients")
331 :     server_print("[AMX] 'stopsound' executed on all clients")
332 :     return PLUGIN_HANDLED
333 :     }
334 :    
335 :     public plugin_init() {
336 :     register_plugin("Easy Speech Plugin","1.4c","EJL")
337 :     register_concmd("yy","sp_shrtcut",ADMIN_VOTE,"<msg>: Speak words on system of everyone. <vox>")
338 :     register_concmd("uu","sp_shrtcut",ADMIN_VOTE,"<msg>: Speak words on system of everyone. <fvox>")
339 :     register_concmd("ii","sp_shrtcut",ADMIN_VOTE,"<msg>: Speak words on system of everyone. <scientist>")
340 :     register_concmd("rr","sp_shrtcut",ADMIN_VOTE,"<msg>: Speak words on system of everyone. <barney>")
341 :     register_concmd("tt","sp_shrtcut",ADMIN_VOTE,"<msg>: Speak words on system of everyone. <hgrunt>")
342 :     register_concmd("amx_speakall","sp_shrtcut",ADMIN_VOTE,"<msg>: Speak words on system of everyone.")
343 :     register_concmd("amx_speakteam","sp_shrtcut",ADMIN_VOTE,"<team> <msg>: Speak words on a whole team.")
344 :     register_concmd("amx_speak","sp_shrtcut",ADMIN_VOTE,"<part of nick> <msg>: Speak words on a player.")
345 :     register_concmd("amx_stopallsounds","admin_stopallsounds",ADMIN_VOTE,"executes stopsound on all clients -- useful for ending looped sounds.")
346 :     register_clcmd("yy_help","admin_ssearch",ADMIN_VOTE,"yy_help <search target>: Find words to speak from <vox>")
347 :     register_clcmd("uu_help","admin_ssearch",ADMIN_VOTE,"uu_help <search target>: Find words to speak from <fvox>")
348 :     register_clcmd("tt_help","admin_ssearch",ADMIN_VOTE,"tt_help <search target>: Find words to speak from <hgrunt>")
349 :     register_clcmd("rr_help","admin_ssearch",ADMIN_VOTE,"rr_help <search target>: Find words to speak from <barney>")
350 :     register_clcmd("ii_help","admin_ssearch",ADMIN_VOTE,"ii_help <search target>: Find words to speak from <scientist>")
351 :     register_clcmd("say","handle_say")
352 :    
353 :     new path[48],yysearch[65],uusearch[65],ttsearch[65],rrsearch[65],iisearch[65]
354 :     build_path(path,47,"$basedir")
355 :     format(yysearch,64,"%s/yy_search.txt",path)
356 :     format(uusearch,64,"%s/uu_search.txt",path)
357 :     format(ttsearch,64,"%s/tt_search.txt",path)
358 :     format(rrsearch,64,"%s/rr_search.txt",path)
359 :     format(iisearch,64,"%s/ii_search.txt",path)
360 :    
361 :     for(new a = 0; a < 650; a++) {
362 :     new data[25]
363 :     new stextsize = 0
364 :     read_file(yysearch,a,data,25,stextsize)
365 :     if(strlen(data) > 0){
366 :     copy(T_TrigWords_yy[numword_yy], 25, data)
367 :     numword_yy++
368 :     }
369 :     }
370 :     for(new a = 0; a < 150; a++) {
371 :     new data[25]
372 :     new stextsize = 0
373 :     read_file(uusearch,a,data,25,stextsize)
374 :     if(strlen(data) > 0){
375 :     copy(T_TrigWords_uu[numword_uu], 25, data)
376 :     numword_uu++
377 :     }
378 :     }
379 :     for(new a = 0; a < 350; a++) {
380 :     new data[25]
381 :     new stextsize = 0
382 :     read_file(ttsearch,a,data,25,stextsize)
383 :     if(strlen(data) > 0){
384 :     copy(T_TrigWords_tt[numword_tt], 25, data)
385 :     numword_tt++
386 :     }
387 :     }
388 :     for(new a = 0; a < 200; a++) {
389 :     new data[25]
390 :     new stextsize = 0
391 :     read_file(rrsearch,a,data,25,stextsize)
392 :     if(strlen(data) > 0){
393 :     copy(T_TrigWords_rr[numword_rr], 25, data)
394 :     numword_rr++
395 :     }
396 :     }
397 :     for(new a = 0; a < 400; a++) {
398 :     new data[25]
399 :     new stextsize = 0
400 :     read_file(iisearch,a,data,25,stextsize)
401 :     if(strlen(data) > 0){
402 :     copy(T_TrigWords_ii[numword_ii], 25, data)
403 :     numword_ii++
404 :     }
405 :     }
406 :     return PLUGIN_CONTINUE
407 :     }
408 :    

Contact
ViewVC Help
Powered by ViewVC 1.0.4