AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Changing color of death msg (https://forums.alliedmods.net/showthread.php?t=141392)

bibu 10-23-2010 15:21

Changing color of death msg
 
I would like to change the color of death msg for cs.

It's for example like that:

(red)bibi (weapon) (blue)Player

Can someone show me how to change the color of that without changing something in the teams? That it can look like:

(red)bibi (weapon) (red)Player (player is still ct)

or

(white)bibi (weapon) (white)Player

or reverse

(blue)bibi (weapon) (red)Player (player is still ct)

hleV 10-23-2010 16:06

Re: Changing color of death msg
 
When exactly do you want to change the message? Do you want to change colors of all death messages?

bibu 10-23-2010 17:07

Re: Changing color of death msg
 
Quote:

Originally Posted by hleV (Post 1332536)
When exactly do you want to change the message? Do you want to change colors of all death messages?

I would like to change all death messages, that i can customize it with the color, cvars like that for example:

amx_t_kill blue (default: red)
amx_ct_kill red (default: blue)

Should support those 3 colors: red, blue, gray

hleV 10-23-2010 18:38

Re: Changing color of death msg
 
  • amx_cdmc <1|0> - enabled/disabled;
  • amx_cdmc_t <1|2|3> - red/blue/gray;
  • amx_cdmc_ct <1|2|3>.
Code:
#include <amxmodx> new g_iTeam[33]; new g_iTeamInfo; new g_pColors[3]; public plugin_init() {         register_plugin("Custom Death Message Colors", "1.0", "hleV");         g_pColors[0] = register_cvar("amx_cdmc", "1");         g_pColors[1] = register_cvar("amx_cdmc_t", "3");         g_pColors[2] = register_cvar("amx_cdmc_ct", "1");         g_iTeamInfo = get_user_msgid("TeamInfo");         new const szDeathMsg[] = "DeathMsg";         register_message(get_user_msgid(szDeathMsg), "msgDeathMsg");         register_event(szDeathMsg, "eventDeathMsg", "a"); } public msgDeathMsg() {         if (!get_pcvar_num(g_pColors[0]))                 return;         new const iKiller = get_msg_arg_int(1);         new const iVictim = get_msg_arg_int(2);         if (iKiller && iKiller != iVictim)                 fnSetTeamInfo(iKiller, get_pcvar_num(g_pColors[(g_iTeam[iKiller] = get_user_team(iKiller))]));         fnSetTeamInfo(iVictim, get_pcvar_num(g_pColors[(g_iTeam[iVictim] = get_user_team(iVictim))])); } public eventDeathMsg() {         if (!get_pcvar_num(g_pColors[0]))                 return;         new const iKiller = read_data(1);         new const iVictim = read_data(2);         if (iKiller && iKiller != iVictim)                 fnSetTeamInfo(iKiller, g_iTeam[iKiller]);         fnSetTeamInfo(iVictim, g_iTeam[iVictim]); } fnSetTeamInfo(iClient, const iTeam) {         static const s_szTeams[][] =         {                 "",                 "TERRORIST",                 "CT",                 "SPECTATOR"         };         message_begin(MSG_ALL, g_iTeamInfo, _, iClient);         write_byte(iClient);         write_string(s_szTeams[iTeam]);         message_end(); }

fysiks 10-23-2010 18:39

Re: Changing color of death msg
 
Quote:

Originally Posted by bibu (Post 1332512)
without changing something in the teams?

Doubtful if possible at all (which I don't believe is possible).

Jacob 10-23-2010 19:18

Re: Changing color of death msg
 
Quote:

Originally Posted by fysiks (Post 1332631)
Doubtful if possible at all (which I don't believe is possible).

agree.

fysiks 10-23-2010 20:12

Re: Changing color of death msg
 
@hlev: I'm not sure that would work. Did you test it? Registering the death message, afaik, is effectively hooking it in post so the message was already sent. Can't modify it after it's been sent already.

Exolent[jNr] 10-23-2010 23:08

Re: Changing color of death msg
 
Quote:

Originally Posted by fysiks (Post 1332662)
@hlev: I'm not sure that would work. Did you test it? Registering the death message, afaik, is effectively hooking it in post so the message was already sent. Can't modify it after it's been sent already.

register_message() is pre hook.
register_event() is post hook.

fysiks 10-24-2010 00:02

Re: Changing color of death msg
 
Quote:

Originally Posted by Exolent[jNr] (Post 1332731)
register_message() is pre hook.
register_event() is post hook.

Oh. Nice to know. Also, didn't notice he had both in there.

hleV 10-24-2010 03:55

Re: Changing color of death msg
 
I tested it with only 1 player (myself), so only the victim's name was displayed in custom color.


All times are GMT -4. The time now is 10:16.

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