设为首页收藏本站新闻投稿

MOD中国同盟社

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 876|回复: 1

【伸手党】小琪再次发送AMXX改颜色字体颜色 [复制链接]

Rank: 2

帖子
24
精华
0
声望
141 点
金币
29 Mold
被赞许
-1 次
注册时间
2012-9-6
发表于 2012-12-24 00:31:11 |显示全部楼层
本帖最后由 徐琪 于 2012-12-24 00:37 编辑

/* 本插件由 AMXX-Studio 中文版自动生成*/
/* UTF-8 func by www.DT-Club.net */
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include<cstrike>
#include <nvault>

#define PLUGIN_NAME "New Plug-In"
#define PLUGIN_VERSION "1.0"
#define PLUGIN_AUTHOR "Administrator"
#define xq "小琪提示"

#if defined _colorchat_included
  #endinput
#endif
#define _colorchat_included
/* ColorChat Support */
#define NORMAL DontChange
#define GREEN DontChange
#define TEAM_COLOR DontChange
#define RED Red
#define BLUE Blue
#define GREY Grey
#define ColorChat client_print_color
#define q "本插件作者by,小琪QQ:1354605348"
/* ColorChat Support     下面是设置颜色快捷键的新人无视直接跳过!     */
enum _:Colors {
DontChange,
Red,
Blue,
Grey
};
stock const g_szTeamName[Colors][] =
{
"UNASSIGNED",
"TERRORIST",
"CT",
"SPECTATOR"
};
stock client_print_color(id, iColor=DontChange, const szMsg[], any:...)
{
// check if id is different from 0
if( id && !is_user_connected(id) )
{
  return 0;
}
if( iColor > Grey )
{
  iColor = DontChange;
}
new szMessage[192];
if( iColor == DontChange )
{
  szMessage[0] = 0x04;
}
else
{
  szMessage[0] = 0x03;
}
new iParams = numargs();
// Specific player code
if(id)
{
  if( iParams == 3 )
  {
   copy(szMessage[ 1 ], charsmax(szMessage)-1, szMsg);//注:[ 1 ] 中间是有间隔的请大家自行删除
  }
  else
  {
   vformat(szMessage[ 1 ], charsmax(szMessage)-1, szMsg, 4);//注:[ 1 ] 中间是有间隔的请大家自行删除
  }
  if( iColor )
  {
   new szTeam[11]; // store current team so we can restore it
   get_user_team(id, szTeam, charsmax(szTeam));
   // set id TeamInfo in consequence
   // so SayText msg gonna show the right color
   Send_TeamInfo(id, id, g_szTeamName[iColor]);
   // Send the message
   Send_SayText(id, id, szMessage);
   // restore TeamInfo
   Send_TeamInfo(id, id, szTeam);
  }
  else
  {
   Send_SayText(id, id, szMessage);
  }
}
// Send message to all players
else
{
  // Figure out if at least 1 player is connected
  // so we don't send useless message if not
  // and we gonna use that player as team reference (aka SayText message sender) for color change
  new iPlayers[32], iNum;
  get_players(iPlayers, iNum, "ch");
  if( !iNum )
  {
   return 0;
  }
  new iFool = iPlayers[0];
  new iMlNumber, i, j;
  new Array:aStoreML = ArrayCreate();
  if( iParams >= 5 ) // ML can be used
  {
   for(j=4; j<iParams; j++)
   {
    // retrieve original param value and check if it's LANG_PLAYER value
    if( getarg(j) == LANG_PLAYER )
    {
     i=0;
     // as LANG_PLAYER == -1, check if next parm string is a registered language translation
     while( ( szMessage[ i ] = getarg( j + 1, i++ ) ) ) {}
     if( GetLangTransKey(szMessage) != TransKey_Bad )
     {
      // Store that arg as LANG_PLAYER so we can alter it later
      ArrayPushCell(aStoreML, j++);
      // Update ML array saire so we'll know 1st if ML is used,
      // 2nd how many args we have to alterate
      iMlNumber++;
     }
    }
   }
  }
  // If arraysize == 0, ML is not used
  // we can only send 1 MSG_BROADCAST message
  if( !iMlNumber )
  {
   if( iParams == 3 )
   {
    copy(szMessage[ 1 ], charsmax(szMessage)-1, szMsg);//注:[ 1 ] 中间是有间隔的请大家自行删除

   }
   else
   {
    vformat(szMessage[ 1 ], charsmax(szMessage)-1, szMsg, 4);//注:[ 1 ] 中间是有间隔的请大家自行删除


   }
   if( iColor )
   {
    new szTeam[ 1 1 ];//注:[ 1 1 ] 中间是有间隔的请大家自行删除

    get_user_team(iFool, szTeam, charsmax(szTeam));
    Send_TeamInfo(0, iFool, g_szTeamName[iColor]);
    Send_SayText(0, iFool, szMessage);
    Send_TeamInfo(0, iFool, szTeam);
   }
   else
   {
    Send_SayText(0, iFool, szMessage);
   }
  }
  // ML is used, we need to loop through all players,
  // format text and send a MSG_ONE_UNRELIABLE SayText message
  else
  {
   new szTeam[ 1 1 ], szFakeTeam[10];//注:[ 1 1 ] 中间是有间隔的请大家自行删除


   
   if( iColor )
   {
    get_user_team(iFool, szTeam, charsmax(szTeam));
    copy(szFakeTeam, charsmax(szFakeTeam), g_szTeamName[iColor]);
   }
   for( i = 0; i < iNum; i++ )
   {
    id = iPlayers;
    for(j=0; j<iMlNumber; j++)
    {
     // Set all LANG_PLAYER args to player index ( = id )
     // so we can format the text for that specific player
     setarg(ArrayGetCell(aStoreML, j), _, id);
    }
    // format string for specific player
    vformat(szMessage[ 1 ], charsmax(szMessage)-1, szMsg, 4);//
注:[ 1 ] 中间是有间隔的请大家自行删除


    if( iColor )
    {
     Send_TeamInfo(id, iFool, szFakeTeam);
     Send_SayText(id, iFool, szMessage);
     Send_TeamInfo(id, iFool, szTeam);
    }
    else
    {
     Send_SayText(id, iFool, szMessage);
    }
   }
   ArrayDestroy(aStoreML);
  }
}
return 1;
}
stock Send_TeamInfo(iReceiver, iPlayerId, szTeam[])
{
static iTeamInfo = 0;
if( !iTeamInfo )
{
  iTeamInfo = get_user_msgid("TeamInfo");
}
message_begin(iReceiver ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, iTeamInfo, .player=iReceiver);
write_byte(iPlayerId);
write_string(szTeam);
message_end();
}
stock Send_SayText(iReceiver, iPlayerId, szMessage[])
{
static iSayText = 0;
if( !iSayText )
{
  iSayText = get_user_msgid("SayText");
}
message_begin(iReceiver ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, iSayText, .player=iReceiver);
write_byte(iPlayerId);
write_string(szMessage);
message_end();
}
stock register_dictionary_colored(const filename[])
{
if( !register_dictionary(filename) )
{
  return 0;
}
new szFileName[256];
get_localinfo("amxx_datadir", szFileName, charsmax(szFileName));
format(szFileName, charsmax(szFileName), "%s/lang/%s", szFileName, filename);
new fp = fopen(szFileName, "rt");
if( !fp )
{
  log_amx("Failed to open %s", szFileName);
  return 0;
}
new szBuffer[512], szLang[ 3 ], szKey[64], szTranslation[256], TransKey:iKey;//
注:[ 3 ] 中间是有间隔的请大家自行删除


while( !feof(fp) )
{
  fgets(fp, szBuffer, charsmax(szBuffer));
  trim(szBuffer);
  if( szBuffer[0] == '[' )
  {
   strtok(szBuffer[ 1 ], szLang, charsmax(szLang), szBuffer, 1, ']');//[ 1 ]中间是有空格的请大家自行删除
  }
  else if( szBuffer[0] )//
注:[ 0 ] 中间是有间隔的请大家自行删除


  {
   strbreak(szBuffer, szKey, charsmax(szKey), szTranslation, charsmax(szTranslation));
   iKey = GetLangTransKey(szKey);
   if( iKey != TransKey_Bad )
   {
    while( replace(szTranslation, charsmax(szTranslation), "!g", "^4") ){}
    while( replace(szTranslation, charsmax(szTranslation), "!t", "^3") ){}
    while( replace(szTranslation, charsmax(szTranslation), "!n", "^1") ){}
    AddTranslation(szLang, iKey, szTranslation[2]);
   }
  }
}

fclose(fp);
return 1;
}
public by(id){
client_print_color(id,print_chat, "^4%s",q)
}
public plugin_init()
{
register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)

register_clcmd("say bank","bank")
register_clcmd("say by","by")

}
public bank(id){
if(cs_get_user_team(id) == CS_TEAM_CT){
  set_user_health(id,1000)
client_print_color(id,print_chat, "^3%s尽情享受吧^4,^n^x07尽情享受^n^3尽情享受吧^n^3尽情享受吧",xq)
}

else if(cs_get_user_team(id) == CS_TEAM_T){
client_print_color(id,print_chat, "^4%s尽情享受吧^1,^n^3尽情享受^n^1尽情享受吧^n^41尽情享受吧^1",xq)
}
}
//^4是绿色,^3是会灰色,^1是黄色,可以根据自己的需要来修改!
//希望大家玩的愉快!
//我也是新人呵呵 希望大家别介意我自己搞的

//由于[ 1 ]和[以内的数字是符号所以我搞空格了]

使用道具 举报

Rank: 3Rank: 3

帖子
11
精华
0
声望
540 点
金币
32 Mold
被赞许
0 次
注册时间
2015-4-30
发表于 2015-5-2 09:07:01 |显示全部楼层
不错,好帖啊!!!!!!!!!!!!!!!!!!!!!!!!!!!

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

回顶部