AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Play .wav when someonay says a word... (https://forums.alliedmods.net/showthread.php?t=25429)

TiToTal 03-13-2006 19:50

Play .wav when someonay says a word...
 
I think it's not hard...

I need to know how I can make a .wav sound plays when someone says a specific word... But, it has to play for everyone close to this person...

Code:
if(containi(said,"theword") != -1) {     ??? }

I only know this peace of code :oops: :stupid:

can someone plz help me?

kinsprite2 03-14-2006 03:19

Code:
public plugin_precache() { if (file_exists("sound/misc/woohoo.wav"))         precache_sound("misc/woohoo.wav") } public plugin_init() { ..........................         register_clcmd("say","check_say")     register_clcmd("say_team","check_say") } public check_say(id){ .................. clsaywh(id)     return PLUGIN_CONTINUE } public clsaywh(id) {     if (!is_user_alive(id)) {         client_print(id,print_chat,"%L", id, "NOTALIVE")         return  PLUGIN_HANDLED          }     if (file_exists("sound/misc/woohoo.wav"))         emit_sound(id,CHAN_STATIC, "misc/woohoo.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)       return  PLUGIN_HANDLED        }
just like this

TiToTal 03-14-2006 14:26

Quote:

Originally Posted by kinsprite2
Code:
public plugin_precache() { if (file_exists("sound/misc/woohoo.wav"))         precache_sound("misc/woohoo.wav") } public plugin_init() { ..........................         register_clcmd("say","check_say")     register_clcmd("say_team","check_say") } public check_say(id){ .................. clsaywh(id)     return PLUGIN_CONTINUE } public clsaywh(id) {     if (!is_user_alive(id)) {         client_print(id,print_chat,"%L", id, "NOTALIVE")         return  PLUGIN_HANDLED          }     if (file_exists("sound/misc/woohoo.wav"))         emit_sound(id,CHAN_STATIC, "misc/woohoo.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)       return  PLUGIN_HANDLED        }
just like this


O.O

is this plugin going to emit the sound only when some specific word is said?

VEN 03-14-2006 14:33

Quote:

is this plugin
This is not a plugin but a code snippet (example).

TiToTal 03-14-2006 15:54

Quote:

Originally Posted by VEN
Quote:

is this plugin
This is not a plugin but a code snippet (example).


yes, I know, thanks for correcting me... =P I make this mistakes normally, I don't speak english perfectly so I may get some mistakes...

I know.. so change my question to: "is this code... ?"

[ --<-@ ] Black Rose 03-14-2006 16:08

would this really work?
Code:
public plugin_precache() { if (file_exists("sound/misc/woohoo.wav"))         precache_sound("misc/woohoo.wav") }
the file_exist is totally unecessary and if it wold be there, there would be an ! in front of it

Zenith77 03-14-2006 16:17

Quote:

Originally Posted by [ --<-@
Black Rose]would this really work?
Code:
public plugin_precache() { if (file_exists("sound/misc/woohoo.wav"))         precache_sound("misc/woohoo.wav") }
the file_exist is totally unecessary and if it wold be there, there would be an ! in front of it

Putting a '!' in front of the if statement would precache the sound if it DIDN'T exist. Which would then make it truely unecssary.
Why? It prevents the server from crashing if it does not have it. But, you should make it print a warning message if its not precached to let the server know so they can add it.

Just in case somebody wants to argue
Quote:

file_exists - Checks if a file exists (returns 1 on success, 0 on failure).

karlos 03-14-2006 16:18

"file_exist" is necessary
Code:

public plugin_precache() {
        precache_sound("misc/woohoo.wav")
}

this code would produce an error if wav is missing
so check if such file exists before using it

[ --<-@ ] Black Rose 03-14-2006 16:21

oh, i thought it was client side
so if the file was found on client then dl, if not no dl.
sry

karlos 03-14-2006 16:25

precache = load file
if client cannot load it, download it and then load it


All times are GMT -4. The time now is 20:22.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.