Raised This Month: $ Target: $400
 0% 

sound message


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
abaskime
Junior Member
Join Date: Dec 2020
Old 01-14-2022 , 19:25   sound message
Reply With Quote #1

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?
abaskime is offline
Yusochan
Member
Join Date: Sep 2021
Location: Algeria
Old 01-16-2022 , 18:43   Re: sound message
Reply With Quote #2

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
__________________
<b>IP : <font color=Red>93.115.53.168:27017</font></b>
<b>Founder : <font color=Cyan>YusoChan-</font></b>

Last edited by Yusochan; 01-16-2022 at 18:58.
Yusochan is offline
abaskime
Junior Member
Join Date: Dec 2020
Old 01-17-2022 , 13:19   Re: sound message
Reply With Quote #3

Quote:
Originally Posted by Yusochan View Post
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);
abaskime is offline
Yusochan
Member
Join Date: Sep 2021
Location: Algeria
Old 01-17-2022 , 13:48   Re: sound message
Reply With Quote #4

Quote:
Originally Posted by abaskime View Post
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
__________________
<b>IP : <font color=Red>93.115.53.168:27017</font></b>
<b>Founder : <font color=Cyan>YusoChan-</font></b>

Last edited by Yusochan; 01-17-2022 at 13:48.
Yusochan is offline
abaskime
Junior Member
Join Date: Dec 2020
Old 01-17-2022 , 14:19   Re: sound message
Reply With Quote #5

thank you Bro
abaskime is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 01-17-2022 , 15:03   Re: sound message
Reply With Quote #6

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.
__________________

Last edited by OciXCrom; 01-17-2022 at 15:04.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-17-2022 , 19:13   Re: sound message
Reply With Quote #7

Quote:
Originally Posted by OciXCrom View Post
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.
__________________
fysiks is offline
Yusochan
Member
Join Date: Sep 2021
Location: Algeria
Old 01-18-2022 , 08:08   Re: sound message
Reply With Quote #8

Quote:
Originally Posted by OciXCrom View Post
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 ?
__________________
<b>IP : <font color=Red>93.115.53.168:27017</font></b>
<b>Founder : <font color=Cyan>YusoChan-</font></b>
Yusochan is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-18-2022 , 22:50   Re: sound message
Reply With Quote #9

Quote:
Originally Posted by Yusochan View Post
Alright, thanks !

Buy can you tell me why ?
They do the same thing using two different methods.
__________________
fysiks is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 01-19-2022 , 07:23   Re: sound message
Reply With Quote #10

Quote:
Originally Posted by fysiks View Post
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.

__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 00:57.


Powered by vBulletin®
Copyright ©2000 - 2022, vBulletin Solutions, Inc.
Theme made by Freecode