// Copyright © 2016 Vaqtincha
//############################ CONFIG START ############################//
/**========================= commentable =========================**/
#define DESCRIPTIVE_FITH // +colored text "Fire in the hole!"
// #define REAL_RADIO // like "Real Radio" plugin
/**========================= commentable =========================**/
/**=========================== editable ==========================**/
#define TEXT_FITH "(RADIO): Fire in the hole!" // radio text
#define TEXT_SMOKE "^4[smokegren]"
#define TEXT_FLASH "^3[flashbang]"
#define TEXT_HEGREN "^3[explosive]"
//**********
#define MAX_SOUND_PATH_LENGTH 32
#define MAX_SOUNDS 4 // 4 + 4 + 4 = 12
// default audio file format: WAVE(PCM), 8-bit, 22.05 KHz, Mono
// converted: WAVE(PCM), 16-bit, 24.0 KHz, Mono
new const g_szSmokeSounds[MAX_SOUNDS][MAX_SOUND_PATH_LENGTH] = {
"radio/custom/smoke01.wav", // length 24
"radio/custom/smoke02.wav", // length 24
"radio/custom/smoke03.wav", // length 24
"radio/custom/smoke04.wav" // length 24
}
new const g_szFlashSounds[MAX_SOUNDS][MAX_SOUND_PATH_LENGTH] = {
"radio/custom/flashbang01.wav", // length 28
"radio/custom/flashbang02.wav", // length 28
"radio/custom/flashbang03.wav", // length 28
"radio/custom/flashbang04.wav" // length 28
}
new const g_szHegrenSounds[MAX_SOUNDS][MAX_SOUND_PATH_LENGTH] = {
"radio/custom/grenade01.wav", // length 26
"radio/custom/grenade02.wav", // length 26
"radio/custom/grenade03.wav", // length 26
"radio/custom/grenade04.wav" // length 26
}
/**=========================== editable ==========================**/
//############################# CONFIG END #############################//
#define VERSION "0.0.4"
#include <amxmodx>
#if defined DESCRIPTIVE_FITH && AMXX_VERSION_NUM < 183
#include <colorchat>
#endif
#define MSGARG_SENDER_ID 2
#define MSGARG_SENDER_NAME 4
#define MSGARG_PRINT_RADIO 5
#define MSGARG_AUDIO_CODE 2
new g_MsgIdSendAudio
#if defined DESCRIPTIVE_FITH
new g_TextMsgBlock
#endif
public plugin_precache()
{
for(new i=0; i< MAX_SOUNDS; i++)
{
precache_sound(g_szSmokeSounds[i])
precache_sound(g_szFlashSounds[i])
precache_sound(g_szHegrenSounds[i])
}
}
public plugin_init()
{
register_plugin("Custom FITH Sounds & Text", VERSION, "Vaqtincha")
#if defined DESCRIPTIVE_FITH
g_TextMsgBlock = register_cvar("cfst_block_textmsg", "0")
#endif
g_MsgIdSendAudio = get_user_msgid("SendAudio")
register_message(g_MsgIdSendAudio, "Message_SendAudio") // block def FITH sound (method 1)
register_message(get_user_msgid("TextMsg"), "Message_TextMsg")
}
public Message_TextMsg(iMsgId, iMsgType, iMsgEnt)
{
if(get_msg_arg_int(1) != MSGARG_PRINT_RADIO)
return PLUGIN_CONTINUE
static szMsg[32]
get_msg_arg_string(MSGARG_PRINT_RADIO, szMsg, charsmax(szMsg))
if(equal(szMsg, "#Fire_in_the_hole"))
{
static Sender[4], SenderName[32], szSound[MAX_SOUND_PATH_LENGTH], SenderId
get_msg_arg_string(MSGARG_SENDER_ID, Sender, charsmax(Sender))
get_msg_arg_string(MSGARG_SENDER_NAME, SenderName, charsmax(SenderName))
SenderId = str_to_num(Sender)
switch(get_user_weapon(SenderId))
{
case CSW_HEGRENADE:{
szSound = g_szHegrenSounds[random(sizeof(g_szHegrenSounds))]
#if defined DESCRIPTIVE_FITH
if(get_pcvar_num(g_TextMsgBlock) == 0)
{
client_print_color(iMsgEnt, print_team_red, "%s %s %s^1", SenderName, TEXT_FITH, TEXT_HEGREN)
}
#endif
}
case CSW_SMOKEGRENADE:{
szSound = g_szSmokeSounds[random(sizeof(g_szSmokeSounds))]
#if defined DESCRIPTIVE_FITH
if(get_pcvar_num(g_TextMsgBlock) == 0)
{
client_print_color(iMsgEnt, print_team_default, "%s %s %s^1", SenderName, TEXT_FITH, TEXT_SMOKE)
}
#endif
}
case CSW_FLASHBANG:{
szSound = g_szFlashSounds[random(sizeof(g_szFlashSounds))]
#if defined DESCRIPTIVE_FITH
if(get_pcvar_num(g_TextMsgBlock) == 0)
{
client_print_color(iMsgEnt, print_team_grey, "%s %s %s^1", SenderName, TEXT_FITH, TEXT_FLASH)
}
#endif
}
default: return PLUGIN_CONTINUE
}
#if defined REAL_RADIO
emit_sound(SenderId, CHAN_VOICE, szSound, VOL_NORM, ATTN_STATIC, 0, PITCH_NORM)
#else
SendAudio(iMsgEnt, szSound)
#endif
// BlockAudio(iMsgEnt) // block def FITH sound (method 2)
#if defined DESCRIPTIVE_FITH
return PLUGIN_HANDLED // block def FITH text
#endif
}
return PLUGIN_CONTINUE
}
public Message_SendAudio(iMsgId, iMsgType, iMsgEnt)
{
static szSound[22]
get_msg_arg_string(MSGARG_AUDIO_CODE, szSound, charsmax(szSound))
return equal(szSound, "%!MRAD_FIREINHOLE") ? PLUGIN_HANDLED : PLUGIN_CONTINUE
}
stock SendAudio(id, const szSound[])
{
message_begin(MSG_ONE, g_MsgIdSendAudio, .player=id)
write_byte(id)
write_string(szSound)
write_short(PITCH_NORM)
message_end()
}
// by VEN
stock BlockAudio(id)
{
message_begin(MSG_ONE, g_MsgIdSendAudio, .player=id)
write_byte(0)
write_string("%!MRAD_FIREINHOLE")
write_short(32767)
message_end()
}