|
Member
|

07-22-2023
, 08:39
add ghost chat
|
#1
|
"ghost chat" plugin with the ability to dead can read alive's messages.
PHP Code:
#include <amxmodx>
#include <amxmisc>
new gmsgSayText;
// Return current setting or set new value
public handle_ghostchat(id,level,cid) {
// No switches given
if (read_argc() < 2) {
new status[55];
copy(status, 55, "Dead can read alive");
return PLUGIN_HANDLED;
}
return PLUGIN_HANDLED;
}
public handle_say(id) {
new is_alive = is_user_alive(id);
new message[129];
read_argv(1,message,128);
new name[33];
get_user_name(id,name,32);
new player_count = get_playersnum();
new players[32];
get_players(players, player_count, "c");
// Clients sometimes send empty messages, or a message containig a '[', ignore those.
if (equal(message,"")) return PLUGIN_CONTINUE;
if (equal(message,"[")) return PLUGIN_CONTINUE;
// Response to a specific query
// Format the messages, the %c (2) adds the color. The client decides what color
// it gets by looking at team.
if (is_alive) format(message, 127, "%c%s : %s^n", 2, name, message);
else format(message, 127, "%c*DEAD*%s : %s^n", 2, name, message);
for (new i = 0; i < player_count; i++) {
if (is_alive && !is_user_alive(players[i])) {
// Talking person alive, current receiver dead
message_begin(MSG_ONE,gmsgSayText,{0,0,0},players[i]);
write_byte(id);
write_string(message);
message_end();
}
}
return PLUGIN_CONTINUE;
}
public plugin_init() {
register_plugin("Ghostchat", "0.3", "NetRipper");
register_clcmd("say", "handle_say");
register_concmd("amx_ghostchat", "handle_ghostchat",-1,"<mode>");
gmsgSayText = get_user_msgid("SayText");
return PLUGIN_CONTINUE;
}
My random name chat plugin:
PHP Code:
#include <amxmodx>
#include <murdermod>
new const g_szOldChannels[][] =
{
"#Cstrike_Chat_CT",
"#Cstrike_Chat_T",
"#Cstrike_Chat_CT_Dead",
"#Cstrike_Chat_T_Dead",
"#Cstrike_Chat_Spec",
"#Cstrike_Chat_All",
"#Cstrike_Chat_AllDead",
"#Cstrike_Chat_AllSpec"
};
new const g_szNewChannels[][] =
{
"(Counter-Terrorist) ",
"(Terrorist) ",
"*DEAD*(Counter-Terrorist) ",
"*DEAD*(Terrorist) ",
"(Spectator) ",
"",
"*ÖLÜ* ",
"*SPEC* "
};
public plugin_init()
{
register_plugin("[MM] Chat messages", MM_VERSION, MM_AUTHOR);
register_message(get_user_msgid("SayText"), "Message_SayText");
register_clcmd("say_team", "hook_sayteam");
}
public Message_SayText(msgid, dest, id)
{
new sender = get_msg_arg_int(1);
if(!is_user_alive(sender) || mm_get_gamemode() != GAME_STARTED)
return PLUGIN_CONTINUE;
static channel[64];
get_msg_arg_string(2, channel, charsmax(channel));
new i;
for(i = 0; i < sizeof g_szOldChannels; i++)
if(equal(channel, g_szOldChannels[i]))
break;
static message[192];
get_msg_arg_string(4, message, charsmax(message));
remove_quotes(message);
client_print_color(id, print_team_default, "%s%s ^x01: %s", g_szNewChannels[i], get_name(sender), message);
return PLUGIN_HANDLED;
}
public hook_sayteam(id)
{
if(is_user_alive(id))
return PLUGIN_HANDLED;
return PLUGIN_CONTINUE;
}
I want to edit my plugin in a way that the dead can read the messages of the living, similar to ghost chat. The living will not see the messages of the dead, I only want the dead to see the message of the living as an extra.
I tried to do it, but the dead see the message of the living more than once. Like
John:Hi
John:Hi
PHP Code:
#include <amxmodx>
#include <murdermod>
#include <amxmisc>
new gmsgSayText;
new const g_szOldChannels[][] =
{
"#Cstrike_Chat_CT",
"#Cstrike_Chat_T",
"#Cstrike_Chat_CT_Dead",
"#Cstrike_Chat_T_Dead",
"#Cstrike_Chat_Spec",
"#Cstrike_Chat_All",
"#Cstrike_Chat_AllDead",
"#Cstrike_Chat_AllSpec"
};
new const g_szNewChannels[][] =
{
"(Counter-Terrorist) ",
"(Terrorist) ",
"*DEAD*(Counter-Terrorist) ",
"*DEAD*(Terrorist) ",
"(Spectator) ",
"",
"*ÖLÜ* ",
"*SPEC* "
};
public plugin_init()
{
gmsgSayText = get_user_msgid("SayText");
register_plugin("[MM] Chat messages", MM_VERSION, MM_AUTHOR);
register_message(get_user_msgid("SayText"), "Message_SayText");
register_clcmd("say_team", "hook_sayteam");
return PLUGIN_CONTINUE;
}
public Message_SayText(msgid, dest, id)
{
new sender = get_msg_arg_int(1);
if(!is_user_alive(sender) || mm_get_gamemode() != GAME_STARTED)
return PLUGIN_CONTINUE;
static channel[64];
get_msg_arg_string(2, channel, charsmax(channel));
new i;
for(i = 0; i < sizeof g_szOldChannels; i++)
if(equal(channel, g_szOldChannels[i]))
break;
static message[192];
get_msg_arg_string(4, message, charsmax(message));
remove_quotes(message);
client_print_color(id, print_team_default, "%s%s ^x01: %s", g_szNewChannels[i], get_name(sender), message);
new is_alive = is_user_alive(id);
new message1[192];
read_argv(1,message1,charsmax(message1));
/* new player_count = get_playersnum();
new players[32];
get_players(players, player_count, "ch"); */
if (equal(message1,"")) return PLUGIN_CONTINUE;
// if (equal(message1,"[")) return PLUGIN_CONTINUE;
//if (is_alive) format(message, 127, "%c%s : %s^n", 2, name, message);
if (is_alive) format(message1, 127, "%s%s : %s^n", g_szNewChannels[i], get_name(sender), message1);
else format(message1, 127, "*ÖLÜ*%s%s: %s^n", g_szNewChannels[i], get_name(sender), message1);
//for (new i = 0; i < player_count; i++) {
new num, it;
static players[32];
get_players(players, num);
for(--num; num >= 0; num--)
{
it = players[num];
if (is_alive && !is_user_alive(it)) {
message_begin(MSG_ONE,gmsgSayText,{0,0,0},it);
write_byte(id);
write_string(message1);
message_end();
break;
}
}
return PLUGIN_HANDLED;
}
public hook_sayteam(id)
{
if(is_user_alive(id))
return PLUGIN_HANDLED;
return PLUGIN_CONTINUE;
}
|
|