AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   sound message (https://forums.alliedmods.net/showthread.php?t=335928)

abaskime 01-14-2022 19:25

sound message
 
Hello!
I need a plugin when I type for example /ctc all players hear a sound
Only an admin can write this
can you do this?

Yusochan 01-16-2022 18:43

Re: sound message
 
PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <cromchat>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

#define ADMINACCESS    ADMIN_KICK

new const g_Sound[] = "misc/yoursound.wav";

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say /ctc""Sound");
    
register_clcmd("say_team /ctc""Sound");
}

public 
plugin_precache() {    
    
precache_sound(g_Sound);
}

public 
Sound(id) {
    if(
is_user_access(id)) {
        
        new 
szName[32];
        
get_user_name(idszName31);
        
CC_SendMessage(0"&x01ADMIN: &x04%s &x03Joined the game &x01!"szName);
        
client_cmd(0"spk %s"g_Sound);
    }
    else {
        
CC_SendMessage(id"&x03You don't have access to this &x04command !");
    }
}
    
bool:is_user_access(id)
    return !!(
get_user_flags(id) & ADMINACCESS


abaskime 01-17-2022 13:19

Re: sound message
 
Quote:

Originally Posted by Yusochan (Post 2768601)
PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <cromchat>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

#define ADMINACCESS    ADMIN_KICK

new const g_Sound[] = "misc/yoursound.wav";

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say /ctc""Sound");
    
register_clcmd("say_team /ctc""Sound");
}

public 
plugin_precache() {    
    
precache_sound(g_Sound);
}

public 
Sound(id) {
    if(
is_user_access(id)) {
        
        new 
szName[32];
        
get_user_name(idszName31);
        
CC_SendMessage(0"&x01ADMIN: &x04%s &x03Joined the game &x01!"szName);
        
client_cmd(0"spk %s"g_Sound);
    }
    else {
        
CC_SendMessage(id"&x03You don't have access to this &x04command !");
    }
}
    
bool:is_user_access(id)
    return !!(
get_user_flags(id) & ADMINACCESS


Thank you it works
Can you add a hud message in place of CC_SendMessage(0, "&x01ADMIN: &x04%s &x03Joined the game &x01!", szName);

Yusochan 01-17-2022 13:48

Re: sound message
 
Quote:

Originally Posted by abaskime (Post 2768654)
Thank you it works
Can you add a hud message in place of CC_SendMessage(0, "&x01ADMIN: &x04%s &x03Joined the game &x01!", szName);

Here you go :

PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <cromchat>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

#define ADMINACCESS    ADMIN_KICK

new const g_Sound[] = "misc/yoursound.wav";

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /ctc""Sound");
    
register_clcmd("say_team /ctc""Sound");
}

public 
plugin_precache() {    
    
precache_sound(g_Sound);
}

public 
Sound(id) {
    if(
is_user_access(id)) {
        
        new 
szName[32];
        
get_user_name(idszName31);
        
set_hudmessage(150255330.400.36, .effects, .holdtime5.0);
        
show_hudmessage(0"ADMIN: %s JOINED THE GAME !"szName);
        
client_cmd(id"spk %s"g_Sound);
    }
    else {
        
CC_SendMessage(id"&x03ONLY &x04ADMINS");
    }
}
    
bool:is_user_access(id)
    return !!(
get_user_flags(id) & ADMINACCESS


abaskime 01-17-2022 14:19

Re: sound message
 
thank you Bro :)

OciXCrom 01-17-2022 15:03

Re: sound message
 
Code:
bool:is_user_access(id)     return !!(get_user_flags(id) & ADMINACCESS)

Should be:

Code:
bool:is_user_access(id)     return (get_user_flags(id) & ADMINACCESS) != 0

Also you should use "precache_generic" for client-side sounds.

fysiks 01-17-2022 19:13

Re: sound message
 
Quote:

Originally Posted by OciXCrom (Post 2768664)
Code:
bool:is_user_access(id)     return !!(get_user_flags(id) & ADMINACCESS)

Should be:

Code:
bool:is_user_access(id)     return (get_user_flags(id) & ADMINACCESS) != 0

Why would you say that? Both result in the same return value. Using "!!" is valid. The only negative thing about it is that it might be more confusing to people who don't understand what exactly the "!!" does.

Yusochan 01-18-2022 08:08

Re: sound message
 
Quote:

Originally Posted by OciXCrom (Post 2768664)
Code:
bool:is_user_access(id)     return !!(get_user_flags(id) & ADMINACCESS)

Should be:

Code:
bool:is_user_access(id)     return (get_user_flags(id) & ADMINACCESS) != 0

Also you should use "precache_generic" for client-side sounds.

Alright, thanks !

Buy can you tell me why ?

fysiks 01-18-2022 22:50

Re: sound message
 
Quote:

Originally Posted by Yusochan (Post 2768724)
Alright, thanks !

Buy can you tell me why ?

They do the same thing using two different methods.

OciXCrom 01-19-2022 07:23

Re: sound message
 
Quote:

Originally Posted by fysiks (Post 2768680)
Why would you say that? Both result in the same return value. Using "!!" is valid. The only negative thing about it is that it might be more confusing to people who don't understand what exactly the "!!" does.

I remember someone once told me "!!" is not correct but I forgot why it exactly that was.
I did some digging and turns out it's not a big deal.

https://i.imgur.com/V7z7L7q.png


All times are GMT -4. The time now is 14:54.

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