Ghostchat (amx plugin)

Od HLDS.pl
Wersja Trawiator (dyskusja | edycje) z dnia 14:14, 20 cze 2008
(różn.) ← poprzednia wersja | zobacz aktualną wersję (różn.) | następna wersja → (różn.)
Skocz do: nawigacji, wyszukiwania
/*
 ,------------------------------------------------------------
 | Ghostchat for AMX
 |-------------------------------------------------
 | Author: NetRipper
 | #Choke @ (irc.)Quakenet(.org)
 | ghostchat@netripper.tmfweb.nl
 |
 | Description: Plugin to let dead people read what alive people say
 | or to let dead and alive people chat with eachother.
 | You can also make only HLTV read chat of the living.
 | Plugin can be disabled from any console by an admin.
 |
 | Commands: amx_ghostchat 0 // Plugin disabled
 | amx_ghostchat 1 // Dead can read living
 | amx_ghostchat 2 // Dead and living read eachother
 | amx_ghostchat 3 // Only HLTV can read the living
 |
 | Access: Everyone can use amx_ghostchat to retrieve status
 | Admin Level B needed to _change_ ghostchat status
 | Server console access (won't give response but does work)
 |
 | Thanks to: PsychoGuard for his idea of dead reading alive.
 | [WHO]Them for making the ghostchat plugin for AM.
 |
 | Changes: Monday 2nd June 2003, v0.4:
 | - Fixed server crash (!!)
 | - Changed default to mode 3 (HLTV only)
 | - Changed log file to AMX's log files (amx/logs/admin%m%d.log)
 | Wednesday 20th April 2003, v0.3:
 | - Removed a little bug where lines starting with the
 | '[' character were ignored by the plugin.
 | - Added a [G] tag before *ALIVE* or *DEAD* so people
 | know it's the result of a plugin (some get confused).
 | - Added a reponse to any line with [G] in it, so when
 | people ask what [G] means, they get an automated
 | response asking to use amx_ghostchat for status.
 | Tuesday 29th April 2003:
 | - Everyone can use the amx_ghostchat to get status
 | - A 3rd mode has been added, 'HLTV can read living'
 | Sunday 27th April 2003, v0.2:
 | - Fixed displaying empty messages or msg's with [
 | - Changed client_print() with a real message, so
 | color gets added depending on team.
 | - Fixed bug where HLTV or clients console gets
 | f*cked due to a missing newline.
 | Saturday 26th April 2003, v0.1:
 | - First release
 `-------------------
 */
 #include <amxmod>
 #include <amxmisc>
 // Ghostchat disabled by default
 new ghostchat = 3; // Set to let HLTV see alive chat by default.
 new gmsgSayText;
 new logfilename[256];
 // Return current setting or set new value
 public handle_ghostchat(id,level,cid) {
	 // No switches given
	 if (read_argc() < 2) {
	 new statusa[56];
	 if (ghostchat == 1) {
		 copy(statusa, 55, "Dead can read alive");
	 }
	 else if (ghostchat == 2) {
		 copy(statusa, 55, "Dead and alive can read eachother");
	 }
	 else if (ghostchat == 3) {
		 copy(statusa, 55, "HLTV can read chat of the living");
	 }
	 else {
		 copy(statusa, 55, "Disabled");
	 }
	 client_print(id,print_console,"[AMX] Ghostchat status: %s (NOT TEAMSAY)", statusa);
	 if (cmd_access(id,ADMIN_LEVEL_B,cid,0))
	 client_print(id,print_console,"[AMX] Ghostchat usage: amx_ghostchat 0(disabled), 1(Dead can read alive), 2(Dead and alive can chat), 3(Only HLTV can read alive)");
	 return PLUGIN_HANDLED;
	 }
	 // If you don't have enough rights, you can't change anything
	 if (!cmd_access(id,ADMIN_LEVEL_B,cid,0))
	 return PLUGIN_HANDLED;
 
	 new arg[3];
	 read_argv(1,arg,2);
	 if (equal(arg,"0",1)) {
		 ghostchat = 0;
		 client_print(0,print_chat,"[AMX] Ghostchat - Plugin has been disabled");
	 }
	 else if (equal(arg,"1",1)) {
		 ghostchat = 1;
		 client_print(0,print_chat,"[AMX] Ghostchat - Dead people can read the chat of the living (NOT TEAMSAY)!");
	 }
	 else if (equal(arg,"2",1)) {
		 ghostchat = 2;
		 client_print(0,print_chat,"[AMX] Ghostchat - Dead and living people can talk to eachother (NOT TEAMSAY)!");
	 }
	 else if (equal(arg,"3",1)) {
		 ghostchat = 3;
		 client_print(0,print_chat,"[AMX] Ghostchat - HLTV can read chat of the living (NOT TEAMSAY)!");
	 }
	 new authid[16],name[32];
	 get_user_authid(id,authid,15);
	 get_user_name(id,name,31);
	 log_to_file(logfilename,"Ghostchat: ^"%s<%d><%s><>^" amx_ghostchat %s",name,get_user_userid(id),authid,arg);
	 return PLUGIN_HANDLED;
	 }
 public handle_say(id) {
   // If plugin is disabled, skip the code
   if (ghostchat <= 0) return PLUGIN_CONTINUE;
   // Gather information
   new is_alive = is_user_alive(id);
   new message[128];
   read_argv(1,message,127);
   new name[33];
   get_user_name(id,name,31);
   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
   if (containi(message,"[G]") != -1) 
    client_print(id,print_chat,"[AMX] Ghostchat - Type amx_ghostchat in console for current status");
 
   // 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[G]*[ZYWY]*%s : %s^n", 2, name, message);
   else format(message, 127, "%c[G]*DEAD*%s : %s^n", 2, name, message);
   // Check all players wether they should receive the message or not
   for (new i = 0; i < player_count; i++) {
     if (is_alive && !is_user_alive(players[i])) {
       // Talking person alive, current receiver dead
       if ((ghostchat == 3 && is_user_hltv(players[i])) || ghostchat <= 2) {
         // Either HLTV mode is enabled and current player is HLTV
         // or one of the other modes is enabled...
         message_begin(MSG_ONE,gmsgSayText,{0,0,0},players[i]);
         write_byte(id);
         write_string(message);
         message_end();
         }
       }
     else if (!is_alive && is_user_alive(players[i]) && ghostchat == 2) {
       // Talking person is dead, current receiver alive
       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");
   get_time("addons/amx/logs/admin%m%d.log",logfilename,255)
   return PLUGIN_CONTINUE;
 }
Osobiste
Przestrzenie nazw
Warianty
Działania
HLDS.pl - Menu:
Inne
IRC
Inne sekcje:
Znajomi:
Narzędzia