Правила форума Гаранты форума
Размещение рекламы AMX-X компилятор

Здравствуйте, гость Вход | Регистрация

Наши новости:

14-дек
24-апр
10-апр
11-апр

Добавление colorchat'а, удаление hud сообщения.

Статус пользователя АльТ
сообщение 17.9.2012, 17:26
Сообщение #1


Стаж: 14 лет

Сообщений: 407
Благодарностей: 102
Полезность: 500

Вот хочу в два плагина добавить colorchat, и убрать некоторые функции. Подскажите, если что-то неправильно сделаю.

Хочу просто добавить colorchat.
Instant AutoTeamBalance
Код

               /*      Copyright © 2008, ConnorMcLeod
                
                       Instant AutoTeamBalance is free software;
                       you can redistribute it and/or modify it under the terms of the
                       GNU General Public License as published by the Free Software Foundation.
                
                       This program is distributed in the hope that it will be useful,
                       but WITHOUT ANY WARRANTY; without even the implied warranty of
                       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                       GNU General Public License for more details.
                
                       You should have received a copy of the GNU General Public License
                       along with Instant AutoTeamBalance; if not, write to the
                       Free Software Foundation, Inc., 59 Temple Place - Suite 330,
                       Boston, MA 02111-1307, USA.
               */
                
               #include <amxmodx>
               #include <cstrike>
                
               #define PLUGIN "Instant AutoTeamBalance"
               #define AUTHOR "ConnorMcLeod"
               #define VERSION "1.2.0"
                
               #define BALANCE_IMMUNITY                ADMIN_RCON
                
               #define MAX_PLAYERS     32
                
               enum {
                       aTerro,
                       aCt
               }
                
               new bool:g_bImmuned[MAX_PLAYERS+1]
                
               new Float:g_fJoinedTeam[MAX_PLAYERS+1] = {-1.0, ...}
                
               new g_iMaxPlayers
               new g_pcvarEnable, g_pcvarImmune, g_pCvarMessage
                
               // true when connected and not a HLTV
               new bool:g_bValid[MAX_PLAYERS+1]
                
               public plugin_init()
               {
                       register_plugin(PLUGIN, VERSION, AUTHOR)
                
                       g_pcvarEnable = register_cvar("iatb_active", "1")
                       g_pcvarImmune = register_cvar("iatb_admins_immunity", "1")
                       g_pCvarMessage = register_cvar("iatb_message", "Teams Auto Balanced")
                
                       register_logevent("LogEvent_JoinTeam", 3, "1=joined team")
                
                       register_event("TextMsg", "Auto_Team_Balance_Next_Round", "a", "1=4", "2&#Auto_Team")
                
                       g_iMaxPlayers = get_maxplayers()
               }
                
               public LogEvent_JoinTeam()
               {
                       new loguser[80], name[32], id
                       read_logargv(0, loguser, 79)
                       parse_loguser(loguser, name, 31)
                       id = get_user_index(name)
                
                       g_fJoinedTeam[id] = get_gametime()
               }
                
               public client_authorized(id)
               {
                       g_bImmuned[id] = bool:(get_user_flags(id) & BALANCE_IMMUNITY)
               }
                
               public client_putinserver(id)
               {
                       g_bValid[id] = bool:!is_user_hltv(id)
               }
                
               public client_disconnect(id)
               {
                       g_bValid[id] = false
               }
                
               public Auto_Team_Balance_Next_Round()
               {
                       if(!get_pcvar_num(g_pcvarEnable))
                               return
                
                       if( balance_teams()  )
                       {
                               new szMessage[128]
                               get_pcvar_string(g_pCvarMessage, szMessage, charsmax(szMessage))
                               client_print(0, print_center, szMessage)
                       }
               }
                
               cs_set_user_team_custom(id, CsTeams:iTeam)
               {
                       switch(iTeam)
                       {
                               case CS_TEAM_T:
                               {
                                       if( cs_get_user_defuse(id) )
                                       {
                                               cs_set_user_defuse(id, 0)
                                               // set body to 0 ?
                                       }
                               }
                               case CS_TEAM_CT:
                               {
                                       if( user_has_weapon(id, CSW_C4) )
                                       {
                                               engclient_cmd(id, "drop", "weapon_c4")
                                       }
                               }
                       }
                
                       cs_set_user_team(id, iTeam)
                
                       return 1
               }
                
               balance_teams()
               {
                       new aTeams[2][MAX_PLAYERS], aNum[2], id
                
                       for(id = 1; id <= g_iMaxPlayers; id++)
                       {
                               if(!g_bValid[id])
                               {
                                       continue
                               }
                
                               switch( cs_get_user_team(id) )
                               {
                                       case CS_TEAM_T:
                                       {
                                               aTeams[aTerro][aNum[aTerro]++] = id
                                       }
                                       case CS_TEAM_CT:
                                       {
                                               aTeams[aCt][aNum[aCt]++] = id
                                       }
                                       default:
                                       {
                                               continue
                                       }
                               }
                       }
                
                       new iCheck
                       new iTimes = aNum[aCt] - aNum[aTerro]
                
                       if(iTimes > 0)
                       {
                               iCheck = aCt
                       }
                       else if(iTimes < 0)
                       {
                               iCheck = aTerro
                       }
                       else
                       {
                               return 0
                       }
                
                       iTimes = abs(iTimes/2)
                
                       new bool:bTransfered[MAX_PLAYERS+1],
                               bool:bAdminsImmune = bool:get_pcvar_num(g_pcvarImmune)
                
                       new iLast, iCount
                       while( iTimes > 0 )
                       {
                               iLast = 0
                               for(new i=0; i <aNum[iCheck]; i++)
                               {
                                       id = aTeams[iCheck][i]
                                       if( g_bImmuned[id] && bAdminsImmune )
                                       {
                                               continue
                                       }
                                       if(bTransfered[id])
                                       {
                                               continue
                                       }
                                       if(g_fJoinedTeam[id] > g_fJoinedTeam[iLast])
                                       {
                                               iLast = id
                                       }
                               }
                
                               if(!iLast)
                               {
                                       return 0
                               }
                
                               cs_set_user_team_custom(iLast, iCheck ? CS_TEAM_T : CS_TEAM_CT)
                
                               bTransfered[iLast] = true
                               iCount++
                               iTimes--
                       }
                       return 1
               }

