Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

!suggestion Garnade. #959

Open
Escap3d opened this issue Apr 10, 2024 · 1 comment
Open

!suggestion Garnade. #959

Escap3d opened this issue Apr 10, 2024 · 1 comment

Comments

@Escap3d
Copy link

Escap3d commented Apr 10, 2024

Is it possible that when we throw any grenade, the name of the player along with the name of the grenade is also shown? Like I mentioned here, it also shows in CS2 which grenade was thrown with the player's name.

Escape* : Fire in the hole! HE
Escape* : Fire in the hole! Flash
Escape* : Fire in the hole! Smoke

@StevenKal
Copy link
Contributor

StevenKal commented Apr 17, 2024

A plugin exists, named "Descriptive 'Fire in the hole!'" (in case you not aware of).

Descriptive 'Fire in the hole!'
/* AMX Mod
*   Descriptive 'Fire in the hole!'
*
* (c) Copyright 2006 by VEN
*
* This file is provided as is (no warranties)
*
*     DESCRIPTION
*       Plugin provides additional colored text for "Fire in the hole!" radio chat message.
*       The color and the text is different for each grenade type and can be altered.
*       This will help teammates to get the throwed grenade type and act accordingly.
*       Search for "EDITABLE" mark in the plugin's source code to configure text and color.
*
*     CREDITS
*       Damaged Soul - colored chat text method
*       p3tsin - team color override method
*
*     CHANGELOG
*       0.1 Initial release.
*       0.2 Added support for Condition Zero location radio messages (this will keep the team color of the sender, then the grenade type will be in green color).
*
*/

#include <amxmod>

new const PLUGIN_NAME[]    = "Descriptive 'Fire in the hole!'"
new const PLUGIN_VERSION[] = "0.2"
new const PLUGIN_AUTHOR[]  = "VEN"

enum grenade {
  GRENADE_HE,
  GRENADE_FLASH,
  GRENADE_SMOKE
}

// EDITABLE: grenade description
new const g_grenade_description[_:grenade][] = {
  " [explosive]",
  " [flashbang]",
  " [smokegren]"
}

enum color {
  COLOR_NORMAL,
  COLOR_RED,
  COLOR_BLUE,
  COLOR_GRAY,
  COLOR_GREEN
}

// EDITABLE: grenade description text color
new const g_grenade_desccolor[_:grenade] = {
  COLOR_RED,
  COLOR_GRAY,
  COLOR_GREEN
}

new const g_grenade_weaponid[_:grenade] = {
  CSW_HEGRENADE,
  CSW_FLASHBANG,
  CSW_SMOKEGRENADE
}

#define COLORCODE_NORMAL   0x01
#define COLORCODE_TEAM     0x03
#define COLORCODE_LOCATION 0x04

new const g_color_code[_:color] = {
  COLORCODE_NORMAL,
  COLORCODE_TEAM,
  COLORCODE_TEAM,
  COLORCODE_TEAM,
  COLORCODE_LOCATION
}

new const g_color_teamname[_:color][] = {
  "",
  "TERRORIST",
  "CT",
  "SPECTATOR",
  ""
}

#define RADIOTEXT_MSGARG_NUMBER 5
enum {
  RADIOTEXT_MSGARG_PRINTDEST = 1,
  RADIOTEXT_MSGARG_CALLERID,
  RADIOTEXT_MSGARG_TEXTTYPE,
  RADIOTEXT_MSGARG_CALLERNAME,
  RADIOTEXT_MSGARG_RADIOTYPE,
}

new const g_required_radiomsg[]           = "#Game_radio"
new const g_required_radiotype[]          = "#Fire_in_the_hole"
new const g_radiotext_template[]          = "%s (RADIO): Fire in the hole!"
//new const g_radiotext_template_location[] = "%s @ ^4%s^1 (RADIO): Fire in the hole!"
new const g_radiotext_template_location[] = "^3%s^1 @ ^4%s^1 (RADIO): Fire in the hole!" // Can't display team color around player with grenade color!

new gmsgSayText
new gmsgTeamInfo

public plugin_init() {
  register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)

  register_message(get_user_msgid("TextMsg"), "message_text")

  gmsgSayText  = get_user_msgid("SayText")
  gmsgTeamInfo = get_user_msgid("TeamInfo")
}

public message_text(msgid, dest, id) {
  static arg[32]
  get_msg_arg_string(RADIOTEXT_MSGARG_TEXTTYPE, arg, charsmax(arg))

  if(arg[0] != g_required_radiomsg[0] || !equal(arg, g_required_radiomsg, charsmax(g_required_radiomsg)))
    return PLUGIN_CONTINUE

  new bool:bIsRadioLocationMsg = arg[charsmax(g_required_radiomsg)] ? true : false

  get_msg_arg_string(RADIOTEXT_MSGARG_RADIOTYPE + _:bIsRadioLocationMsg, arg, charsmax(arg))

  if(!equal(arg, g_required_radiotype))
    return PLUGIN_CONTINUE

  get_msg_arg_string(RADIOTEXT_MSGARG_CALLERID, arg, charsmax(arg))

  new caller = str_to_num(arg)
  if(!is_user_alive(caller))
    return PLUGIN_CONTINUE

  new clip, ammo, weapon
  weapon = get_user_weapon(caller, clip, ammo)

  for(new i = 0; i < sizeof(g_grenade_weaponid); ++i) {
    if(g_grenade_weaponid[i] == weapon) {
      new pos, text[192]
      text[pos++] = g_color_code[COLOR_NORMAL]
      get_msg_arg_string(RADIOTEXT_MSGARG_CALLERNAME, arg, charsmax(arg))

      if(bIsRadioLocationMsg == false) {
        pos += formatex(text[pos], charsmax(text) - pos, g_radiotext_template, arg)
      }
      else {
        new szLocation[64]
        get_msg_arg_string(5, szLocation, charsmax(szLocation))
        pos += formatex(text[pos], charsmax(text) - pos, g_radiotext_template_location, arg, szLocation)
      }

      if(bIsRadioLocationMsg == false) {
        copy(text[++pos], charsmax(text) - pos, g_grenade_description[i])

        new desccolor = g_grenade_desccolor[i]
        if((text[--pos] = g_color_code[desccolor]) == COLORCODE_TEAM) {
          new teamname[12]
          get_user_team(id, teamname, charsmax(teamname))

          if(!equal(teamname, g_color_teamname[desccolor])) {
            msg_teaminfo(id, g_color_teamname[desccolor])
            msg_saytext(id, text)
            msg_teaminfo(id, teamname)
            return PLUGIN_HANDLED_MAIN
          }
        }
      }
      else {
        text[pos++] = COLORCODE_LOCATION
        copy(text[pos], charsmax(text) - pos, g_grenade_description[i])
      }

      msg_saytext(id, text)
      return PLUGIN_HANDLED_MAIN
    }
  }

  return PLUGIN_CONTINUE
}

msg_teaminfo(id, teamname[]) {
  message_begin(MSG_ONE, gmsgTeamInfo, _, id)
  write_byte(id)
  write_string(teamname)
  message_end()
}

msg_saytext(id, text[]) {
  message_begin(MSG_ONE, gmsgSayText, _, id)
  write_byte(id)
  write_string(text)
  message_end()
}
</details>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants