AMX MOD X
Воскресенье, 14.06.2026, 07:09:09



Приветствую Вас Гость | RSS
[ Главная ] [ Сolored messages ( Хочу добавить серый цвет ) - AMX Mod X Форум ] [ Регистрация ] [ Вход ]
[ Новые сообщения · Участники · Правила форума · Поиск · RSS ]

Вниманию участников! Данный форум теперь является архивом и вскором времени здесь нельзя будет создавать новых тем! Просьба всем для общения и создания новых тем перейти на наш новый форум: http://amxmodx.su/

  • Страница 1 из 1
  • 1
Модератор форума: slogic, AlMod  
Сolored messages ( Хочу добавить серый цвет )
ahaДата: Вторник, 28.10.2008, 18:10:54 | Сообщение # 1
Генерал-майор
Группа: Пользователи
Сообщений: 370
Репутация: 6
Статус: Не в сети
Имею плугин :

Code
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Say rank"
#define VERSION "1.0"
#define AUTHOR "aha"

public plugin_init()
{
       register_plugin(PLUGIN,VERSION,AUTHOR)
    
  register_dictionary("sayrank.txt")

       register_clcmd("say /rank", "text")
       register_clcmd("say rank", "text")     
       register_clcmd("say /top15", "text")
       register_clcmd("say top15", "text")
       register_clcmd("say /rankstats", "text")
       register_clcmd("say /stats", "text")
       register_clcmd("say /statsme", "text")
}

public text(id)  
{
        new msg[128]
   format(msg, 127, "%L", id, "STATISTIKA")
   client_color(id,msg)
}

public client_color(id,msg[]){
   new playerslist[32],playerscount//,i
   get_players(playerslist,playerscount,"c")
   while(replace(msg,127,"!W","^x01")){}
                 while(replace(msg,127,"0x02","^x02")){}
                 while(replace(msg,127,"!T","^x03")){}
                 while(replace(msg,127,"!G","^x04")){}
   if(id==0){
    message_begin(MSG_ALL, get_user_msgid("SayText"), {0,0,0},id)  
    write_byte(id)
    write_string(msg)
    message_end()
      
   }
   else{
    message_begin(MSG_ONE, get_user_msgid("SayText"), {0,0,0}, id)  
    write_byte(id)
    write_string(msg)
    message_end()
   }
}

sayrank.txt :

Code
[en]
STATISTIKA = !TWebStats !Won !Ghttp://xxx.xx

Имею цвета в сообщении : Зеленый , желтый , синий , красный .

!T - Цвет тима
!W - Желтый (оригинал)
!G - Зеленый

Как мне добавить еще букву !S с серым цветом ?

 
draftДата: Среда, 29.10.2008, 01:12:53 | Сообщение # 2
Полковник
Группа: Пользователи
Сообщений: 225
Репутация: 3
Статус: Не в сети
Серый цвет - это цвет команды спектаторов, который можно получить из x03, отправив перед мессагой "сообщение" мессагу get_user_msgid("TeamInfo"), в которой укажешь CS_TEAM_SPECTATOR в качестве байта.
 
ahaДата: Среда, 29.10.2008, 14:43:44 | Сообщение # 3
Генерал-майор
Группа: Пользователи
Сообщений: 370
Репутация: 6
Статус: Не в сети
Во че получилось :

Code
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Say rank"
#define VERSION "1.0"
#define AUTHOR "aha"

#define MAXSLOTS 32

new MaxSlots;
new TeamInfo;
new SayText;

new bool:IsConnected[MAXSLOTS + 1];

new TeamName[][] =  
{
  "",
  "TERRORIST",
  "CT",
  "SPECTATOR"
}

enum Color
{
  YELLOW = 1, // Yellow
  GREEN, // Green Color
  TEAM_COLOR, // Red, grey, blue
  GREY, // grey
  RED, // Red
  BLUE, // Blue
}

public plugin_init()
{
       register_plugin(PLUGIN,VERSION,AUTHOR)
    
  register_dictionary("sayrank.txt")

       register_clcmd("say /rank", "text")
       register_clcmd("say rank", "text")     
       register_clcmd("say /top15", "text")
       register_clcmd("say top15", "text")
       register_clcmd("say /rankstats", "text")
       register_clcmd("say /stats", "text")
       register_clcmd("say /statsme", "text")

       register_clcmd("say /rank2", "text2")
        
        TeamInfo = get_user_msgid("TeamInfo");
   SayText = get_user_msgid("SayText");
  MaxSlots = get_maxplayers();
}

public text(id)  
{
        new msg[128]
   format(msg, 127, "%L", id, "STATISTIKA")
   client_color(id,msg)
}

public client_color(id,msg[]){
   new playerslist[32],playerscount//,i
   get_players(playerslist,playerscount,"c")
   while(replace(msg,127,"!W","^x01")){}
                 while(replace(msg,127,"0x02","^x02")){}
                 while(replace(msg,127,"!T","^x03")){}
                 while(replace(msg,127,"!G","^x04")){}
   if(id==0){
    message_begin(MSG_ALL, get_user_msgid("SayText"), {0,0,0},id)  
    write_byte(id)
    write_string(msg)
    message_end()
      
   }
   else{
    message_begin(MSG_ONE, get_user_msgid("SayText"), {0,0,0}, id)  
    write_byte(id)
    write_string(msg)
    message_end()
   }
}

public text2(id)  
{
  ColorChat(id, GREY, "Web Stats on http://xxx.xx ");
  return PLUGIN_HANDLED;
}

public ColorChat(id, Color:type, const msg[], {Float,Sql,Result,_}:...)
{
  static message[256];

  switch(type)
  {
   case YELLOW: // Yellow
   {
    message[0] = 0x01;
   }
   case GREEN: // Green
   {
    message[0] = 0x04;
   }
   default: // White, Red, Blue
   {
    message[0] = 0x03;
   }
  }

  vformat(message[1], 251, msg, 4);

  // Make sure message is not longer than 192 character. Will crash the server.
  message[192] = '^0';

  new team, ColorChange, index, MSG_Type;
   
  if(!id)
  {
   index = FindPlayer();
   MSG_Type = MSG_ALL;
   
  } else {
   MSG_Type = MSG_ONE;
   index = id;
  }
   
  team = get_user_team(index);  
  ColorChange = ColorSelection(index, MSG_Type, type);

  ShowColorMessage(index, MSG_Type, message);
    
  if(ColorChange)
  {
   Team_Info(index, MSG_Type, TeamName[team]);
  }
}

FindPlayer()
{
  new i = -1;

  while(i <= MaxSlots)
  {
   if(IsConnected[++i])
   {
    return i;
   }
  }

  return -1;
}

ColorSelection(index, type, Color:Type)
{
  switch(Type)
  {
   case RED:
   {
    return Team_Info(index, type, TeamName[1]);
   }
   case BLUE:
   {
    return Team_Info(index, type, TeamName[2]);
   }
   case GREY:
   {
    return Team_Info(index, type, TeamName[0]);
   }
  }

  return 0;
}

ShowColorMessage(id, type, message[])
{
  message_begin(type, SayText, _, id);
  write_byte(id)   
  write_string(message);
  message_end();  
}

Team_Info(id, type, team[])
{
  message_begin(type, TeamInfo, _, id);
  write_byte(id);
  write_string(team);
  message_end();

  return 1;
}

При написании /rank2 бедет писать серым цветом , но как мне добавить lang систему как и в

Code
public text(id)  
{
        new msg[128]
   format(msg, 127, "%L", id, "STATISTIKA")
   client_color(id,msg)
}

Да и еще чтобы !S был серым ?
 
draftДата: Четверг, 30.10.2008, 04:16:26 | Сообщение # 4
Полковник
Группа: Пользователи
Сообщений: 225
Репутация: 3
Статус: Не в сети
format(msg, 127, "%L", id, "STATISTIKA")
замени на
formatex(msg, 127, "%L", LANG_PLAYER, "STATISTIKA")

Либо на LANG_SERVER, если хочешь язык сервера, а не клиента.
По поводу formatex - её лучше всегда для оптимизации использовать вместо format, если только ты не используешь в функции одинаковую входную и выходную переменную, например, есть
stroka = "blabla"
ты хочешь добавить к ней ещё одно bla, тогда formatex использовать нельзя:
format(stroka, 15, "%sbla", stroka)

 
  • Страница 1 из 1
  • 1
Поиск:

AMX Mod X Russian Community © 2006-2026