/* AMX Mod X
* Advanced Radio plugin based on Advanced Radio Commands by KaLoSZyFeR
*
* (c) Copyright 2007 by KaLoSZyFeR
*
* KaLoSZyFer published this code in the public domain.
* I (Jorl17) hereby license my modification under the
* GNU GPL - Protecting everyone's freedoms.
*
* =====================================================================
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.*
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* =====================================================================
*
* ORIGINAL (KaLoSZyFeR's) DESCRIPTION
* Plugin changes old and adds new customizable menu, allow hear custom radio
* commands, also included something like VEN's Real Radio.
*
* ORIGINAL (KaLoSZyFeR's) FEATURES
* - custom radio commands (sounds and messages)
* - custom menus
* - real radio effect
*
* =====================================================================
*
* DESCRIPTION
* This plugin enables the server admin to reconfigure the radio messages.
* It also adds a fourth menu which can by binded to a key (such as 'v').
* Unlike KaLoSZyFeR's plugin, no custom commands are supported,
* although the 'Fire in the hole!' can still be altered.
* Additionally, it puts all the customization in the hands of the server
* admininistrator.
*
* CVARS
* amx_custom_radio (0: OFF, 1: ON, default: 1) - disables/enables plugin
* amx_real_radio (0: OFF, 1: ON, default: 1) - disables/enables real radio effect
* amx_radio_info (0: OFF, 1: ON, default: 1) - disables/enables viewing info about
* plugin on start of server
*
* CUSTOMIZATION
* Since there are 4 radio groups, I shall name them 'A','B', 'C' and 'D'.
* There is a limit of 9 options for each group (there are only 9 positive integers
* before 10).
*
* Given the two previous statements, one can set the messages to use by following
* the rule (note that RC comes from Radio Command):
* RC<group><option> "message"
* For instance, if one wanted to define that the first group's message is 'Cover me!',
* this could be achieved by writting the following in custom_radio.amxx:
*
* RCA1 "Cover me!"
*
* Similarly, one can set the third's group fourth message to be "Roger that!":
*
* RCC4 "Roger that!"
*
* To specify a sound, the same logic is applied, but the syntax becomes:
*
* RC<group><option>Sound "file location in sound folder"
*
* Here's an example:
*
* RCD2 "Cover that!"
* RCD2Music "radio/custom/coverthat1.wav".
*
* Simply DO NOT FORGET to specify THE NUMBER OF COMMANDS which you have. This
* can be achieved with the following Variables:
* amx_radio_cmdsA
* amx_radio_cmdsB
* amx_radio_cmdsC
* amx_radio_cmdsD
*
* Each one of them sets the number of comands for each group.
*
* Most options found in the previous plugin (such as colors) can still be used
* with this plugin.
*
*
* =====================================================================
*
*
* MODIFICATIONS
*
* While editing this code, I (Jorl17) cleaned everything up
* and turned it into a more easy-to-ready code. I also matched it
* to my coding standards, simplifying and sometimes optimizing it.
*
*/
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <csx>
#include <fakemeta>
#define PLUGIN "Advanced Radio"
#define VERSION "1.0"
#define AUTHOR "Jorl17 & KaLoSZyFeR"
/* CONFIG SETUP */
#define MAX_OPTIONS 10 //The maximum number of options in a radio command
new Radio1Cmds;
new Radio2Cmds;
new Radio3Cmds;
new Radio4Cmds;
new Radio1Commands[MAX_OPTIONS][64];
new Radio2Commands[MAX_OPTIONS][64];
new Radio3Commands[MAX_OPTIONS][64];
new Radio4Commands[MAX_OPTIONS][64];
new g_RadioTimer[33];
new CRexit[64];
new CRcolortitle[2];
new CRcolormenu[2];
new CRfireinhole[64];
new Radio1Wavs[MAX_OPTIONS][64];
new Radio2Wavs[MAX_OPTIONS][64];
new Radio3Wavs[MAX_OPTIONS][64];
new Radio4Wavs[MAX_OPTIONS][64];
//General function to be used by all of them. Some kind of OOP <!-- s:D --><img src=\"{SMILIES_PATH}/icon_e_biggrin.gif\" alt=\":D\" title=\"nagyon boldog\" /><!-- s:D -->
public radio ( id, menustr[], counter, commandsArray[][] ) {
if ( !get_cvar_num ( "amx_custom_radio" ) ) //Check that we're ready to go.
return PLUGIN_CONTINUE;
if ( is_user_alive ( id ) == 0 ) return PLUGIN_HANDLED;
new key = ( 1 << 0 );
new menu_body[512];
//The Title
new len = format ( menu_body, 511, "\%s%s\%s^n\ ", CRcolortitle, menustr, CRcolormenu );
//Loop through the array and print the options
for ( new i ; i < counter ; i++ ) {
key |= ( 1 << i );
len += format ( menu_body[len], 511 - len, "%d. %s^n\ ", i + 1, commandsArray[i] );
}
len += format ( menu_body[len], 511 - len, "^n\ " ); //newline
len += format ( menu_body[len], 511 - len, "0. %s", CRexit ); //Exit.
key |= ( 1 << 9 );
show_menu ( id, key, menu_body ); // Show the above menu on screen
return PLUGIN_HANDLED;
}
public radiocmd ( id, key, commandsArray[][64], wavsArray[][] ) {
if ( !get_cvar_num ( "amx_custom_radio" ) ) //Check that we're ready to go.
return PLUGIN_CONTINUE;
if ( is_user_alive ( id ) == 0 ) return PLUGIN_HANDLED; //Dead people don't talk.
if ( g_RadioTimer[id] == 1 ) return PLUGIN_HANDLED; //Wait until you're finished, dawg!
new players[32], name[32], team_name[10], total;
get_user_team ( id, team_name, 9 );
get_players ( players, total , "ce", team_name ) // No bots and Match team name
get_user_name ( id, name, 31 );
if ( get_cvar_num ( "amx_real_radio" ) ) {
emit_sound ( id, CHAN_VOICE, wavsArray[key] , 0.9, ATTN_STATIC, 0, PITCH_NORM ) // Play sounds
}
for ( new a = 0, player = 0, message[64]; a < total; ++a ) {
player = players[a];
message = commandsArray[key];
client_cmd ( player, "spk ^"%s^"", wavsArray[key] );
client_print ( player, print_chat, "%s (RADIO): %s", name, message );
g_RadioTimer[id] = 1;
set_task ( 1.0, "radiotimer", id );
}
return PLUGIN_HANDLED;
}
public radio1 ( id ) { // Client used Radio1 commands
return radio ( id, "Radio Commands A", Radio1Cmds, Radio1Commands );
}
public radio1cmd ( id, key ) {
return radiocmd ( id, key, Radio1Commands, Radio1Wavs );
}
public radio2 ( id ) { // Client used Radio2 commands
return radio ( id, "Radio Commands B", Radio2Cmds, Radio2Commands );
}
public radio2cmd ( id, key ) {
return radiocmd ( id, key, Radio2Commands, Radio2Wavs );
}
public radio3 ( id ) { // Client used Radio3 commands
return radio ( id, "Radio Commands C", Radio3Cmds, Radio3Commands );
}
public radio3cmd ( id, key ) {
return radiocmd ( id, key, Radio3Commands, Radio3Wavs );
}
public radio4 ( id ) { // Client used Radio4 commands
return radio ( id, "Radio Commands D", Radio4Cmds, Radio4Commands );
}
public radio4cmd ( id, key ) {
return radiocmd ( id, key, Radio4Commands, Radio4Wavs );
}
public register_plugin_clcmds() {
register_clcmd ( "radio1", "radio1", 0, "- Calls radio menu 1" );
register_clcmd ( "radio2", "radio2", 0, "- Calls radio menu 2" );
register_clcmd ( "radio3", "radio3", 0, "- Calls radio menu 3" );
register_clcmd ( "radio4", "radio4", 0, "- Calls radio menu 4" );
}
public register_plugin_menucmds() {
register_menucmd ( register_menuid ( "Radio Commands A" ), 511, "radio1cmd" );
register_menucmd ( register_menuid ( "Radio Commands B" ), 511, "radio2cmd" );
register_menucmd ( register_menuid ( "Radio Commands C" ), 511, "radio3cmd" );
register_menucmd ( register_menuid ( "Radio Commands D" ), 511, "radio4cmd" );
}
public register_plugin_cvars() {
register_cvar ( "amx_custom_radio", "1" );
register_cvar ( "amx_real_radio", "1" );
register_cvar ( "amx_radio_info", "1" );
register_cvar ( "amx_radio_cmdsA", "1" );
register_cvar ( "amx_radio_cmdsB", "1" );
register_cvar ( "amx_radio_cmdsC", "1" );
register_cvar ( "amx_radio_cmdsD", "1" );
register_cvar ( "RCA1", "radio" );
register_cvar ( "RCA2", "radio" );
register_cvar ( "RCA3", "radio" );
register_cvar ( "RCA4", "radio" );
register_cvar ( "RCA5", "radio" );
register_cvar ( "RCA6", "radio" );
register_cvar ( "RCA7", "radio" );
register_cvar ( "RCA8", "radio" );
register_cvar ( "RCA9", "radio" );
register_cvar ( "RCB1", "radio" );
register_cvar ( "RCB2", "radio" );
register_cvar ( "RCB3", "radio" );
register_cvar ( "RCB4", "radio" );
register_cvar ( "RCB5", "radio" );
register_cvar ( "RCB6", "radio" );
register_cvar ( "RCB7", "radio" );
register_cvar ( "RCB8", "radio" );
register_cvar ( "RCB9", "radio" );
register_cvar ( "RCC1", "radio" );
register_cvar ( "RCC2", "radio" );
register_cvar ( "RCC3", "radio" );
register_cvar ( "RCC4", "radio" );
register_cvar ( "RCC5", "radio" );
register_cvar ( "RCC6", "radio" );
register_cvar ( "RCC7", "radio" );
register_cvar ( "RCC8", "radio" );
register_cvar ( "RCC9", "radio" );
register_cvar ( "RCD1", "radio" );
register_cvar ( "RCD2", "radio" );
register_cvar ( "RCD3", "radio" );
register_cvar ( "RCD4", "radio" );
register_cvar ( "RCD5", "radio" );
register_cvar ( "RCD6", "radio" );
register_cvar ( "RCD7", "radio" );
register_cvar ( "RCD8", "radio" );
register_cvar ( "RCD9", "radio" );
register_cvar ( "RCA1Audio", "radio/custom/null.wav" );
register_cvar ( "RCA2Audio", "radio/custom/null.wav" );
register_cvar ( "RCA3Audio", "radio/custom/null.wav" );
register_cvar ( "RCA4Audio", "radio/custom/null.wav" );
register_cvar ( "RCA5Audio", "radio/custom/null.wav" );
register_cvar ( "RCA6Audio", "radio/custom/null.wav" );
register_cvar ( "RCA7Audio", "radio/custom/null.wav" );
register_cvar ( "RCA8Audio", "radio/custom/null.wav" );
register_cvar ( "RCA9Audio", "radio/custom/null.wav" );
register_cvar ( "RCB1Audio", "radio/custom/null.wav" );
register_cvar ( "RCB2Audio", "radio/custom/null.wav" );
register_cvar ( "RCB3Audio", "radio/custom/null.wav" );
register_cvar ( "RCB4Audio", "radio/custom/null.wav" );
register_cvar ( "RCB5Audio", "radio/custom/null.wav" );
register_cvar ( "RCB6Audio", "radio/custom/null.wav" );
register_cvar ( "RCB7Audio", "radio/custom/null.wav" );
register_cvar ( "RCB8Audio", "radio/custom/null.wav" );
register_cvar ( "RCB9Audio", "radio/custom/null.wav" );
register_cvar ( "RCC1Audio", "radio/custom/null.wav" );
register_cvar ( "RCC2Audio", "radio/custom/null.wav" );
register_cvar ( "RCC3Audio", "radio/custom/null.wav" );
register_cvar ( "RCC4Audio", "radio/custom/null.wav" );
register_cvar ( "RCC5Audio", "radio/custom/null.wav" );
register_cvar ( "RCC6Audio", "radio/custom/null.wav" );
register_cvar ( "RCC7Audio", "radio/custom/null.wav" );
register_cvar ( "RCC8Audio", "radio/custom/null.wav" );
register_cvar ( "RCC9Audio", "radio/custom/null.wav" );
register_cvar ( "RCD1Audio", "radio/custom/null.wav" );
register_cvar ( "RCD2Audio", "radio/custom/null.wav" );
register_cvar ( "RCD3Audio", "radio/custom/null.wav" );
register_cvar ( "RCD4Audio", "radio/custom/null.wav" );
register_cvar ( "RCD5Audio", "radio/custom/null.wav" );
register_cvar ( "RCD6Audio", "radio/custom/null.wav" );
register_cvar ( "RCD7Audio", "radio/custom/null.wav" );
register_cvar ( "RCD8Audio", "radio/custom/null.wav" );
register_cvar ( "RCD9Audio", "radio/custom/null.wav" );
register_cvar ( "CRexit", "radio" );
register_cvar ( "CRcolortitle", "r" );
register_cvar ( "CRcolormenu", "w" );
register_cvar ( "CRfireinhole", "radio" );
}
public register_plugin_messages() {
register_message ( get_user_msgid ( "TextMsg" ), "message" );
register_message ( get_user_msgid ( "SendAudio" ), "msg_audio" );
}
public server_exec_plugin_cfg() {
new configsDir[64];
get_configsdir ( configsDir, 63 );
server_cmd ( "exec %s/custom_radio.cfg", configsDir );
server_exec();
}
public read_custom_radio_cfg() {
Radio1Cmds = get_cvar_num ( "amx_radio_cmdsA" );
Radio2Cmds = get_cvar_num ( "amx_radio_cmdsB" );
Radio3Cmds = get_cvar_num ( "amx_radio_cmdsC" );
Radio4Cmds = get_cvar_num ( "amx_radio_cmdsD" );
get_cvar_string ( "RCA1", Radio1Commands[0], 63 );
get_cvar_string ( "RCA2", Radio1Commands[1], 63 );
get_cvar_string ( "RCA3", Radio1Commands[2], 63 );
get_cvar_string ( "RCA4", Radio1Commands[3], 63 );
get_cvar_string ( "RCA5", Radio1Commands[4], 63 );
get_cvar_string ( "RCA6", Radio1Commands[5], 63 );
get_cvar_string ( "RCA7", Radio1Commands[6], 63 );
get_cvar_string ( "RCA8", Radio1Commands[7], 63 );
get_cvar_string ( "RCA9", Radio1Commands[8], 63 );
get_cvar_string ( "RCB1", Radio2Commands[0], 63 );
get_cvar_string ( "RCB2", Radio2Commands[1], 63 );
get_cvar_string ( "RCB3", Radio2Commands[2], 63 );
get_cvar_string ( "RCB4", Radio2Commands[3], 63 );
get_cvar_string ( "RCB5", Radio2Commands[4], 63 );
get_cvar_string ( "RCB6", Radio2Commands[5], 63 );
get_cvar_string ( "RCB7", Radio2Commands[6], 63 );
get_cvar_string ( "RCB8", Radio2Commands[7], 63 );
get_cvar_string ( "RCB9", Radio2Commands[8], 63 );
get_cvar_string ( "RCC1", Radio3Commands[0], 63 );
get_cvar_string ( "RCC2", Radio3Commands[1], 63 );
get_cvar_string ( "RCC3", Radio3Commands[2], 63 );
get_cvar_string ( "RCC4", Radio3Commands[3], 63 );
get_cvar_string ( "RCC5", Radio3Commands[4], 63 );
get_cvar_string ( "RCC6", Radio3Commands[5], 63 );
get_cvar_string ( "RCC7", Radio3Commands[6], 63 );
get_cvar_string ( "RCC8", Radio3Commands[7], 63 );
get_cvar_string ( "RCC9", Radio3Commands[8], 63 );
get_cvar_string ( "RCD1", Radio4Commands[0], 63 );
get_cvar_string ( "RCD2", Radio4Commands[1], 63 );
get_cvar_string ( "RCD3", Radio4Commands[2], 63 );
get_cvar_string ( "RCD4", Radio4Commands[3], 63 );
get_cvar_string ( "RCD5", Radio4Commands[4], 63 );
get_cvar_string ( "RCD6", Radio4Commands[5], 63 );
get_cvar_string ( "RCD7", Radio4Commands[6], 63 );
get_cvar_string ( "RCD8", Radio4Commands[7], 63 );
get_cvar_string ( "RCD9", Radio4Commands[8], 63 );
get_cvar_string ( "RCA1Audio", Radio1Wavs[0], 63 );
get_cvar_string ( "RCA2Audio", Radio1Wavs[1], 63 );
get_cvar_string ( "RCA3Audio", Radio1Wavs[2], 63 );
get_cvar_string ( "RCA4Audio", Radio1Wavs[3], 63 );
get_cvar_string ( "RCA5Audio", Radio1Wavs[4], 63 );
get_cvar_string ( "RCA6Audio", Radio1Wavs[5], 63 );
get_cvar_string ( "RCA7Audio", Radio1Wavs[6], 63 );
get_cvar_string ( "RCA8Audio", Radio1Wavs[7], 63 );
get_cvar_string ( "RCA9Audio", Radio1Wavs[8], 63 );
get_cvar_string ( "RCB1Audio", Radio2Wavs[0], 63 );
get_cvar_string ( "RCB2Audio", Radio2Wavs[1], 63 );
get_cvar_string ( "RCB3Audio", Radio2Wavs[2], 63 );
get_cvar_string ( "RCB4Audio", Radio2Wavs[3], 63 );
get_cvar_string ( "RCB5Audio", Radio2Wavs[4], 63 );
get_cvar_string ( "RCB6Audio", Radio2Wavs[5], 63 );
get_cvar_string ( "RCB7Audio", Radio2Wavs[6], 63 );
get_cvar_string ( "RCB8Audio", Radio2Wavs[7], 63 );
get_cvar_string ( "RCB9Audio", Radio2Wavs[8], 63 );
get_cvar_string ( "RCC1Audio", Radio3Wavs[0], 63 );
get_cvar_string ( "RCC2Audio", Radio3Wavs[1], 63 );
get_cvar_string ( "RCC3Audio", Radio3Wavs[2], 63 );
get_cvar_string ( "RCC4Audio", Radio3Wavs[3], 63 );
get_cvar_string ( "RCC5Audio", Radio3Wavs[4], 63 );
get_cvar_string ( "RCC6Audio", Radio3Wavs[5], 63 );
get_cvar_string ( "RCC7Audio", Radio3Wavs[6], 63 );
get_cvar_string ( "RCC8Audio", Radio3Wavs[7], 63 );
get_cvar_string ( "RCC9Audio", Radio3Wavs[8], 63 );
get_cvar_string ( "RCD1Audio", Radio4Wavs[0], 63 );
get_cvar_string ( "RCD2Audio", Radio4Wavs[1], 63 );
get_cvar_string ( "RCD3Audio", Radio4Wavs[2], 63 );
get_cvar_string ( "RCD4Audio", Radio4Wavs[3], 63 );
get_cvar_string ( "RCD5Audio", Radio4Wavs[4], 63 );
get_cvar_string ( "RCD6Audio", Radio4Wavs[5], 63 );
get_cvar_string ( "RCD7Audio", Radio4Wavs[6], 63 );
get_cvar_string ( "RCD8Audio", Radio4Wavs[7], 63 );
get_cvar_string ( "RCD9Audio", Radio4Wavs[8], 63 );
get_cvar_string ( "CRexit", CRexit, 63 );
get_cvar_string ( "CRcolortitle", CRcolortitle, 1 );
get_cvar_string ( "CRcolormenu", CRcolormenu, 1 );
//version 0.6
get_cvar_string ( "CRfireinhole", CRfireinhole, 63 );
}
/* Since we need to precache stuff we find,
everything must be started here. Well...not everything, but, for me,
it's easier if we just initialize everything here.
*/
public start_plugin() {
register_plugin_clcmds();
register_plugin_menucmds();
register_plugin_cvars();
register_plugin_messages();
server_exec_plugin_cfg();
read_custom_radio_cfg();
}
public plugin_precache() {
start_plugin();
for ( new i ; i < Radio1Cmds ; i++ ) {
precache_sound ( Radio1Wavs[i] );
}
for ( new i ; i < Radio2Cmds ; i++ ) {
precache_sound ( Radio2Wavs[i] );
}
for ( new i ; i < Radio3Cmds ; i++ ) {
precache_sound ( Radio3Wavs[i] );
}
for ( new i ; i < Radio4Cmds ; i++ ) {
precache_sound ( Radio4Wavs[i] );
}
precache_sound ( "radio/custom/null.wav" );
precache_sound ( "radio/custom/ct_fireinhole.wav" );
}
public plugin_init() {
register_plugin ( PLUGIN, VERSION, AUTHOR );
return PLUGIN_CONTINUE;
}
public plugin_cfg() {}
public message() {
if ( !get_cvar_num ( "amx_custom_radio" ) )
return PLUGIN_CONTINUE;
if ( get_msg_args() != 4 || get_msg_argtype ( 2 ) != ARG_STRING || get_msg_argtype ( 4 ) != ARG_STRING ) {
return PLUGIN_CONTINUE;
}
new arg2[16]
get_msg_arg_string ( 2, arg2, 15 )
if ( !equal ( arg2, "#Game_radio" ) ) {
return PLUGIN_CONTINUE;
}
new arg4[20]
get_msg_arg_string ( 4, arg4, 19 )
if ( equal ( arg4, "#Fire_in_the_hole" ) ) {
set_msg_arg_string ( 4, CRfireinhole )
return PLUGIN_CONTINUE;
}
return PLUGIN_CONTINUE;
}
public msg_audio() {
if ( !get_cvar_num ( "amx_custom_radio" ) )
return PLUGIN_CONTINUE;
if ( get_msg_args() != 3 || get_msg_argtype ( 2 ) != ARG_STRING ) {
return PLUGIN_CONTINUE;
}
new arg2[20];
get_msg_arg_string ( 2, arg2, 19 );
if ( equal ( arg2[1], "!MRAD_FIREINHOLE" ) ) {
return PLUGIN_HANDLED;
}
return PLUGIN_CONTINUE;
}
public grenade_throw ( id, ent, wid ) {
if ( !get_cvar_num ( "amx_custom_radio" ) )
return PLUGIN_CONTINUE;
new players[32], total, team_name[10];
get_user_team ( id, team_name, 9 );
get_players ( players, total , "ce", team_name ) // No bots and Match team name
new name[32];
get_user_name ( id, name, 31 );
for ( new a = 0; a < total; ++a ) {
client_cmd ( players[a], "spk radio/custom/ct_fireinhole.wav" );
if ( get_cvar_num ( "amx_real_radio" ) ) {
emit_sound ( id, CHAN_VOICE, "radio/custom/ct_fireinhole.wav" , 0.9, ATTN_STATIC, 0, PITCH_NORM );
}
}
return PLUGIN_HANDLED;
}
public radiotimer ( id ) {
g_RadioTimer[id] = 0;
return PLUGIN_HANDLED;
}
public client_connect ( id ) {
g_RadioTimer[id] = 0;
}
public client_disconnect ( id ) {
g_RadioTimer[id] = 0;
}
public client_putinserver ( id ) {
set_task ( 20.0, "dispInfo", id );
}
public dispInfo ( id ) {
if ( get_cvar_num ( "amx_radio_info" ) ) {
client_print ( id, print_chat, "Advanced Radio plugin is running on this server." );
client_print ( id,
print_chat,
"It is brought to you by: Joao Ricardo Lourenco (jorl17.8@gmail.com)." );
client_print ( id,
print_chat,
"Portions of this code were written by KaLoSZyFeR (kaloszyfer@o2.pl)." );
}
}