Надо заменить
Код

                               new szMessage[128]
                               get_pcvar_string(g_pCvarMessage, szMessage, charsmax(szMessage))
                               client_print(0, print_center, szMessage)

на
Код

                   colorchat(id, NORMAL, "g_pCvarMessage")

Так? Кавычки нужны "g_pCvarMessage"?

И второй. Хочу убрать раскрашивание экрана в цвет команды, и худ переделать в colorchat.
TeamAlert
Код

               /*      Copyright © 2008, ConnorMcLeod
                
                       Team Alert is free software;
                       you can redistribute it and/or modify it under the terms of the
                       GNU General Public License as published by the Free Software Foundation.
                
                       This program is distributed in the hope that it will be useful,
                       but WITHOUT ANY WARRANTY; without even the implied warranty of
                       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                       GNU General Public License for more details.
                
                       You should have received a copy of the GNU General Public License
                       along with Team Alert; if not, write to the
                       Free Software Foundation, Inc., 59 Temple Place - Suite 330,
                       Boston, MA 02111-1307, USA.
               */
                
               #include <amxmodx>
               #include <cstrike>
                
               #define PLUGIN "Team Alert"
               #define AUTHOR "allenwr/ConnorMcLeod"
               #define VERSION "0.0.1"
                
               #define MAX_PLAYERS 32
                
               new CsTeams:g_iPlayerTeam[MAX_PLAYERS+1]
               new gmsgScreenFade
                
               public plugin_init()
               {
                       register_plugin( PLUGIN, VERSION, AUTHOR )
                       register_dictionary("teamalert.txt")
                
                       register_event("ResetHUD", "Event_ResetHUD", "be")
                       gmsgScreenFade = get_user_msgid("ScreenFade")
               }
                
               public client_putinserver(id)
               {
                       g_iPlayerTeam[id] = CS_TEAM_UNASSIGNED
               }
                
               public Event_ResetHUD(id)
               {
                       new CsTeams:iTeam = cs_get_user_team(id)
                       if( g_iPlayerTeam[id] != iTeam)
                       {
                               new r,b, MSG[6]
                               g_iPlayerTeam[id] = iTeam
                               switch( iTeam )
                               {
                                       case 1:
                                       {
                                               r = 175
                                               MSG = "TEAM1"
                                       }
                                       case 2:
                                       {
                                               b = 175
                                               MSG = "TEAM2"
                                       }
                                       default:return
                               }
                
                               set_hudmessage(r, 0, b, 0.42, 0.53, 2, 6.0, 4.0, 0.1, 0.2, -1)
                               show_hudmessage(id, "%L", id, MSG)
                
                               message_begin(MSG_ONE_UNRELIABLE, gmsgScreenFade, _, id)
                               write_short(1<<12)
                               write_short(1<<12)
                               write_short(0)
                               write_byte(r)
                               write_byte(0)
                               write_byte(b)
                               write_byte(100)
                               message_end()
                       }
               }

Как я понимаю это эффекты на экране.
Код

                             message_begin(MSG_ONE_UNRELIABLE, gmsgScreenFade, _, id)
                             write_short(1<<12)
                             write_short(1<<12)
                             write_short(0)
                             write_byte(r)
                             write_byte(0)
                             write_byte(b)
                             write_byte(100)
                             message_end()

А далее
Код

                               set_hudmessage(r, 0, b, 0.42, 0.53, 2, 6.0, 4.0, 0.1, 0.2, -1)
                               show_hudmessage(id, "%L", id, MSG)

Заменить на
Код

                   colorchat(id, NORMAL, "MSG")

Кавычки нужны :D?
И еще, что с этим делать?
Код
                new r,b, MSG[6]
                               g_iPlayerTeam[id] = iTeam
                               switch( iTeam )

Надобность в r и b отпадает, просто удалить их? Вообще что это, если их значение одинаковое? Может еще что убрать, если худ-сообщение и раскрашивание экрана больше не нужно.
Поправьте пожалуйста, если что не так. Надеюсь на вашу помощь :D
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   Цитировать сообщение
underwoker
сообщение 17.9.2012, 17:53
Сообщение #2
Стаж: 56 лет


Благодарностей:

В другой код сделай.
Перейти в начало страницы     
   + Цитировать сообщение
Статус пользователя АльТ
сообщение 17.9.2012, 18:55
Сообщение #3


Стаж: 14 лет

Сообщений: 407
Благодарностей: 102
Полезность: 500

underwoker,
Отсутствие колорчата в первом плагине я еще смогу пережить, но вот второй, меня hud и это изменение цвета экрана раздражают. Да и другим игрокам думаю это не понравится, лучше просто чат.

Отредактировал: АльТ, - 17.9.2012, 19:06
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
  Тема закрытаНачать новую тему
 
0 пользователей и 1 гостей читают эту тему: