AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Need help with a sound script (https://forums.alliedmods.net/showthread.php?t=10201)

XunTric 02-11-2005 12:18

Need help with a sound script
 
One of my first plugins. What im trying to make is when a admin types amx_sound <file name> it will get played for everyone on the server. If anybody know if there is any plugin like it already tell me... Here it is:
Code:
#include <amxmodx> plublic plugin_init() {     register_plugin("Admin Sounds", "1.0", "XunTric")     register_concmd("amx_sound", "cmdsound", ADMIN_SLAY, "<Sound name> Plays a sound for the server") } plublic cmdsound(id,level,cid) {     if(!cmd_access(id,level,cid,1))          return PLUGIN_HANDLED     server_cmd("play sound/adminsound/%s")          return PLUGIN_CONTINUE }

XxAvalanchexX 02-11-2005 16:04

Try
Code:
client_cmd(0,"speak ^"sound/adminsound/%s^"");
. Although it won't work properly, since you have a %s but nothing to replace it with.

XunTric 02-11-2005 17:32

Hehe i knew you would help :) You have been helping me with some plugins last week. But it still doesnt work. I get 7 errors when im trying to compile it.

Crazywelder1 02-11-2005 17:46

i think u have to precache the sounds but i am not sure i am probably wrong<Avalanche am i right or way off???

TotalNoobScripter 02-11-2005 19:33

if they are custom sounds, and no one else has em, you should precache them. If they are standard, using client_cmd speak should be no problem.

TotalNoobScripter 02-11-2005 19:44

Code:
#include <amxmodx> #include <amxmisc> plublic plugin_init() {     register_plugin("Admin Sounds", "1.0", "Teh Wooters Ate the Hooters")     register_concmd("amx_sound", "cmdsound", ADMIN_SLAY, "<Sound name> Plays a sound for the server") } plublic cmdsound(id,level,cid) { new output[64]     if(!cmd_access(id,level,cid,1)) {          return PLUGIN_HANDLED }     read_argv(1,output,63)     client_cmd(0,"speak ^"sound/adminsound/%s^"",output)     client_print(0,print_chat,"[♀] Server has made everyone listen to %s!",output)          return PLUGIN_CONTINUE } public plugin_precache() { /* precache_sound("sound/adminsound/whatever.wav") precache_sound("sound/adminsound/whatever.wav") precache_sound("sound/adminsound/whatever.wav") // Only if the client does not download the wav when they join. */

now, this should work.

Note: In the client print if u see a ♀ or a bunch of random numbers, compile anyway and see if it will work. If not, dam, you cant see my secret message :twisted:

XxAvalanchexX 02-11-2005 22:45

No, that won't work at all.

You declare a function "plublic" two times, have random mis-indentations, and don't close the plugin_precache with another brace. Additionally, the last parameter for cmd_access should be 2 in that case.

XunTric 02-12-2005 14:26

Quote:

Originally Posted by TotalNoobScripter
Code:
#include <amxmodx> #include <amxmisc> plublic plugin_init() {     register_plugin("Admin Sounds", "1.0", "Teh Wooters Ate the Hooters")     register_concmd("amx_sound", "cmdsound", ADMIN_SLAY, "<Sound name> Plays a sound for the server") } plublic cmdsound(id,level,cid) { new output[64]     if(!cmd_access(id,level,cid,1)) {          return PLUGIN_HANDLED }     read_argv(1,output,63)     client_cmd(0,"speak ^"sound/adminsound/%s^"",output)     client_print(0,print_chat,"[♀] Server has made everyone listen to %s!",output)          return PLUGIN_CONTINUE } public plugin_precache() { /* precache_sound("sound/adminsound/whatever.wav") precache_sound("sound/adminsound/whatever.wav") precache_sound("sound/adminsound/whatever.wav") // Only if the client does not download the wav when they join. */

now, this should work.

Note: In the client print if u see a ♀ or a bunch of random numbers, compile anyway and see if it will work. If not, dam, you cant see my secret message :twisted:

Didnt work :( still get 6 errors. Why did you post your own name in the plugin?
And yes, its custom sounds.
Can i use mp3 files also?

Da Bishop 02-12-2005 14:39

Code:
#include <amxmodx> #include <amxmisc> plublic plugin_init() {     register_plugin("Admin Sounds", "1.0", "Teh Wooters Ate the Hooters")     register_concmd("amx_sound", "cmdsound", ADMIN_SLAY, "<Sound name> Plays a sound for the server") } plublic cmdsound(id,level,cid) { new output[64]     if(!cmd_access(id,level,cid,1)) {          return PLUGIN_HANDLED }     read_argv(1,output,63)     client_cmd(0,play "adminsound/%s", output)     client_print(0,print_chat,"[♀] Server has made everyone listen to %s!",output) }          return PLUGIN_CONTINUE } public plugin_precache() { /* precache_sound("sound/adminsound/whatever.wav") precache_sound("sound/adminsound/whatever.wav") precache_sound("sound/adminsound/whatever.wav") // Only if the client does not download the wav when they join. */

play command starts in the sound folder... precache might too

TotalNoobScripter 02-12-2005 14:44

Teh Wooters Ate Teh Hooters was a joke...


All times are GMT -4. The time now is 19:21.

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