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

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

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

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

> Правила форума

Этот раздел, как вы могли заметить по названию, предназначен для решения вопросов по поводу уже существующих модов и плагинов.
Пожалуйста, если у вас проблема с написанием плагина, не путайте этот раздел с разделом по скриптингу.
Для поиска плагинов и модов существует соответствующий раздел.

Название темы должно соответствовать содержанию. Темы с названием типа "Помогите", "Вопрос", "парни подскажите..." - будут удалены.
Все темы, не относящиеся к "Вопросам по модам и плагинам", будут удалены или перемещены в соответствующий раздел.

Правила оформления темы:
1. Помимо заголовка не забудьте верно сформулировать свой вопрос.
2. Выложите исходник (в тег кода + ) или ссылку на плагин который вызывает у вас вопросы.
3. Выложите лог с ошибками (если имеется) под спойлер

цветные сообщения

Статус пользователя Archipelago
сообщение 15.1.2011, 16:01
Сообщение #1


Стаж: 16 лет

Сообщений: 520
Благодарностей: 67
Полезность: 21

Скажи пожалуйста каким образом можно перекрасить сообщения в чате.Интересуют все методы окрашивания чата в цвета (зеленый,синий,красный,серый)
про инклюд colorchat писать не надо.

Спасибо
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   Цитировать сообщение
Статус пользователя STR@TEG
сообщение 15.1.2011, 18:56
Сообщение #2
Стаж: 16 лет

Сообщений: 4186
Благодарностей: 1763
Полезность: 837

Цитата(spzm @ 15.1.2011, 17:01) *
про инклюд colorchat писать не надо.
Может сразу закрыть тему?
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя Archipelago
сообщение 15.1.2011, 19:10
Сообщение #3


Стаж: 16 лет

Сообщений: 520
Благодарностей: 67
Полезность: 21

зачем сразу закрывать...ведь есть много плагинов которые не используют этот инклюд...но всеже имеют цветные сообщения...на пример этот
сорр ,если вопрос нубский..
sma
Код
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "text in chat"
#define VERSION "1.0"
#define AUTHOR "patr1g / Pr4yer"


enum ChatColor
{
    CHATCOLOR_YELLOW = 1,     // ЖЁЛТЫЙ
    CHATCOLOR_GREEN,     // ЗЕЛЁНЫЙ
    CHATCOLOR_TEAM_COLOR,     // Цвет, в зависимости от команды. (T - красный, CT - синий, CPEC - серый)
    CHATCOLOR_GREY,     // СЕРЫЙ
    CHATCOLOR_RED,         // КРАСНЫЙ
    CHATCOLOR_BLUE,     // СИНИЙ
}

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

new g_msgSayText
new g_msgTeamInfo


public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    
    register_cvar("text_chat", "1")
    register_cvar("text_chat_interval", "25")
    
    register_cvar("text_chat_1", "***************************************************")
    register_cvar("text_chat_2", "бла бла бла")
    register_cvar("text_chat_3", "бла бла бла")
    register_cvar("text_chat_4", "бла бла бла")
    register_cvar("text_chat_5", "***************************************************")
    
    g_msgSayText = get_user_msgid("SayText")
    g_msgTeamInfo = get_user_msgid("TeamInfo")
}

public plugin_cfg()
{
  set_task(get_cvar_float("text_chat_interval"), "showMsg", 12345, "", _, "b")
}

public showMsg()
{
  if(get_cvar_num("text_chat") == 1)
  {
    static
            msg1[128],
            msg2[128],
            msg3[128],
            msg4[128],
            msg5[128]
    
    get_cvar_string("text_chat_1", msg1, 127)
    get_cvar_string("text_chat_2", msg2, 127)
    get_cvar_string("text_chat_3", msg3, 127)
    get_cvar_string("text_chat_4", msg4, 127)
    get_cvar_string("text_chat_5", msg5, 127)
    
    colorChat(0, CHATCOLOR_GREEN, "%s", msg1)
    colorChat(0, CHATCOLOR_RED, "%s", msg2)
    colorChat(0, CHATCOLOR_BLUE, "%s", msg3)
    colorChat(0, CHATCOLOR_GREY, "%s", msg4)
    colorChat(0, CHATCOLOR_GREEN, "%s", msg5)
  }
}

colorChat(id, ChatColor:color, const msg[], {Float,Sql,Result,_}:...)
{
    new team, index, MSG_Type
    new bool:teamChanged = false
    new message[192]
    
    switch(color)
    {
        case CHATCOLOR_YELLOW:
        {
            message[0] = 0x01;
        }
        case CHATCOLOR_GREEN:
        {
            message[0] = 0x04;
        }
        default:
        {
            message[0] = 0x03;
        }
    }
    
    vformat(message[1], 190, msg, 4);
    
    if (id == 0)
    {
        index = findAnyPlayer();
        MSG_Type = MSG_ALL;
    }
    else
    {
        index = id;
        MSG_Type = MSG_ONE;
    }
    if (index != 0)
    {
        team = get_user_team(index);    
        if (color == CHATCOLOR_RED && team != 1)
        {
            messageTeamInfo(index, MSG_Type, g_TeamName[1])
            teamChanged = true
        }
        else
        if (color == CHATCOLOR_BLUE && team != 2)
        {
            messageTeamInfo(index, MSG_Type, g_TeamName[2])
            teamChanged = true
        }
        else
        if (color == CHATCOLOR_GREY && team != 0)
        {
            messageTeamInfo(index, MSG_Type, g_TeamName[0])
            teamChanged = true
        }
        messageSayText(index, MSG_Type, message);
        if (teamChanged)
        {
            messageTeamInfo(index, MSG_Type, g_TeamName[team]);
        }
    }
}

messageSayText(id, type, message[])
{
    message_begin(type, g_msgSayText, _, id)
    write_byte(id)        
    write_string(message)
    message_end()
}
    
messageTeamInfo(id, type, team[])
{
    message_begin(type, g_msgTeamInfo, _, id)
    write_byte(id)
    write_string(team)
    message_end()
}
    
findAnyPlayer()
{
    new players[32], inum
    
    get_players(players, inum)
    
    for (new a = 0; a < inum; ++a)
    {
        if(is_user_connected(players[a]))
        {
            return players[a]
        }
    }
    return 0
}


Отредактировал: spzm, - 15.1.2011, 19:11
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя NickLesNick
сообщение 15.1.2011, 19:28
Сообщение #4


Стаж: 16 лет

Сообщений: 355
Благодарностей: 153
Полезность: 680

Без colorChat цветных сообщений не будет. А в этом исходнике colorChat уже содержится. Просто поменяли названия некоторых переменных и всё.
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя Archipelago
сообщение 15.1.2011, 19:40
Сообщение #5


Стаж: 16 лет

Сообщений: 520
Благодарностей: 67
Полезность: 21

Цитата(NickLesNick @ 15.1.2011, 19:28) *
Просто поменяли названия некоторых переменных и всё.

просто писта,для меня это так далеко...cbf1b2bfde1a.gif
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя Rejiser
сообщение 15.1.2011, 20:51
Сообщение #6


Стаж: 15 лет

Сообщений: 2261
Благодарностей: 1068
Полезность: 870

Цитата(spzm @ 15.1.2011, 20:40) *
просто писта,для меня это так далеко...cbf1b2bfde1a.gif

поэтому для тебя проще использовать инклуд колорчат, что он вам так не нравится?
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя Archipelago
сообщение 15.1.2011, 21:39
Сообщение #7


Стаж: 16 лет

Сообщений: 520
Благодарностей: 67
Полезность: 21

Цитата(Rejiser @ 15.1.2011, 20:51) *
поэтому для тебя проще использовать инклуд колорчат, что он вам так не нравится?

та всё устраивает вот только с мультиязычностью не дружу..да и в некоторых плагинах оно почему-то не работает..
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя STR@TEG
сообщение 16.1.2011, 1:22
Сообщение #8
Стаж: 16 лет

Сообщений: 4186
Благодарностей: 1763
Полезность: 837

spzm,
Поподробнее давай, поможем.
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
Поблагодарили 1 раз
   + Цитировать сообщение
Статус пользователя Archipelago
сообщение 16.1.2011, 1:56
Сообщение #9


Стаж: 16 лет

Сообщений: 520
Благодарностей: 67
Полезность: 21

тю лаг какой-то..не могу оформить...
Цитата(STR@TEG @ 16.1.2011, 1:22) *
spzm,
Поподробнее давай, поможем.

плагин ptb (для балансировки сил команд)


Код
        set_hudmessage(0, 255, 0, 0.05, 0.25, 0, 6.0, 5.0 , 0.5, 0.15, -1)
        ShowSyncHudMsg(0, g_MyMsgSync, "%s", text)
        client_print_color(id, Red, "[NewLine #4]: Перемещен %s к %s",winnerName, (winnerTeam == CTS) ? "ТЕРОВ" : "КОНТРОВ")
    }else{
        doTypesay(text, 5, 0, 255, 0)
        client_print_color(id, Red, "^x04[NewLine #4]: Перемещен %s к %s",winnerName, (winnerTeam == CTS) ? "ТЕРОВ" : "КОНТРОВ")

полный код
CODE
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <chatcolor>

// Uncomment for support immunity on VIP
//#define PTB_VIP_IMMUNITY

// Uncomment to activate log debug messages.
//#define PTB_DEBUG

// team ids
#define UNASSIGNED 0
#define TS 1
#define CTS 2
#define AUTO_TEAM 5

new const PTB_VERSION[] = "1.8b3"

// team selection control
new bool:PTB_LIMITJOIN = true // set limits on team joining
new PTB_LIMITAFTER = 0 // number of rounds after which teams limiting begins
new PTB_LIMITMIN = 0 // number of minimum players on map for team limiting
new PTB_MAXSIZE = 10 // maximum team size per team
new PTB_MAXDIFF = 2 // maximum team size difference
new PTB_AUTOROUNDS = 3 // number of first rounds into match, which allow autojoin only
new PTB_WTJAUTO = 3 // wtj tries needed to become autojoined
new PTB_WTJKICK = 5 // wtj tries needed to become kicked
new bool:PTB_KICK = true // kick for wtj counts
new bool:PTB_SAVEWTJ = false // save wtjs to wtj.log

// team balancing actions
new bool:PTB_SWITCH = true // switch/transfer players
new PTB_SWITCHAFTER = 0 // number of rounds after which switching begins
new PTB_SWITCHMIN = 3 // number of minimum players on map for switching
new PTB_SWITCHFREQ = 1 // relative next possible switch round
new PTB_PLAYERFREQ = 3 // relative next possible switch round for player
new PTB_FORCESWITCH = 3 // number of tries after which PTB switches alive, if neccessary
new bool:PTB_DEADONLY = false // switch dead only

// messages
new bool:PTB_TELLWTJ = true // tell about wtj tries
new bool:PTB_ANNOUNCE = true // announce team status at beginning of round
new bool:PTB_SAYOK = true // announce team status, if teams are alright
new bool:PTB_TYPESAY = true // use typesay

// team strength limits
new PTB_MAXSTREAK = 2 // max. allowed team win streak
new PTB_MAXSCORE = 2 // max. allowed team score difference
new Float:PTB_MINRATING = 1.5 // minimum critical team rating
new Float:PTB_MAXRATING = 2.0 // maximum critical team rating
new Float:PTB_SUPERRATING = 3.0 // super critical team rating
new PTB_MAXINCIDENTS = 50 // maximum kills + deaths before the score is divided by PTB_SCALEDOWN
new PTB_SCALEDOWN = 2 // divisor for kills and deaths, when PTB_MAXINCIDENTS is reached

// sorted player indices are 0-based
new sortedTeams[3][32]
new sortedValidTargets[3][32]
new validTargetCounts[3]

new teamKills[3]
new teamDeaths[3]
new teamScores[3]
new winStreaks[3]

new wtConditions[3]
new winnerTeam
new loserTeam

new Float:ctKD
new Float:tKD
new Float:ctStrength
new Float:tStrength
new Float:ctRating
new Float:tRating

// player arrays are 1-based, there is no player 0
new clientVGUIMenu[33][2]
new bool:isBeingTransfered[33]
new playerTeam[33]
new lastRoundSwitched[33]
new wtjCount[33]
new teamCounts[3]
new kills[33]
new deaths[33]

new roundCounter
new lastSwitchRound
new couldNotSwitchCounter

new lastTeamBalanceCheck[32]

//New auto-channeling system in amxmodx 1.70
new g_MyMsgSync

// pcvars
new saychat
new transfer_type
new switch_immunity
new limitjoin_immunity
new immunity_level
new access_level
new show_in_hlsw

public plugin_init(){
register_plugin("Team Balancer",PTB_VERSION,"Ptahhotep")
register_cvar("amx_ptb_version",PTB_VERSION,FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_UNLOGGED|FCVAR_SPONLY)

saychat = register_cvar("ptb_saychat", "1")
transfer_type = register_cvar("ptb_transfer_type", "1")
switch_immunity = register_cvar("ptb_switch_immunity", "1")
limitjoin_immunity = register_cvar("ptb_limitjoin_immunity", "1")
immunity_level = register_cvar("ptb_immunity_level", "o")
access_level = register_cvar("ptb_access_level", "l")
show_in_hlsw = register_cvar("ptb_show_in_hlsw", "1")

register_menucmd(register_menuid("Team_Select",1),(1<<0)|(1<<1)|(1<<4),"teamselect")
register_event("ShowMenu","menuclass","b","4&CT_Select","4&Terrorist_Select")
register_clcmd("jointeam","jointeam")
register_clcmd("team_join","team_join")
#if defined PTB_DEBUG
register_clcmd("say /last","check_lasttransfer")
#endif
register_event("SendAudio","round_end","a","2=%!MRAD_terwin","2=%!MRAD_ctwin","2=%!MRAD_rounddraw") // Round End
register_event("TeamScore","team_score","a") // Team Score
register_event("RoundTime", "new_round", "bc") // Round Time
register_event("DeathMsg","death_msg","a") // Kill
register_event("TeamInfo","team_assign","a") // Team Assigment (also UNASSIGNED and SPECTATOR)
register_event("TextMsg","team_join","a","1=1","2&Game_join_te","2&Game_join_ct") // Team Joining
register_event("TextMsg","game_restart","a","1=4","2&#Game_C","2&#Game_w") // Game restart
register_concmd("amx_ptb","admin_ptb",get_access_level_flag(),"- displays PTB options")

new configsDir[64]
get_configsdir(configsDir, 63)
server_cmd("exec %s/ptb.cfg", configsDir) // Execute main configuration file

//New auto-channeling system in amxmodx 1.70
g_MyMsgSync = CreateHudSyncObj()


// Init clients VGUI-menu setting
// Set terminating 0 to allow use of char processing instead of string
// to improve performance.
for (new i=0;i<33;i++){
clientVGUIMenu[i][0] = '0'
clientVGUIMenu[i][1] = 0
}

return PLUGIN_CONTINUE
}

public get_immunity_level_flag()
{
new flags[24]
get_pcvar_string(immunity_level, flags, 23)

return(read_flags(flags))
}

public get_access_level_flag()
{
new flags[24]
get_pcvar_string(access_level, flags, 23)

return(read_flags(flags))
}


Float:fdivWorkaround(Float:nom, Float:denom){
if ( denom == 0.0) return nom
return floatabs(nom / denom)
}

doTypesay(string[], duration, r, g, b) {
if (!PTB_TYPESAY) return
//last parameter is not needed
set_hudmessage(r, g, b, 0.05, 0.25, 0, 6.0, float(duration) , 0.5, 0.15, -1)
//use this instead of show_hudmessage
ShowSyncHudMsg(0, g_MyMsgSync, "%s", string)
}

say(string[]){
if(get_pcvar_num(saychat) == 1 || get_pcvar_num(saychat) == 3){
client_print(0,print_chat,string)
server_print(string)
}
}

bool:check_param_bool(param[])
return (equali(param, "on") || equal(param, "1")) ? true : false

Float:check_param_float(param[],Float:n){
new Float:a = floatstr(param)
if (a < n) a = n
return a
}

check_param_num(param[],n){
new a = str_to_num(param)
if (a < n) a = n
return a
}

transferPlayer(id){

if (!is_user_connected(id)) return
if (isBeingTransfered[id]) return
isBeingTransfered[id] = false

new name[32], player_steamid[50], team_pre_transfer[12]
get_user_name(id,name,31)
get_user_authid(id, player_steamid, 49)
get_user_team(id, team_pre_transfer, 11)

if(cs_get_user_defuse(id))
cs_set_user_defuse(id, 0);

cs_set_user_team(id, (playerTeam[id]==TS) ? 2 : 1)
cs_reset_user_model(id)

// This must be done here or lastroundswithed will not be registered
lastRoundSwitched[id] = roundCounter

// This logs to hlds logs so Psychostats knows that the player has changed team (PS 3.X)
//"LAntz69<9><STEAM_0:1:1895474><TERRORIST>" joined team "CT" //This is how it will be outputted in hlds logs
log_message("^"%s<%d><%s><%s>^" joined team ^"%s^"",
name, get_user_userid(id), player_steamid, team_pre_transfer, (playerTeam[id]==TS) ? "CT" : "TERRORIST" )

if(get_pcvar_num(show_in_hlsw) == 1)
{
// This makes you able to see transfers with HLSW in the chat
log_message("^"<><><>^" triggered ^"amx_chat^" (text ^"[PTB] %s перемещен за %s^")",
name, (playerTeam[id]==TS) ? "CT" : "TERRORIST" )
}

#if defined PTB_DEBUG
log_amx("Transfer player: %s lastRoundSwitched[id]: %i roundCounter:%i", name, lastRoundSwitched[id], roundCounter)
client_print(0,print_chat,"Игрок перемещен: %s lastRoundSwitched[id]: %i roundCounter:%i", name, lastRoundSwitched[id], roundCounter)
#endif
}

#if defined PTB_DEBUG
public check_lasttransfer(id) {
new lasttransfer, text[255]
lasttransfer = lastRoundSwitched[id]

format(text,255,"Последний раунд перемещения: %i", lasttransfer)
say(text)
}
#endif

actAtEndOfRound(){
if (!PTB_SWITCH) return
// skip switching for the first few rounds
if (roundCounter <= PTB_SWITCHAFTER) return
// honor switch frequency setting
if (roundCounter - lastSwitchRound < PTB_SWITCHFREQ) return
// skip switching for a small number of players
if (get_playersnum() < PTB_SWITCHMIN) return

say("[NewLine #4]: Раунд окончен, проверка команд.")
checkTeamBalance()
if (winnerTeam) {
sortTeam(CTS)
sortTeam(TS)

// If they set the cvar(ptb_transfer_type) 1 or less than 2 or bigger than 3
// then standard transfers will be selected
if(get_pcvar_num(transfer_type) < 2 || get_pcvar_num(transfer_type) > 3){

// This is the standard if it should be a swith of to players or just one transfer
if (teamCounts[winnerTeam] <= teamCounts[loserTeam]) // Original formula
doSwitch()
else if (teamCounts[loserTeam] < teamCounts[winnerTeam]) // Original formula
doTransfer()

}

if(get_pcvar_num(transfer_type) == 2){

// This is more agressive but not so much as the one below
if (teamCounts[winnerTeam] < teamCounts[loserTeam])
doSwitch()

else if (teamCounts[loserTeam] <= teamCounts[winnerTeam])
doTransfer()
}

if(get_pcvar_num(transfer_type) == 3){

// This is the most agressive transfertype
if ((teamCounts[winnerTeam]+(PTB_MAXDIFF/2)) < teamCounts[loserTeam])
doSwitch()

else if (teamCounts[loserTeam] <= (teamCounts[winnerTeam]+(PTB_MAXDIFF/2)))
doTransfer()
}

}
}

createValidTargets(theTeam, bool:deadonly) {
new n = 0
for (new i = 0; i < teamCounts[theTeam]; ++i) {


#if defined PTB_VIP_IMMUNITY
// If player is in the VIP team dont touch
if (cs_get_user_vip(sortedTeams[theTeam][i])) continue
#endif

// Protection for admins if ptb_switch_immunity 1
if (get_user_flags(sortedTeams[theTeam][i])&get_immunity_level_flag() && (get_pcvar_num(switch_immunity) == 1)) continue
// Dead only condition
if ( deadonly && is_user_alive(sortedTeams[theTeam][i]) ) continue
// Already switched or in PTB_PLAYERFREQ time condition
if ((lastRoundSwitched[sortedTeams[theTeam][i]] == roundCounter) ||
(roundCounter - lastRoundSwitched[sortedTeams[theTeam][i]] < PTB_PLAYERFREQ)) continue
sortedValidTargets[theTeam][n++] = sortedTeams[theTeam][i]
}
validTargetCounts[theTeam] = n
}

sortTeam(theTeam) {
// create list of players
new n = 0, a = get_maxplayers()
for (new i = 1; i <= a; ++i) {
// Get only members of specified team
if (playerTeam[i] != theTeam) continue
sortedTeams[theTeam][n++] = i
}
// do a selection sort
new swap, count = n
for (new i = count-1; i > 0; --i){
for (new k = i-1; k >= 0; --k){
// compare players (kills better then other or if equal then with less deaths)
if ( (kills[sortedTeams[theTeam][k]]<kills[sortedTeams[theTeam][i]])
|| ( (kills[sortedTeams[theTeam][k]]==kills[sortedTeams[theTeam][i]]) &&
(deaths[sortedTeams[theTeam][k]]>deaths[sortedTeams[theTeam][i]]))) {
// swap
swap = sortedTeams[theTeam][k]
sortedTeams[theTeam][k] = sortedTeams[theTeam][i]
sortedTeams[theTeam][i] = swap
}
}
}
}

Float:score(team, toBeAdded=0, toBeRemoved=0){
new Float:sumKD = 0.0
new a = get_maxplayers()
for (new i = 1; i <= a; ++i) {
if ( (playerTeam[i]!=team&&i!=toBeAdded) || (i==toBeRemoved) )
continue
sumKD += fdivWorkaround(float(kills[i]), float(deaths[i]))
}
new Float:strength = float(teamCounts[team])
if (sumKD) strength *= sumKD
return strength
}

doSwitch() {
new text[256]
//displayStatistics(0,true)
// don't switch, if at least one team is empty
if ( teamCounts[winnerTeam] == 0 || teamCounts[loserTeam] == 0 ) {
copy(text,255, "[NewLine #4]: Нельзя переместить игроков, нужны игроки в обеих командах.")
doTypesay(text, 5, 0, 255, 0)
say(text)
return
}
// don't switch, if winner is alone (RULER!!!)
if (teamCounts[winnerTeam] == 1) {
copy(text,255, "[NewLine #4]: Нет игроков для перемещения, команда из-за него выигрывает.")
doTypesay(text, 5, 0, 255, 0)
say(text)
return
}
// don't switch, if both teams are full
if (teamCounts[winnerTeam] >= PTB_MAXSIZE && teamCounts[loserTeam] >= PTB_MAXSIZE) {
copy(text,255, "[NewLine #4]: Нельзя сделать перемещение ,обе команды полны.")
doTypesay(text, 5, 0, 255, 0)
say(text)
return
}
if (!PTB_DEADONLY || couldNotSwitchCounter > PTB_FORCESWITCH) {
// choose from random top or bottom x
createValidTargets(winnerTeam, false)
createValidTargets(loserTeam, false)

if (validTargetCounts[winnerTeam] == 0 || validTargetCounts[loserTeam] == 0) {
++couldNotSwitchCounter
copy(text,255, "[NewLine #4]: Нельзя переместить игроков, нет игрока для замены.")
doTypesay(text, 5, 0, 255, 0)
say(text)
return
}
}
else {
//say("switch dead")
createValidTargets(winnerTeam, true)
createValidTargets(loserTeam, true)

if (validTargetCounts[winnerTeam] == 0 || validTargetCounts[loserTeam] == 0) {
if (++couldNotSwitchCounter > PTB_FORCESWITCH) {
say("[NewLine #4]: Не смог переместить мёртвого, перемещаю живого.")
doSwitch()
return
}
copy(text, 255,"[NewLine #4]: Нельзя переместить игроков, нет игрока для замены.")
doTypesay(text, 5, 0, 255, 0)
say(text)
return
}
}
// Now search through the possible 1 to 1 swaps to equalize the strength as much as possible
new Float:closestScore = floatabs(score(winnerTeam) - score(loserTeam))
new Float:myScore, toLoser, toWinner
new winner = 0
new loser = 0
for (new w = 0; w < validTargetCounts[winnerTeam]; ++w) {
toLoser = sortedValidTargets[winnerTeam][w]
for (new l = 0; l < validTargetCounts[loserTeam]; ++l) {
toWinner = sortedValidTargets[loserTeam][l]
myScore = floatabs(score(winnerTeam, toWinner, toLoser) - score(loserTeam, toLoser, toWinner))
if (myScore < closestScore) {
closestScore = myScore
winner = toLoser
loser = toWinner
}
}
}
if (winner == 0 && loser == 0) {
copy(text, 255,"[NewLine #4]: No switch would improve team balancing.")
doTypesay(text, 5, 0, 255, 0)
say(text)
return
}
couldNotSwitchCounter = 0
lastSwitchRound = roundCounter
new winnerName[32], loserName[32]
get_user_name(winner,winnerName,31)
get_user_name(loser,loserName,31)
// if one team is full, first move the the player from the full team ...
if (teamCounts[winnerTeam] >= PTB_MAXSIZE){
transferPlayer(winner)
transferPlayer(loser)
}
else {
transferPlayer(loser)
transferPlayer(winner)
}
format(text,255,"[NewLine #4]: Перемещение %s и %s.",winnerName,loserName)

if(get_pcvar_num(saychat) == 2 || get_pcvar_num(saychat) == 3){
//say(text)
//set_hudmessage(0, 255, 0, 0.05, 0.25, 0, 6.0, 5.0 , 0.5, 0.15, 1)
//show_hudmessage(0, text )
set_hudmessage(0, 255, 0, 0.05, 0.25, 0, 6.0, 5.0 , 0.5, 0.15, -1)
ShowSyncHudMsg(0, g_MyMsgSync, "%s", text)
client_print(0,print_chat,"[NewLine #4]: %s и %s поменялись командами.",winnerName,loserName)
}else{
doTypesay(text, 5, 0, 255, 0)
client_print(0,print_chat,"[NewLine #4]: %s и %s поменялись командами.",winnerName,loserName)
//say(text)
}
}

doTransfer() {
//displayStatistics(0,true)
new text[256]
if (teamCounts[winnerTeam] == 0) {
copy(text,255, "[NewLine #4]: Нельзя сделать замену ,нужны игроки в обеих командах.")
doTypesay(text, 5, 0, 255, 0)
say(text)
return
}
if (teamCounts[loserTeam] >= PTB_MAXSIZE) {
copy(text,255, "[NewLine #4]: Нельзя переместить игрока, проигрывающая команда полна.")
doTypesay(text, 5, 0, 255, 0)
say(text)
return
}
if (!PTB_DEADONLY || couldNotSwitchCounter > PTB_FORCESWITCH) {
createValidTargets(winnerTeam, false)
if (validTargetCounts[winnerTeam] == 0) {
copy(text,255, "[NewLine #4]: Нельзя переместить игрока, нет игрока для замены.")
doTypesay(text, 5, 0, 255, 0)
say(text)
++couldNotSwitchCounter
return
}
}
else {
//say("switch dead")
createValidTargets(winnerTeam, true)
if (validTargetCounts[winnerTeam] == 0) {
if (++couldNotSwitchCounter > PTB_FORCESWITCH) {
say("[NewLine #4]: Не смог перекинуть мёртвого, перекидываю живого.")
doTransfer()
return
}
copy(text,255, "[NewLine #4]: Нельзя переместить игрока, нет игрока для замены.")
doTypesay(text, 5, 0, 255, 0)
say(text)
return
}
}
new Float:closestScore = floatabs(score(winnerTeam) - score(loserTeam))
new Float:myScore, toLoser
new winner = 0
for (new w = 0; w < validTargetCounts[winnerTeam]; ++w) {
toLoser = sortedValidTargets[winnerTeam][w]
myScore = floatabs(score(winnerTeam, 0, toLoser) - score(loserTeam, toLoser, 0))
if (myScore < closestScore) {
closestScore = myScore
winner = toLoser
}
}
if (winner == 0) {
copy(text, 255,"[NewLine #4]: Никакая замена не улучшила бы балансирование команды.")
doTypesay(text, 5, 0, 255, 0)
say(text)
return
}
couldNotSwitchCounter = 0
new winnerName[32]
get_user_name(winner,winnerName,31)
transferPlayer(winner)
format(text,255,"[NewLine #4]: %s Перемещен к %s",winnerName, (winnerTeam == CTS) ? "ТЕРОВ" : "КОНТРОВ")

if(get_pcvar_num(saychat) == 2 || get_pcvar_num(saychat) == 3){
//say(text)
//set_hudmessage(0, 255, 0, 0.05, 0.25, 0, 6.0, 5.0 , 0.5, 0.15, 1)
//show_hudmessage(0, text )
set_hudmessage(0, 255, 0, 0.05, 0.25, 0, 6.0, 5.0 , 0.5, 0.15, -1)
ShowSyncHudMsg(0, g_MyMsgSync, "%s", text)
client_print_color(id, Red, "[NewLine #4]: Перемещен %s к %s",winnerName, (winnerTeam == CTS) ? "ТЕРОВ" : "КОНТРОВ")
}else{
doTypesay(text, 5, 0, 255, 0)
client_print_color(id, Red, "^x04[NewLine #4]: Перемещен %s к %s",winnerName, (winnerTeam == CTS) ? "Ts" : "CTs")
//say(text)
}
}

checkTeamBalance() {

get_time("%m/%d/%Y - %H:%M:%S",lastTeamBalanceCheck,31 )
calcTeamScores()
ctStrength = score(CTS)
tStrength = score(TS)
ctRating = fdivWorkaround(ctStrength, tStrength)
tRating = fdivWorkaround(tStrength, ctStrength)
wtConditions[TS] = 0
wtConditions[CTS] = 0

// compare scores for unequal rating scores
if (teamScores[TS] - teamScores[CTS] > PTB_MAXSCORE && tRating >= PTB_MINRATING)
wtConditions[TS]++

if (teamScores[CTS] - teamScores[TS] > PTB_MAXSCORE && ctRating >= PTB_MINRATING)
wtConditions[CTS]++

// check streaks for unequal rating scores
if (winStreaks[TS] > PTB_MAXSTREAK && tRating >= PTB_MINRATING)
wtConditions[TS]++

if (winStreaks[CTS] > PTB_MAXSTREAK && ctRating >= PTB_MINRATING)
wtConditions[CTS]++

// check ratings
if (tRating >= PTB_MAXRATING)
wtConditions[TS]++

if (ctRating >= PTB_MAXRATING)
wtConditions[CTS]++


// check ratings
if (tRating >= PTB_SUPERRATING)
wtConditions[TS]++

if (ctRating >= PTB_SUPERRATING)
wtConditions[CTS]++


// check team sizes for unequal ratings
if (teamCounts[TS] > teamCounts[CTS] && tRating >= PTB_MINRATING)
wtConditions[TS]++

if (teamCounts[CTS] > teamCounts[TS] && ctRating >= PTB_MINRATING)
wtConditions[CTS]++

// check conditions
if (wtConditions[TS] >= 2) {
winnerTeam = TS
loserTeam = CTS
}
else if (wtConditions[CTS] >= 2) {
winnerTeam = CTS
loserTeam = TS
}
else {
winnerTeam = 0
loserTeam = 0
}
}

manageWtjFile(id) {
if (!PTB_SAVEWTJ) return
//say("Trying to write wtj.log ....")
//if (wtjCount[id] < 4) return
//say("wtj.log should be written to now ....")
new text[256], mapname[32], name[32], authid[32]
get_mapname(mapname,31)
get_user_name(id,name,31)
get_user_authid(id,authid,31)
format(text, 255, "%s <%s> %s", name, authid, mapname)
log_to_file("wtj.log", text)
}


public menuclass(id) {
if (!isBeingTransfered[id]) return PLUGIN_CONTINUE
client_cmd(id,"slot1")
isBeingTransfered[id] = false
return PLUGIN_CONTINUE
}

public jointeam(id) {
new arg[2]
read_argv(1,arg,1)
if (isBeingTransfered[id]) return PLUGIN_HANDLED
return checkTeamSwitch(id,str_to_num(arg)) // team is key pressed + 1
}

public teamselect(id,key) {

return checkTeamSwitch(id,key+1) // team is key pressed + 1
}

checkTeamSwitch(id,iNewTeam) {

// don't care where player joins
if (!PTB_LIMITJOIN) return PLUGIN_CONTINUE
// Protection for admins if ptb_limitjoin_immunity 1
if (get_user_flags(id)&get_immunity_level_flag() && (get_pcvar_num(limitjoin_immunity) == 1)) return PLUGIN_CONTINUE
// players is transfered so don't care with rest
if (isBeingTransfered[id]) {
//say("TRANSFER")
isBeingTransfered[id] = false
return PLUGIN_CONTINUE
}
//say("NO TRANSFER")
// skip limiting for a few rounds into the map
if (PTB_LIMITAFTER && roundCounter <= PTB_LIMITAFTER) return PLUGIN_CONTINUE
// skip limiting for a small number of players
if (get_playersnum() < PTB_LIMITMIN) return PLUGIN_CONTINUE

new iOldTeam = playerTeam[id]

// disallow free team choices in the first rounds of a map
if (PTB_AUTOROUNDS && (iOldTeam==UNASSIGNED) && roundCounter<=PTB_AUTOROUNDS && !(get_user_flags(id) & ADMIN_KICK))
iNewTeam = AUTO_TEAM

// prevent unwanted rejoining of the same team ...
if (iNewTeam == iOldTeam) {
//say("Preventing rejoining of the same team.")
client_print(id,print_chat,"PTB: Нельзя! Переход в эту команду запрещен...")
#if !defined MANUAL_SWITCH
engclient_cmd(id,"chooseteam") // display menu again
#endif
return PLUGIN_HANDLED
}

checkTeamBalance()
//displayStatistics(0,true)

// Player for sure was in CT or T team and now is joining to the opposite team
if ((iNewTeam==CTS&&iOldTeam==TS)||(iNewTeam==TS&&iOldTeam==CTS)){
// If someone is in new team and old team weren't full
// and the winning team is a destination team or in
// new team is more players than in old then treat it as wtj
if ( teamCounts[iNewTeam]&&(teamCounts[iOldTeam]<PTB_MAXSIZE)&&
((iNewTeam==winnerTeam)||(teamCounts[iNewTeam]>=teamCounts[iOldTeam])) ) {
// player is wtjing
new text[256],name[32]
get_user_name(id,name,31)
// Kick wtj player if reached set limit
if (++wtjCount[id] >= PTB_WTJKICK && PTB_KICK) {
format(text, 255, "PTB: Kicking %s for a WTJ count %d of %d.", name, wtjCount[id],PTB_WTJKICK )
doTypesay(text, 5, 0, 255, 0)
say(text)
server_cmd("kick #%d",get_user_userid(id))
return PLUGIN_HANDLED
}
// Announce about WTJ
if (PTB_TELLWTJ) {
if (iNewTeam == CTS) {
format(text, 255, "[NewLine #4]: Контры - довольно сильная команда..., %s (WTJ: %d/%d).", name, wtjCount[id],PTB_WTJKICK)
doTypesay(text, 5, 0, 50, 255)
}
else {
format(text, 255, "[NewLine #4]: Теры - довольно сильная команда, %s (WTJ: %d/%d).", name, wtjCount[id],PTB_WTJKICK)
doTypesay(text, 5, 255, 50, 0)
}
say(text)
}
#if !defined MANUAL_SWITCH
engclient_cmd(id,"chooseteam") // display menu again
#endif
return PLUGIN_HANDLED
}
// check for maximum team size
if (teamCounts[iNewTeam] >= PTB_MAXSIZE) {
client_print(id,print_chat,"[NewLine #4]: Команда полна.Перемещение не возможно.")
#if !defined MANUAL_SWITCH
engclient_cmd(id,"chooseteam") // display menu again
#endif
return PLUGIN_HANDLED
}
// check team size difference limits
if ( teamCounts[iNewTeam]+1-teamCounts[iOldTeam] >= PTB_MAXDIFF ) {
client_print(id,print_chat,"PTB: Команда полна.Перемещение не возможно.")
#if !defined MANUAL_SWITCH
engclient_cmd(id,"chooseteam") // display menu again
#endif
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE // OK! He can join to the oppsoite team!!!
}

// Player is choosing his team for the first time!
if (iNewTeam==CTS||iNewTeam==TS){
// Get opposite team
new opposingTeam = (iNewTeam==CTS)? TS : CTS
// Players is joining to one team but the opposite is not full
// and his team is bettter then opposite or has more players
if (teamCounts[iNewTeam] && teamCounts[opposingTeam]<PTB_MAXSIZE &&
(iNewTeam==winnerTeam||(!winnerTeam&&teamCounts[iNewTeam]>teamCounts[opposingTeam]))) {
new text[256],name[32]
get_user_name(id,name,31)
if (++wtjCount[id] >= PTB_WTJKICK && PTB_KICK) {
format(text, 255, "[NewLine #4]: Kicking %s for a WTJ count %d of %d.", name, wtjCount[id],PTB_WTJKICK)
doTypesay(text, 5, 0, 255, 0)
say(text)
server_cmd("kick #%d", get_user_userid(id))
return PLUGIN_HANDLED
}
if (iNewTeam==CTS) {
if (wtjCount[id]>=PTB_WTJAUTO && is_user_connected(id)) {
manageWtjFile(id)
format(text, 255, "[NewLine #4]: Forcing %s to the Ts (WTJ: %d/%d).", name, wtjCount[id],PTB_WTJKICK)

engclient_cmd(id,"jointeam","1")

doTypesay(text, 5, 255, 50, 0)
say(text)
}
else if (PTB_TELLWTJ) {
format(text, 255, "[NewLine #4]: Контры - довольно сильная команда, %s (WTJ: %d/%d).", name, wtjCount[id],PTB_WTJKICK)
doTypesay(text, 5, 0, 50, 255)
say(text)
#if !defined MANUAL_SWITCH
engclient_cmd(id,"chooseteam") // display menu again
#endif
}
}
else {
if (wtjCount[id]>=PTB_WTJAUTO) {
manageWtjFile(id)
format(text, 255, "[NewLine #4]: Forcing %s to the CTs (WTJ: %d/%d).", name, wtjCount[id],PTB_WTJKICK)

engclient_cmd(id,"jointeam","2")

doTypesay(text, 5, 0, 50, 255)
say(text)
}
else if (PTB_TELLWTJ) {
format(text, 255, "[NewLine #4]: Теры - довольно сильная команда, %s (WTJ: %d/%d).", name, wtjCount[id],PTB_WTJKICK)
doTypesay(text, 5, 255, 50, 0)
say(text)
#if !defined MANUAL_SWITCH
engclient_cmd(id,"chooseteam") // display menu again
#endif
}
}
return PLUGIN_HANDLED
}
// check for maximum team size
if (teamCounts[iNewTeam] >= PTB_MAXSIZE) {
client_print(id,print_chat,"[NewLine #4]: Команда полна.Перемещение не возможно.")
#if !defined MANUAL_SWITCH
engclient_cmd(id,"chooseteam") // display menu again
#endif
return PLUGIN_HANDLED
}
// check team size difference limits
if ( teamCounts[iNewTeam]-teamCounts[opposingTeam] >= PTB_MAXDIFF) {
client_print(id,print_chat,"[NewLine #4]: Команда полна.Перемещение не возможно.")
#if !defined MANUAL_SWITCH
engclient_cmd(id,"chooseteam") // display menu again
#endif
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE // OK! He can join to the oppsoite team!!!
}

// He is choosing the AUTO-SELECT but he was already in game (He wants to play fair!)
if (iNewTeam==AUTO_TEAM&&(iOldTeam==CTS||iOldTeam==TS)) {
//say("Changing team automatically.")
new opposingTeam = (iOldTeam==CTS) ? TS : CTS
if (teamCounts[opposingTeam] && ( (teamCounts[opposingTeam]>=PTB_MAXSIZE)
|| (iOldTeam==loserTeam) || (!loserTeam&&teamCounts[iOldTeam]<=teamCounts[opposingTeam])
|| (teamCounts[opposingTeam]+1-teamCounts[iOldTeam]>=PTB_MAXDIFF)) ) {
client_print(id,print_chat,"PTB: Ты можешь остаться в этой команде...")
return PLUGIN_HANDLED
}
client_print(id,print_chat,"PTB: Ты будешь перемещен автоматически...")

engclient_cmd(id,"jointeam",(opposingTeam==CTS)?"2":"1")

return PLUGIN_HANDLED
}
// He is choosing the team for the first time with AUTO-SELECT (What a nice kid!)
if (iNewTeam==AUTO_TEAM) {
/* this is the "always smaller team" version
if (teamCounts[CTS] < teamCounts[TS] || teamCounts[TS] >= PTB_MAXSIZE) iNewTeam = CTS
else if (teamCounts[TS] < teamCounts[CTS] || teamCounts[CTS] >= PTB_MAXSIZE) iNewTeam = TS
// both teams have same size ...
else if (winnerTeam && teamCounts[loserTeam]<PTB_MAXSIZE) iNewTeam = loserTeam
else if (teamCounts[TS] >= PTB_MAXSIZE) iNewTeam = CTS
else if (teamCounts[CTS] >= PTB_MAXSIZE) iNewTeam = TS
else iNewTeam = (random_num(0,100) < 50) ? CTS : TS
*/
// this version prefers the losing team (but still honors PTB_MAXDIFF)
if (teamCounts[CTS] >= PTB_MAXSIZE) iNewTeam = TS
else if (teamCounts[TS] >= PTB_MAXSIZE) iNewTeam = CTS
else if (teamCounts[CTS]-teamCounts[TS] >= PTB_MAXDIFF) iNewTeam = TS
else if (teamCounts[TS]-teamCounts[CTS] >= PTB_MAXDIFF) iNewTeam = CTS
else if (winnerTeam) iNewTeam = loserTeam
else if (teamCounts[CTS]<teamCounts[TS]) iNewTeam = CTS
else if (teamCounts[TS]<teamCounts[CTS]) iNewTeam = TS
// both teams have same size ...
else iNewTeam = (random_num(0,100) < 50) ? CTS : TS
// check for maximum team size
if (teamCounts[iNewTeam]>=PTB_MAXSIZE) {
client_print(id,print_chat,"[NewLine #4]: Максимальное количество игроков.") // ??? - only a spectator???
#if !defined MANUAL_SWITCH
engclient_cmd(id,"chooseteam") // display menu again
#endif
return PLUGIN_HANDLED
}
client_print(id,print_chat,"[NewLine #4]: Рапределен автоматически...")

engclient_cmd(id,"jointeam",(iNewTeam==CTS)?"2":"1")

return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}

public team_score(){
new arg[2]
read_data(1,arg,1)
teamScores[ ( arg[0] == 'T' ) ? TS : CTS ] = read_data(2)
}

public win_streaks(param[]){
new winner = param[0]
new looser = param[1]
if (winStreaks[winner] < 0) {
winStreaks[winner] = 1
winStreaks[looser] = -1
}
else {
winStreaks[winner]++
winStreaks[looser]--
}
actAtEndOfRound()
}

public round_end(){
new param[12]
read_data(2,param,8)
if (param[7]=='c') {//%!MRAD_ctwin
param[0] = CTS
param[1] = TS
}
else if (param[7]=='t') {//%!MRAD_terwin
param[0] = TS
param[1] = CTS
}
else
return // %!MRAD_rounddraw (both teams have left the game)
set_task(4.5,"win_streaks",0,param,2)
}

public new_round() {
//if ( floatround(get_cvar_float("mp_roundtime") * 60.0) != read_data(1) ) return
if ( floatround(get_cvar_float("mp_roundtime") * 60.0,floatround_floor) != read_data(1) ) return
++roundCounter
announceStatus()
}

// Happen only at team select (also auto-join)
public team_join() {
new arg[32]
read_data(3,arg,31)
lastRoundSwitched[ get_user_index(arg) ] = roundCounter
}

// Can happen at begin of round or team select
public team_assign() {
new arg[2], team
new i = read_data(1)
read_data(2,arg,1)
if ( arg[0] == 'C' )
team = CTS
else if ( arg[0] == 'T' )
team = TS
else
team = UNASSIGNED
teamCounts[playerTeam[i]]-- // Unregister from old team
teamCounts[team]++ // Increase ammount in new team
playerTeam[i] = team // Assign to new
}

public game_restart(){
roundCounter = 0
lastSwitchRound = 0
couldNotSwitchCounter = 0
teamKills[0] = teamKills[1] = teamKills[2] = 0
teamDeaths[0] = teamDeaths[1] = teamDeaths[2] = 0
teamScores[0] = teamScores[1] = teamScores[2] = 0
winStreaks[0] = winStreaks[1] = winStreaks[2] = 0
wtConditions[0] = wtConditions[1] = wtConditions[2] = 0
validTargetCounts[0] = validTargetCounts[1] = validTargetCounts[2] = 0
new a = get_maxplayers()
for (new i = 1; i <= a; ++i){
kills[i] = 0
deaths[i] = 0
wtjCount[i] = 0
lastRoundSwitched[i] = -999
}
}

public death_msg(){
new iWinner = read_data(1)
new iLoser = read_data(2)
if ( iWinner < 1 || iWinner > 32 || iLoser < 1 || iLoser > 32 )
return
if ( playerTeam[iWinner] == playerTeam[iLoser] )
return // no TKS!!!
kills[iWinner]++
deaths[iLoser]++
if (PTB_SCALEDOWN <= 1) return
if (kills[iWinner] + deaths[iWinner] >= PTB_MAXINCIDENTS) {
kills[iWinner] /= PTB_SCALEDOWN
deaths[iWinner] /= PTB_SCALEDOWN
}
if (kills[iLoser] + deaths[iLoser] >= PTB_MAXINCIDENTS) {
kills[iLoser] /= PTB_SCALEDOWN
deaths[iLoser] /= PTB_SCALEDOWN
}
}

calcTeamScores() {
teamDeaths[UNASSIGNED] = 0
teamDeaths[CTS] = 0
teamDeaths[TS] = 0
teamKills[UNASSIGNED] = 0
teamKills[CTS] = 0
teamKills[TS] = 0

new team, a = get_maxplayers()
for (new i = 1; i <= a; ++i) {
team = playerTeam[i]
teamKills[team] += kills[i]
teamDeaths[team] += deaths[i]
}

ctKD = fdivWorkaround(float(teamKills[CTS]), float(teamDeaths[CTS]))
tKD = fdivWorkaround(float(teamKills[TS]), float(teamDeaths[TS]))
}

announceStatus() {
if (!PTB_ANNOUNCE) return
checkTeamBalance()
new text[256]
if (winnerTeam == TS) {
format(text, 255, "Команда (КОНТРОВ) смогла воспользоваться некоторой поддержкой.")
doTypesay(text, 5, 0, 50, 255)
say("[NewLine #4]: Команда (КОНТРОВ) смогла воспользоваться некоторой поддержкой.")
}
else if (winnerTeam == CTS) {
format(text, 255, "Команда (ТЕРОВ) смогла воспользоваться некоторой поддержкой.")
doTypesay(text, 5, 255, 50, 0)
say("[NewLine #4]: Команда (ТЕРОВ) смогла воспользоваться некоторой поддержкой.")
}
else if (wtConditions[TS] > wtConditions[CTS]) {
format(text, 255, "[NewLine #4]: Наблюдение за победами команды ТЕРОВ .")
doTypesay(text, 5, 255, 50, 0)
say("[NewLine #4]: Наблюдение за победами команды ТЕРОВ.")
}
else if (wtConditions[CTS] > wtConditions[TS]) {
format(text, 255, "Наблюдение за победами команды КОНТРОВ.")
doTypesay(text, 5, 0, 50, 255)
say("[NewLine #4]: Наблюдение за победами команды КОНТРОВ.")
}
else if (PTB_SAYOK) {
format(text, 255, "[NewLine #4]: Команды впорядке ,никаких действий не требуется.")
doTypesay(text, 5, 200, 100, 0)
say("[NewLine #4]: Команды впорядке ,никаких действий не требуется.")
}
}

public admin_ptb(id,level,cid) {
if (!cmd_access(id,level,cid,1))
return PLUGIN_HANDLED
new cmd[32], arg[32], lastcmd

if ( read_argv(1,cmd,31) == 0 ) { // no command - plain amx_ptb
//console_print(id,"PTB: Ptahhotep's Team Balancer %s", PTB_VERSION)
//console_print(id,"PTB: (ptahhotep@planethalflife.com)")
checkTeamBalance()
displayStatistics(id)
return PLUGIN_HANDLED
}
if (equali(cmd, "on") || equal(cmd, "1")) {
PTB_LIMITJOIN = true
PTB_SWITCH = true
PTB_ANNOUNCE = true
console_print(id,"[NewLine #4]: Enabled all PTB actions.")
return PLUGIN_HANDLED
}
if (equali(cmd, "off") || equal(cmd, "0")) {
PTB_SWITCH = false
PTB_ANNOUNCE = false
PTB_LIMITJOIN = false
console_print(id,"[NewLine #4]: Disabled all PTB actions.")
return PLUGIN_HANDLED
}
if (equal(cmd, "list") || equal(cmd, "help")) {
console_print(id,"[NewLine #4]: Доступные команды:")
console_print(id,"[NewLine #4]: Контроль выбора команды: ^"limitjoin^", ^"limitafter^", ^"limitmin^", ^"maxsize^", ^"autorounds^",")
console_print(id,"[NewLine #4]: ^"maxdiff^", ^"wtjauto^", ^"wtjkick^", ^"kick^", ^"savewtj^"")
console_print(id,"[NewLine #4]: Балансировка команд: ^"switch^", ^"switchafter^", ^"switchmin^", ^"switchfreq^", ^"playerfreq^",")
console_print(id,"[NewLine #4]: ^"forceswitch^", ^"deadonly^"")
console_print(id,"[NewLine #4]: Пределы уровней мастерства: ^"maxstreak^", ^"maxscore^", ^"minrating^", ^"maxrating^", ^"superrating^"")
console_print(id,"[NewLine #4]: Сообщения: ^"tellwtj^", ^"announce^", ^"sayok^", ^"typesay^"")
console_print(id,"[NewLine #4]: Прочее: ^"^", ^"status^", ^"list^", ^"help^", ^"on^", ^"off^", ^"save^", ^"load^"")
console_print(id,"[NewLine #4]: Для просмотра всех настроек ,напишите ^"amx_ptb status^".")
console_print(id,"[NewLine #4]: Для изменения настроек ,напишите ^"amx_ptb <setting> <on|off|value>^".")
console_print(id,"[NewLine #4]: Для просмотра статистики ,напишите ^"amx_ptb^".")
return PLUGIN_HANDLED
}
new arglen = read_argv(2,arg,31)
new status = equal(cmd, "status")

// team selection control
if ( status ) console_print(id,"[NewLine #4]: ---------- Team Selection Control ----------")

// PTB_LIMITJOIN
if ( (lastcmd = equal(cmd, "limitjoin")) && arglen ) PTB_LIMITJOIN = check_param_bool(arg)
if ( status || lastcmd ) console_print(id,"[NewLine #4]: (limitjoin) WTJ предел %s.", PTB_LIMITJOIN ? "ON" : "OFF")

// PTB_LIMITAFTER
if ( (lastcmd = equal(cmd, "limitafter")) && arglen ) PTB_LIMITAFTER = check_param_num(arg,0)
if ( status || lastcmd ) console_print(id,"[NewLine #4]: (limitafter) Ограничение выбора команды после %d раундов.", PTB_LIMITAFTER)

// PTB_LIMITMIN
if ( (lastcmd = equal(cmd, "limitmin")) && arglen ) PTB_LIMITMIN = check_param_num(arg,0)
if ( status || lastcmd ) console_print(id,"[NewLine #4]: (limitmin) Для ограничения выбора команды необходимо %d игроков.", PTB_LIMITMIN)

// PTB_MAXSIZE
if ( (lastcmd = equal(cmd, "maxsize")) && arglen ) PTB_MAXSIZE = check_param_num(arg,0)
if ( status || lastcmd ) console_print(id,"[NewLine #4]: (maxsize) Максимальный размер команды %d игроков.", PTB_MAXSIZE)

// PTB_MAXDIFF
if ( (lastcmd = equal(cmd, "maxdiff")) && arglen ) PTB_MAXDIFF = check_param_num(arg,1)
if ( status || lastcmd ) console_print(id,"[NewLine #4]: (maxdiff) Максимальная разница команд %d игроков.", PTB_MAXDIFF)

// PTB_AUTOROUNDS
if ( (lastcmd = equal(cmd, "autorounds")) && arglen ) PTB_AUTOROUNDS = check_param_num(arg,0)
if ( status || lastcmd ) console_print(id, "[NewLine #4]: (autorounds) Первый(е) %d раундов команда выбирается автоматически.", PTB_AUTOROUNDS)

// PTB_WTJAUTO
if ( (lastcmd = equal(cmd, "wtjauto")) && arglen ) PTB_WTJAUTO = check_param_num(arg,0)
if ( status || lastcmd ) console_print(id,"[NewLine #4]: (wtjauto) Авто выбор после %d попыток выбора команды.", PTB_WTJAUTO)

// PTB_WTJKICK
if ( (lastcmd = equal(cmd, "wtjkick")) && arglen ) PTB_WTJKICK = check_param_num(arg,1)
if ( status || lastcmd ) console_print(id,"[NewLine #4]: (wtjauto) Auto-kicking WTJ after %d tr(y/ies).", PTB_WTJKICK)

// PTB_KICK
if ( (lastcmd = equal(cmd, "kick")) && arglen ) PTB_KICK = check_param_bool(arg)
if ( status || lastcmd ) console_print(id,"[NewLine #4]: (kick) Кик за WTJ %s.", PTB_KICK ? "ON" : "OFF" )

// PTB_SAVEWTJ
if ( (lastcmd = equal(cmd, "savewtj")) && arglen ) PTB_SAVEWTJ = check_param_bool(arg)
if ( status || lastcmd ) console_print(id,"[NewLine #4]: (savewtj) Сохранение в wtj.log %s.", PTB_SAVEWTJ ? "ON" : "OFF");

// team balancing actions
if ( status ) console_print(id,"[NewLine #4]: ---------- Team Balancing Actions ----------")

// PTB_SWITCH
if ( (lastcmd = equal(cmd, "switch")) && arglen ) PTB_SWITCH = check_param_bool(arg)
if ( status || lastcmd ) console_print(id,"[NewLine #4]: (switch) Смена команды %s.", PTB_SWITCH ? "ON" : "OFF")

// PTB_SWITCHAFTER
if ( (lastcmd = equal(cmd, "switchafter")) && arglen ) PTB_SWITCHAFTER = check_param_num(arg,0)
if ( status || lastcmd ) console_print(id,"[NewLine #4]: (switchafter) Смена команды после %d рауда(ов).", PTB_SWITCHAFTER)

// PTB_SWITCHMIN
if ( (lastcmd = equal(cmd, "switchmin")) && arglen ) PTB_SWITCHMIN = check_param_num(arg,0)
if ( status || lastcmd ) console_print(id,"[NewLine #4]: (switchmin) Для смены команд должно быть %d игрока(ов).", PTB_SWITCHMIN)

// PTB_PLAYERFREQ
if ( (lastcmd = equal(cmd, "playerfreq")) && arglen ) PTB_PLAYERFREQ = check_param_num(arg,0)
if ( status || lastcmd ) console_print(id,"[NewLine #4]: (playerfreq) Игрок может быть перемещен каждые %d раунда(ов).", PTB_PLAYERFREQ)

// PTB_SWITCHFREQ
if ( (lastcmd = equal(cmd, "switchfreq")) && arglen ) PTB_SWITCHFREQ = check_param_num(arg,1)
if ( status || lastcmd ) console_print(id,"[NewLine #4]: (switchfreq) Замены могут быть каждые %d раунда(ов).", PTB_SWITCHFREQ)

// PTB_FORCESWITCH
if ( (lastcmd = equal(cmd, "forceswitch")) && arglen ) PTB_FORCESWITCH = check_param_num(arg,0)
if ( status || lastcmd ) console_print(id,"[NewLine #4]: (forceswitch) Принудительная смена команды после %d неудавшихся попыток.", PTB_FORCESWITCH)

// PTB_DEADONLY
if ( (lastcmd = equal(cmd, "deadonly")) && arglen ) PTB_DEADONLY = check_param_bool(arg)
if ( status || lastcmd ) console_print(id,"[NewLine #4]: (deadonly) Перемещение только мертвых %s.",PTB_DEADONLY ? "ON" : "OFF" )

// messages
if ( status ) console_print(id,"[NewLine #4]: ---------- Messages ----------")

// PTB_TELLWTJ
if ( (lastcmd = equal(cmd, "tellwtj")) && arglen ) PTB_TELLWTJ = check_param_bool(arg)
if ( status || lastcmd ) console_print(id,"[NewLine #4]: (tellwtj) Сообщения о WTJ %s.",PTB_TELLWTJ ? "ON" : "OFF")

// PTB_ANNOUNCE
if ( (lastcmd = equal(cmd, "announce")) && arglen ) PTB_ANNOUNCE = check_param_bool(arg)
if ( status || lastcmd ) console_print(id,"[NewLine #4]: (announce) Объявления %s.",PTB_ANNOUNCE ? "ON" : "OFF")

// PTB_SAYOK
if ( (lastcmd = equal(cmd, "sayok")) && arglen ) PTB_SAYOK = check_param_bool(arg)
if ( status || lastcmd ) console_print(id,"[NewLine #4]: (sayok) ^"OK^" сообщения %s.",PTB_SAYOK ? "ON" : "OFF")

// PTB_TYPESAY
if ( (lastcmd = equal(cmd, "typesay")) && arglen ) PTB_TYPESAY = check_param_bool(arg)
if ( status || lastcmd ) console_print(id,"[NewLine #4]: (typesay) HUD сообщения %s.",PTB_TYPESAY ? "ON" : "OFF")

// team strength limits
if ( status ) console_print(id,"[NewLine #4]: ---------- Team Strength Limits ----------")

// PTB_MAXSTREAK
if ( (lastcmd = equal(cmd, "maxstreak")) && arglen ) PTB_MAXSTREAK = check_param_num(arg,1)
if ( status || lastcmd ) console_print(id,"[NewLine #4]: (maxstreak) Максимальное количество побед подряд %d.", PTB_MAXSTREAK)

// PTB_MAXSCORE
if ( (lastcmd = equal(cmd, "maxscore")) && arglen ) PTB_MAXSCORE = check_param_num(arg,1)
if ( status || lastcmd ) console_print(id,"[NewLine #4]: (maxscore) Максимальная разница в очках %d.", PTB_MAXSCORE)

// PTB_MINRATING
if ( (lastcmd = equal(cmd, "minrating")) && arglen ) PTB_MINRATING = check_param_float(arg,1.0)
if ( status || lastcmd ) console_print(id,"[NewLine #4]: (minrating) Минимальный рейтинг %.2f.",PTB_MINRATING)

// PTB_MAXRATING
if ( (lastcmd = equal(cmd, "maxrating")) && arglen ) PTB_MAXRATING = check_param_float(arg,1.0)
if ( status || lastcmd ) console_print(id,"[NewLine #4]: (maxrating) Максимальный рейтинг %.2f.",PTB_MAXRATING)

// PTB_SUPERRATING
if ( (lastcmd = equal(cmd, "superrating")) && arglen ) PTB_SUPERRATING = check_param_float(arg,1.0)
if ( status || lastcmd ) console_print(id,"[NewLine #4]: (superrating) Сверхвысокий рейтинг %.2f.",PTB_SUPERRATING)

// PTB_MAXINCIDENTS
if ( (lastcmd = equal(cmd, "maxincidents")) && arglen ) PTB_MAXINCIDENTS = check_param_num(arg,1)
if ( status || lastcmd ) console_print(id,"[NewLine #4]: (maxincidents) Максимум ошибок игрока перед понижением рейтинга %d.", PTB_MAXINCIDENTS)

// PTB_SCALEDOWN
if ( (lastcmd = equal(cmd, "scaledown")) && arglen ) PTB_SCALEDOWN = check_param_num(arg,1)
if ( status || lastcmd ) console_print(id,"[NewLine #4]: (scaledown) Коэффициент понижения рейтинга %d.", PTB_SCALEDOWN)

// misc
if ( status ) {
console_print(id,"[NewLine #4]: ---------- Misc ----------")
console_print(id,"[NewLine #4]: To enable or disable PTB, type ^"admin_ptb <on|1|off|0>^".")
console_print(id,"[NewLine #4]: To view or change a single PTB setting, type ^"amx_ptb <setting> <on|off|value>^".")
console_print(id,"[NewLine #4]: To view a brief overview of PTB commands, type ^"amx_ptb help^" or ^"amx_ptb list^".")
console_print(id,"[NewLine #4]: For PTB statistics, simply type ^"amx_ptb^".")
}

return PLUGIN_HANDLED
}

stock displayStatistics(id,bool:toLog = false) {
//say("displayStatistics")
new text[256]
// time
/*format(text, 255, "[NewLine #4]: Статистика сгенерирована за: %s", lastTeamBalanceCheck)
if (toLog) log_amx(text)
console_print(id,text)*/
// connected players
format(text, 255, "[NewLine #4]: Игроков: %d", get_playersnum())
if (toLog) log_amx(text)
console_print(id,text)
// team sizes
format(text, 255, "[NewLine #4]: Команды: Контров %d, Теров %d", teamCounts[CTS], teamCounts[TS])
if (toLog) log_amx(text)
console_print(id,text)
// team scores
format(text, 255, "[NewLine #4]: Счет: Контров %d, Теров %d", teamScores[CTS], teamScores[TS])
if (toLog) log_amx(text)
console_print(id,text)
// Kills:Deaths
format(text, 255, "[NewLine #4]: Фраги и смерти: Контров %d:%d, Теров %d:%d", teamKills[CTS], teamDeaths[CTS], teamKills[TS], teamDeaths[TS])
if (toLog) log_amx(text)
console_print(id,text)
// Kills/Deaths
format(text, 255, "[NewLine #4]: Соотношение фраги/смерти: Контров %.2f, Ts %.2f", ctKD , tKD )
if (toLog) log_amx(text)
console_print(id,text)
// strength
format(text, 255, "[NewLine #4]: Сила команд: Контров %.2f, Теров %.2f",ctStrength , tStrength )
if (toLog) log_amx(text)
console_print(id,text)
// rating
format(text, 255, "[NewLine #4]: Рейтинг команд: Контров %.2f, Теров %.2f",ctRating,tRating )
if (toLog) log_amx(text)
console_print(id,text)
// won rounds
if (winStreaks[CTS] > 0) {
format(text, 255, "[NewLine #4]: LПоследние %d раунда(ов) выйгарли CT.", winStreaks[CTS])
if (toLog) log_amx(text)
console_print(id,text)
}
else if (winStreaks[TS] > 0) {
format(text, 255, "[NewLine #4]: Последние %d раунда(ов) выйграли T.", winStreaks[TS])
if (toLog) log_amx(text)
console_print(id,text)
}

// winning team
switch(winnerTeam){
case CTS: format(text, 255, "[NewLine #4]: Последние %d раунда(ов) выйгарли CT.")
case TS: format(text, 255, "[NewLine #4]: Последние %d раунда(ов) выйграли T.")
default: format(text, 255, "[NewLine #4]: Балансировка команд.")
}
if (toLog) log_amx(text)
console_print(id,text)

/*format(text, 255, "[NewLine #4]: These statistics might be already outdated.")
if (toLog) log_amx(text)
console_print(id,text)

format(text, 255, "[NewLine #4]: To view a brief overview of PTB commands, type ^"amx_ptb help^" or ^"amx_ptb list^".")
if (toLog) log_amx(text)
console_print(id,text)

format(text, 255, "[NewLine #4]: Для просмотра всех настроек напишите ^"amx_ptb status^".")
if (toLog) log_amx(text)
console_print(id,text)*/
}

public client_connect(id){
kills[id] = 0
deaths[id] = 0
isBeingTransfered[id] = false
playerTeam[id] = UNASSIGNED
lastRoundSwitched[id] = -999
wtjCount[id] = 0
get_user_info(id,"_vgui_menus",clientVGUIMenu[id],1)
clientVGUIMenu[id][0] = '0'

return PLUGIN_CONTINUE
}

public client_disconnect(id) {
kills[id] = 0
deaths[id] = 0
isBeingTransfered[id] = false
playerTeam[id] = UNASSIGNED
lastRoundSwitched[id] = -999
wtjCount[id] = 0
// redundant team size check
teamCounts[UNASSIGNED] = 0
teamCounts[CTS] = 0
teamCounts[TS] = 0

new a = get_maxplayers()
for (new i = 1; i <= a; ++i)
++teamCounts[playerTeam[i]]


if (clientVGUIMenu[id][0] != '0') {
set_user_info( id, "_vgui_menus", clientVGUIMenu[id] )
clientVGUIMenu[id][0] = '0'
}

return PLUGIN_CONTINUE
}


про мульти язычность :плагин что нужно заменить сдесь,чтоб выводило цветным * Вы убили 10.
Код
        if (KillingStreak)
        {
            new appl[32], ppl, i
            get_players(appl, ppl, "ac")
            
            for (new a = 0; a < ppl; ++a)
            {
                i = appl[a]
                
                if (g_streakKills[i][0] >= 2)
                    client_print(i, print_chat, "* %L", i, "KILLED_ROW", g_streakKills[i][0])
                else if (g_streakKills[i][1] >= 2)
                    client_print(i, print_chat, "* %L", i, "DIED_ROUNDS", g_streakKills[i][1])
            }


полный код
CODE
/* AMX Mod X
*/

#include <amxmodx>
#include <csx>
#include <cstrike>
#include <colorchat>

public MultiKill
public MultiKillSound
public BombPlanting
public BombDefusing
public BombPlanted
public BombDefused
public BombFailed
public BombPickUp
public BombDrop
public BombCountVoice
public BombCountDef
public BombReached
public ItalyBonusKill
public EnemyRemaining
public LastMan
public KnifeKill
public KnifeKillSound
public GrenadeKill
public GrenadeSuicide
public HeadShotKill
public HeadShotKillSound
public RoundCounterSound
public RoundCounter
public KillingStreak
public KillingStreakSound
public DoubleKill
public DoubleKillSound
public PlayerName
public FirstBloodSound

new g_streakKills[33][2]
new g_multiKills[33][2]
new g_C4Timer
new g_Defusing
new g_Planter
new Float:g_LastOmg
new g_LastAnnounce
new g_roundCount
new Float:g_doubleKill
new g_doubleKillId
new g_friend[33]
new g_firstBlood
new g_center1_sync
new g_announce_sync
new g_status_sync
new g_left_sync
new g_bottom_sync
new g_he_sync

new g_MultiKillMsg[7][] =
{
"%s Triple Kill! ^n%L %d %L (%d %L)",
"%s Ludicrous Kill ! ^n%L %d %L (%d %L)",
"%s Killing Spree^n%L %d %L (%d %L)",
"%s Mega Kill !!! ^n%L %d %L (%d hs)",
"%s Unstoppable !^n%L %d %L (%d %L)",
"%s M m M m o n s t e r Kill!^n%L %d %L (%d %L)",
"%s Godlike !^n%L %d %L (%d %L)"
}

new g_Sounds[7][] =
{
"triplekill",
"ludicrouskill",
"killingspree",
"megakill",
"unstoppable",
"monsterkill",
"godlike"
}
new g_KillingMsg[7][] =
{
"%s: Triple Kill",
"%s: Ludicrous Kill !",
"%s: Killing Spree",
"%s: M e G a Kill",
"%s: Unstoppable !",
"%s: M m M m o n s t e r Kill !",
"%s GODLIKE !"
}

new g_KinfeMsg[4][] =
{
"KNIFE_MSG_1",
"KNIFE_MSG_2",
"KNIFE_MSG_3",
"KNIFE_MSG_4"
}

new g_LastMessages[4][] =
{
"LAST_MSG_1",
"LAST_MSG_2",
"LAST_MSG_3",
"LAST_MSG_4"
}

new g_HeMessages[4][] =
{
"HE_MSG_1",
"HE_MSG_2",
"HE_MSG_3",
"HE_MSG_4"
}

new g_SHeMessages[4][] =
{
"SHE_MSG_1",
"SHE_MSG_2",
"SHE_MSG_3",
"SHE_MSG_4"
}

new g_HeadShots[7][] =
{
"HS_MSG_1",
"HS_MSG_2",
"HS_MSG_3",
"HS_MSG_4",
"HS_MSG_5",
"HS_MSG_6",
"HS_MSG_7"
}

new g_teamsNames[4][] =
{
"TERRORIST",
"CT",
"TERRORISTS",
"CTS"
}

public plugin_init()
{
register_plugin("CS Misc. Stats", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("miscstats.txt")
register_event("TextMsg", "eRestart", "a", "2&#Game_C", "2&#Game_w")
register_event("SendAudio", "eEndRound", "a", "2&%!MRAD_terwin", "2&%!MRAD_ctwin", "2&%!MRAD_rounddraw")
register_event("RoundTime", "eNewRound", "bc")
register_event("StatusValue", "setTeam", "be", "1=1")
register_event("StatusValue", "showStatus", "be", "1=2", "2!0")
register_event("StatusValue", "hideStatus", "be", "1=1", "2=0")

new mapname[32]
get_mapname(mapname, 31)

if (equali(mapname, "de_", 3) || equali(mapname, "csde_", 5))
{
register_event("StatusIcon", "eGotBomb", "be", "1=1", "1=2", "2=c4")
register_event("TextMsg", "eBombPickUp", "bc", "2&#Got_bomb")
register_event("TextMsg", "eBombDrop", "bc", "2&#Game_bomb_d")
}
else if (equali(mapname, "cs_italy"))
{
register_event("23", "chickenKill", "a", "1=108", /*"12=106", */ "15=4")
register_event("23", "radioKill", "a", "1=108", /*"12=294", */ "15=2")
}

g_center1_sync = CreateHudSyncObj()
g_announce_sync = CreateHudSyncObj()
g_status_sync = CreateHudSyncObj()
g_left_sync = CreateHudSyncObj()
g_bottom_sync = CreateHudSyncObj()
g_he_sync = CreateHudSyncObj()
}

public plugin_cfg()
{
new g_addStast[] = "amx_statscfg add ^"%s^" %s"

server_cmd(g_addStast, "ST_MULTI_KILL", "MultiKill")
server_cmd(g_addStast, "ST_MULTI_KILL_SOUND", "MultiKillSound")
server_cmd(g_addStast, "ST_BOMB_PLANTING", "BombPlanting")
server_cmd(g_addStast, "ST_BOMB_DEFUSING", "BombDefusing")
server_cmd(g_addStast, "ST_BOMB_PLANTED", "BombPlanted")
server_cmd(g_addStast, "ST_BOMB_DEF_SUCC", "BombDefused")
server_cmd(g_addStast, "ST_BOMB_DEF_FAIL", "BombFailed")
server_cmd(g_addStast, "ST_BOMB_PICKUP", "BombPickUp")
server_cmd(g_addStast, "ST_BOMB_DROP", "BombDrop")
server_cmd(g_addStast, "ST_BOMB_CD_VOICE", "BombCountVoice")
server_cmd(g_addStast, "ST_BOMB_CD_DEF", "BombCountDef")
server_cmd(g_addStast, "ST_BOMB_SITE", "BombReached")
server_cmd(g_addStast, "ST_ITALY_BONUS", "ItalyBonusKill")
server_cmd(g_addStast, "ST_LAST_MAN", "LastMan")
server_cmd(g_addStast, "ST_KNIFE_KILL", "KnifeKill")
server_cmd(g_addStast, "ST_KNIFE_KILL_SOUND", "KnifeKillSound")
server_cmd(g_addStast, "ST_HE_KILL", "GrenadeKill")
server_cmd(g_addStast, "ST_HE_SUICIDE", "GrenadeSuicide")
server_cmd(g_addStast, "ST_HS_KILL", "HeadShotKill")
server_cmd(g_addStast, "ST_HS_KILL_SOUND", "HeadShotKillSound")
server_cmd(g_addStast, "ST_ROUND_CNT", "RoundCounter")
server_cmd(g_addStast, "ST_ROUND_CNT_SOUND", "RoundCounterSound")
server_cmd(g_addStast, "ST_KILL_STR", "KillingStreak")
server_cmd(g_addStast, "ST_KILL_STR_SOUND", "KillingStreakSound")
server_cmd(g_addStast, "ST_ENEMY_REM", "EnemyRemaining")
server_cmd(g_addStast, "ST_DOUBLE_KILL", "DoubleKill")
server_cmd(g_addStast, "ST_DOUBLE_KILL_SOUND", "DoubleKillSound")
server_cmd(g_addStast, "ST_PLAYER_NAME", "PlayerName")
server_cmd(g_addStast, "ST_FIRST_BLOOD_SOUND", "FirstBloodSound")
}

public client_putinserver(id)
{
g_multiKills[id] = {0, 0}
g_streakKills[id] = {0, 0}
}

public client_death(killer, victim, wpnindex, hitplace, TK)
{
if (wpnindex == CSW_C4)
return

new headshot = (hitplace == HIT_HEAD) ? 1 : 0
new selfkill = (killer == victim) ? 1 : 0

if (g_firstBlood)
{
g_firstBlood = 0
if (FirstBloodSound)
play_sound("misc/cyberarena/firstblood")
}

if ((KillingStreak || KillingStreakSound) && !TK)
{
g_streakKills[victim][1]++
g_streakKills[victim][0] = 0

if (!selfkill)
{
g_streakKills[killer][0]++
g_streakKills[killer][1] = 0

new a = g_streakKills[killer][0] - 3

if ((a > -1) && !(a % 2))
{
new name[32]
get_user_name(killer, name, 31)

if ((a >>= 1) > 6)
a = 6

if (KillingStreak)
{
set_hudmessage(225, 110, 000, 0.05, 0.50, 1, 6.0, 6.0, 0.5, 0.15, -1)
ShowSyncHudMsg(0, g_left_sync, g_KillingMsg[a], name)
}

if (KillingStreakSound)
{
new file[32]

format(file, 31, "misc/newline4/%s", g_Sounds[a])
play_sound(file)
}
}
}
}

if (MultiKill || MultiKillSound)
{
if (!selfkill && !TK && killer)
{
g_multiKills[killer][0]++
g_multiKills[killer][1] += headshot

new param[2]

param[0] = killer
param[1] = g_multiKills[killer][0]
set_task(4.0 + float(param[1]), "checkKills", 0, param, 2)
}
}

if (EnemyRemaining && is_user_connected(victim))
{
new ppl[32], pplnum = 0, maxplayers = get_maxplayers()
new epplnum = 0
new CsTeams:team = cs_get_user_team(victim)
new CsTeams:other_team
new CsTeams:enemy_team = (team == CS_TEAM_T) ? CS_TEAM_CT : CS_TEAM_T

if (team == CS_TEAM_T || team == CS_TEAM_CT)
{
for (new i=1; i<=maxplayers; i++)
{
if (!is_user_connected(i))
{
continue
}
if (i == victim)
{
continue
}
other_team = cs_get_user_team(i)
if (other_team == team && is_user_alive(i))
{
epplnum++
} else if (other_team == enemy_team) {
ppl[pplnum++] = i
}
}

if (pplnum && epplnum)
{
new message[128], team_name[32]

set_hudmessage(250, 250, 250, -1.0, 0.60, 1, 0.01, 3.0, 0.01, 0.01, -1)

/* This is a pretty stupid thing to translate, but whatever */
new _teamname[32]
if (team == CS_TEAM_T)
{
format(_teamname, 31, "TERRORIST%s", (epplnum == 1) ? "" : "S")
} else if (team == CS_TEAM_CT) {
format(_teamname, 31, "CT%s", (epplnum == 1) ? "" : "S")
}

for (new a = 0; a < pplnum; ++a)
{
format(team_name, 31, "%L", ppl[a], _teamname)
format(message, 127, "%L", ppl[a], "REMAINING", epplnum, team_name)
ShowSyncHudMsg(ppl[a], g_bottom_sync, "%s", message)
}
}
}
}

if (LastMan)
{
new cts[32], ts[32], ctsnum, tsnum
new maxplayers = get_maxplayers()
new CsTeams:team

for (new i=1; i<=maxplayers; i++)
{
if (!is_user_connected(i) || !is_user_alive(i))
{
continue
}
team = cs_get_user_team(i)
if (team == CS_TEAM_T)
{
ts[tsnum++] = i
} else if (team == CS_TEAM_CT) {
cts[ctsnum++] = i
}
}

if (ctsnum == 1 && tsnum == 1)
{
new ctname[32], tname[32]

get_user_name(cts[0], ctname, 31)
get_user_name(ts[0], tname, 31)

set_hudmessage(250, 250, 250, -1.0, 0.25, 1, 6.0, 6.0, 0.5, 0.15, -1)
ShowSyncHudMsg(0, g_center1_sync, "%s против. %s", ctname, tname)

play_sound("misc/newline4/maytheforce")
}
else if (!g_LastAnnounce)
{
new oposite = 0, _team = 0

if (ctsnum == 1 && tsnum > 1)
{
g_LastAnnounce = cts[0]
oposite = tsnum
_team = 0
}
else if (tsnum == 1 && ctsnum > 1)
{
g_LastAnnounce = ts[0]
oposite = ctsnum
_team = 1
}

if (g_LastAnnounce)
{
new name[32]

get_user_name(g_LastAnnounce, name, 31)

set_hudmessage(250, 250, 250, -1.0, 0.25, 1, 6.0, 6.0, 0.5, 0.15, -1)
ShowSyncHudMsg(0, g_center1_sync, "%s (%d HP) vs. %d %s%s: %L", name, get_user_health(g_LastAnnounce), oposite, g_teamsNames[_team], (oposite == 1) ? "" : "S", LANG_PLAYER, g_LastMessages[random_num(0, 3)])

if (!is_user_connecting(g_LastAnnounce))
{
client_cmd(g_LastAnnounce, "spk misc/newline4/oneandonly")
}
}
}
}

if (wpnindex == CSW_KNIFE && (KnifeKill || KnifeKillSound))
{
if (KnifeKill)
{
new killer_name[32], victim_name[32]

get_user_name(killer, killer_name, 31)
get_user_name(victim, victim_name, 31)

set_hudmessage(250, 250, 250, -1.0, 0.30, 0, 6.0, 6.0, 0.5, 0.15, -1)
ShowSyncHudMsg(0, g_he_sync, "%L", LANG_PLAYER, g_KinfeMsg[random_num(0, 3)], killer_name, victim_name)
}

if (KnifeKillSound)
play_sound("misc/newline4/humiliation")
}

if (wpnindex == CSW_HEGRENADE && (GrenadeKill || GrenadeSuicide))
{
new killer_name[32], victim_name[32]

get_user_name(killer, killer_name, 31)
get_user_name(victim, victim_name, 31)

set_hudmessage(250, 250, 250, -1.0, 0.25, 1, 6.0, 6.0, 0.5, 0.15, -1)

if (!selfkill)
{
if (GrenadeKill)
ShowSyncHudMsg(0, g_he_sync, "%L", LANG_PLAYER, g_HeMessages[random_num(0, 3)], killer_name, victim_name)
}
else if (GrenadeSuicide)
ShowSyncHudMsg(0, g_he_sync, "%L", LANG_PLAYER, g_SHeMessages[random_num(0, 3)], victim_name)
}

if (headshot && (HeadShotKill || HeadShotKillSound))
{
if (HeadShotKill && wpnindex)
{
new killer_name[32], victim_name[32], weapon_name[32], message[256], players[32], pnum

xmod_get_wpnname(wpnindex, weapon_name, 31)
get_user_name(killer, killer_name, 31)
get_user_name(victim, victim_name, 31)
get_players(players, pnum, "c")

for (new i = 0; i < pnum; i++)
{
format(message, sizeof(message)-1, "%L", players[i], g_HeadShots[random_num(0, 6)])

replace(message, sizeof(message)-1, "$vn", victim_name)
replace(message, sizeof(message)-1, "$wn", weapon_name)
replace(message, sizeof(message)-1, "$kn", killer_name)

set_hudmessage(100, 100, 255, -1.0, 0.25, 1, 6.0, 6.0, 0.5, 0.15, -1)
ShowSyncHudMsg(players[i], g_announce_sync, "%s", message)
}
}

if (HeadShotKillSound)
{
client_cmd(killer, "spk misc/newline4/headshot")
client_cmd(victim, "spk misc/newline4/headshot")
}
}

if ((DoubleKill || DoubleKillSound) && !selfkill)
{
new Float:nowtime = get_gametime()

if (g_doubleKill == nowtime && g_doubleKillId == killer)
{
if (DoubleKill)
{
new name[32]

get_user_name(killer, name, 31)

set_hudmessage(250, 250, 250, -1.0, 0.25, 1, 6.0, 6.0, 0.5, 0.15, -1)
ShowSyncHudMsg(0, g_center1_sync, "%L", LANG_PLAYER, "DOUBLE_KILL", name)
}

if (DoubleKillSound)
play_sound("misc/newline4/doublekill")
}

g_doubleKill = nowtime
g_doubleKillId = killer
}
}

public hideStatus(id)
{
if (PlayerName)
{
ClearSyncHud(id, g_status_sync)
}
}

public setTeam(id)
g_friend[id] = read_data(2)

public showStatus(id)
{
if(!is_user_bot(id) && is_user_connected(id) && PlayerName)
{
new name[32], pid = read_data(2)

get_user_name(pid, name, 31)
new color1 = 0, color2 = 0

if (get_user_team(pid) == 1)
color1 = 255
else
color2 = 255

if (g_friend[id] == 1) // friend
{
new clip, ammo, wpnid = get_user_weapon(pid, clip, ammo)
new wpnname[32]

if (wpnid)
xmod_get_wpnname(wpnid, wpnname, 31)

set_hudmessage(color1, 50, color2, -1.0, 0.60, 1, 0.01, 3.0, 0.01, 0.01, -1)
ShowSyncHudMsg(id, g_status_sync, "%s -- %d HP / %d AP / %s", name, get_user_health(pid), get_user_armor(pid), wpnname)
} else {
set_hudmessage(color1, 50, color2, -1.0, 0.60, 1, 0.01, 3.0, 0.01, 0.01, -1)
ShowSyncHudMsg(id, g_status_sync, "%s", name)
}
}
}

public eNewRound()
{
if (read_data(1) == floatround(get_cvar_float("mp_roundtime") * 60.0,floatround_floor))
{
g_firstBlood = 1
g_C4Timer = 0
++g_roundCount

if (RoundCounter)
{
set_hudmessage(200, 0, 0, -1.0, 0.30, 0, 6.0, 6.0, 0.5, 0.15, -1)
ShowSyncHudMsg(0, g_announce_sync, "%L", LANG_PLAYER, "PREPARE_FIGHT", g_roundCount)
}

if (RoundCounterSound)
play_sound("misc/newline4/prepare")

if (KillingStreak)
{
new appl[32], ppl, i
get_players(appl, ppl, "ac")

for (new a = 0; a < ppl; ++a)
{
i = appl[a]

if (g_streakKills[i][0] >= 2)
client_print(i, print_chat, "* %L", i, "KILLED_ROW", g_streakKills[i][0])
else if (g_streakKills[i][1] >= 2)
client_print(i, print_chat, "* %L", i, "DIED_ROUNDS", g_streakKills[i][1])
}
}
}
}

public eRestart()
{
eEndRound()
g_roundCount = 0
g_firstBlood = 1
}

public eEndRound()
{
g_C4Timer = -2
g_LastOmg = 0.0
remove_task(8038)
g_LastAnnounce = 0
}

public checkKills(param[])
{
new id = param[0]
new a = param[1]

if (a == g_multiKills[id][0])
{
a -= 3

if (a > -1)
{
if (a > 6)
{
a = 6
}

if (MultiKill)
{
new name[32]

get_user_name(id, name, 31)
set_hudmessage(200, 150, 075, 0.5, 0.60, 0, 6.0, 6.0, 0.5, 0.15, -1)

ShowSyncHudMsg(0, g_left_sync, g_MultiKillMsg[a], name, LANG_PLAYER, "WITH", g_multiKills[id][0], LANG_PLAYER, "KILLS", g_multiKills[id][1], LANG_PLAYER, "HS")
}

if (MultiKillSound)
{
new sound[24]
format(sound, 23, "misc/newline4/%s", g_Sounds[a])
play_sound(sound)
}
}
g_multiKills[id] = {0, 0}
}
}

public chickenKill()
{
if (ItalyBonusKill)
announceEvent(0, "KILLED_CHICKEN")
}

public radioKill()
{
if (ItalyBonusKill)
announceEvent(0, "BLEW_RADIO")
}

announceEvent(id, message[])
{
new name[32]

get_user_name(id, name, 31)
set_hudmessage(255, 100, 50, -1.0, 0.30, 0, 6.0, 6.0, 0.5, 0.15, -1)
ShowSyncHudMsg(0, g_announce_sync, "%L", LANG_PLAYER, message, name)
}

public eBombPickUp(id)
{
if (BombPickUp)
announceEvent(id, "PICKED_BOMB")
}

public eBombDrop()
{
if (BombDrop)
announceEvent(g_Planter, "DROPPED_BOMB")
}

public eGotBomb(id)
{
g_Planter = id

if (BombReached && read_data(1) == 2 && g_LastOmg < get_gametime())
{
g_LastOmg = get_gametime() + 15.0
announceEvent(g_Planter, "REACHED_TARGET")
}
}

public bombTimer()
{
if (--g_C4Timer > 0)
{
if (BombCountVoice)
{
if (g_C4Timer == 30 || g_C4Timer == 20)
{
new temp[64]

num_to_word(g_C4Timer, temp, 63)
format(temp, 63, "^"vox/%s seconds until explosion^"", temp)
play_sound(temp)
}
else if (g_C4Timer < 11)
{
new temp[64]

num_to_word(g_C4Timer, temp, 63)
format(temp, 63, "^"vox/%s^"", temp)
play_sound(temp)
}
}
if (BombCountDef && g_Defusing)
client_print(g_Defusing, print_center, "%d", g_C4Timer)
}
else
remove_task(8038)
}

public bomb_planted(planter)
{
g_Defusing = 0

if (BombPlanted)
announceEvent(planter, "SET_UP_BOMB")

g_C4Timer = get_cvar_num("mp_c4timer")
set_task(1.0, "bombTimer", 8038, "", 0, "b")
}

public bomb_planting(planter)
{
if (BombPlanting)
announceEvent(planter, "PLANT_BOMB")
}

public bomb_defusing(defuser)
{
if (BombDefusing)
announceEvent(defuser, "DEFUSING_BOMB")

g_Defusing = defuser
}

public bomb_defused(defuser)
{
if (BombDefused)
announceEvent(defuser, "DEFUSED_BOMB")
}

public bomb_explode(planter, defuser)
{
if (BombFailed && defuser)
announceEvent(defuser, "FAILED_DEFU")
}

public play_sound(sound[])
{
new players[32], pnum
get_players(players, pnum, "c")
new i

for (i = 0; i < pnum; i++)
{
if (is_user_connecting(players[i]))
continue

client_cmd(players[i], "spk %s", sound)
}
}

public plugin_precache()
{
precache_sound("misc/newline4/doublekill.wav")
precache_sound("misc/newline4/godlike.wav")
precache_sound("misc/newline4/killingspree.wav")
precache_sound("misc/newline4/triplekill.wav")
precache_sound("misc/newline4/monsterkill.wav")
precache_sound("misc/newline4/megakill.wav")
precache_sound("misc/newline4/ludicrouskill.wav")
precache_sound("misc/newline4/unstoppable.wav")
precache_sound("misc/newline4/humiliation.wav")
}


Отредактировал: spzm, - 16.1.2011, 2:00
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя STR@TEG
сообщение 4.2.2011, 1:01
Сообщение #10
Стаж: 16 лет

Сообщений: 4186
Благодарностей: 1763
Полезность: 837

Archipelago,
Код
if (KillingStreak)
{
    new message[192], appl[32], ppl, i
    get_players(appl, ppl, "ac")
    
    for (new a = 0; a < ppl; ++a)
    {
        i = appl[a]
        
        if (g_streakKills[i][0] >= 2)
        {
            format(message, charsmax(message), "* %L", i, "KILLED_ROW", g_streakKills[i][0])
        }
        else if (g_streakKills[i][1] >= 2)
        {
            format(message, charsmax(message), "* %L", i, "DIED_ROUNDS", g_streakKills[i][1])
        }
        
        replace_all(message, charsmax(message), "!n", "^x01")
        replace_all(message, charsmax(message), "!t", "^x03")
        replace_all(message, charsmax(message), "!g", "^x04")
        
        ColorChat(i, TEAM_COLOR, "%s", message)
        // client_print(i, print_chat, "%s", message)
    }
}

В словаре используй префиксы !n, !t, !g. То есть:
!n - желтый цвет.
!t - белый, синий, красный.
!g - зеленый.
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя my_world243
сообщение 8.2.2011, 18:18
Сообщение #11
Стаж: 15 лет

Сообщений: 29
Благодарностей: 1
Полезность: 28

Плагин Deathrun Shop v 4.0
Помогите сделать чтобы надпись "[Deathrun Shop]" была красным цветом в чате.

Я делал так:
Цитата
client_print( id, print_chat, "[Deathrun Shop] %L", id, "DRSHOP_BOTHGREN_ITEM" );
ColorChat( id, TEAM_COLOR, "[Deathrun Shop] %L", id, "DRSHOP_BOTHGREN_ITEM", message );


У меня выдает ошыбку (картинка):
http://s013.radikal.ru/i324/1102/7c/d1aad41fc79b.bmp

*.sma
Код
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <nvault>
#include <hamsandwich>
#include <fakemeta>

// Let's force the semicolon on every endline
#pragma semicolon 1

// Some defines
#define PICKUP_SND "items/gunpickup2.wav"
#define HEALTH_SOUND "items/smallmedkit1.wav"
#define ARMOR_SOUND "items/ammopickup2.wav"
#define CLOACK_SOUND "hornet/ag_buzz1.wav"
#define LJ_SOUND "fvox/powermove_on.wav"
#define SOUND_NVGOFF "items/nvg_off.wav"
#define ADMIN_ACCESS_CMD ADMIN_KICK    
#define HAS_NVGS (1<<0)
#define USES_NVGS (1<<8)
#define get_user_nvg(%1) (get_pdata_int(%1,m_iNvg) & HAS_NVGS)
#define OFFSET_MONEY     115

// Plugin informations
new const PLUGIN[] = "Deathrun Shop";
new const VERSION[] = "4.0";
new const AUTHOR[] = "tuty";

// Zomg lot of globals
new gDrShopOn;
new gHeCost;
new gBothGrenadesCost;
new gSilentCost;
new gHealthCost;
new gArmorCost;
new gSpeedCost;
new gGravityCost;
new gInvisCost;
new gSpeedCvar;
new gGravityCvar;
new gAdvertiseCvar;
new gHealthPointCvar;
new gArmorPointCvar;
new gAdvertiseTimeCvar;
new gInvisPercent;
new gKillerPointsCvar;
new gSuiciderPointsCvar;
new gSavePlayerPoints;
new gNoclipCost;
new gVault;
new gNoclipTime;
new gJetSprite;
new gJetPackCost;
new gJetTime;
new gDeagleCost;
new gMsgItemPickup;
new gLongJumpTime;
new gLongJumpCost;
new gGlowCost;
new gNvgCost;
new gMessageNVG;
new gMsgMoney;

// Item variables
new HasHe[ 33 ];
new HasBothGren[ 33 ];
new HasSilent[ 33 ];
new HasHealth[ 33 ];
new HasArmor[ 33 ];
new HasSpeed[ 33 ];
new HasGravity[ 33 ];
new HasInvis[ 33 ];
new HasNoclip[ 33 ];
new HasJet[ 33 ];
new HasDeagle[ 33 ];
new HasLongJump[ 33 ];
new HasGlow[ 33 ];
new HasNVG[ 33 ];
new gName[ 32 char ];
new gSteamID[ 32 ];
new vKey[ 64 ];
new vData[ 64 ];

// Player points, need this to save points, load points, etc
new gKillerPoints[ 33 ];
new g_Saved_Money[33];

// Offsets for nvg
const m_iNvg = 129;
const m_iLinuxDiff = 5;

// So, let's get started
public plugin_init()
{
    // Registering the plugin to show when you type amx_plugins..
    register_plugin( PLUGIN, VERSION, AUTHOR );
    
    // Registering a little cvar to see wich servers using this plugin
    register_cvar( "drshop_version", VERSION, FCVAR_SERVER | FCVAR_SPONLY );

    // Register some usefull events
    register_logevent( "logevent_round_start", 2, "1=Round_Start" );
    register_event( "DeathMsg", "Hook_Deathmessage", "a" );
    register_event( "CurWeapon", "HookCurWeapon", "be", "1=1" );
    
    // Called when a player is performing a jump
    RegisterHam( Ham_Player_Jump, "player", "bacon_playerJumping" );
    
    // We need this forward to find if player has suicided with kill in console
    // We can't do that on deathmsg because player die in traps by suicide,.. trigger_hurt or world.. etc
    register_forward( FM_ClientKill, "forward_kill" );
    
    // Command for setting points to player/@all
    register_concmd( "deathrun_set_points", "cmdSetPoints", ADMIN_ACCESS_CMD, "<name/@all> <points> - set points to a player" );
    
    // Command for reseting points to palyer/@all
    register_concmd( "deathrun_reset_points", "cmdResetPoints", ADMIN_ACCESS_CMD, "<name/@all> - reset player points" );
    
    // Command for opening the menu
    register_clcmd( "say drshop", "DeathrunShop" );
    register_clcmd( "say /drshop", "DeathrunShop" );
    register_clcmd( "say_team drshop", "DeathrunShop" );
    register_clcmd( "say_team /drshop", "DeathrunShop" );
    
    // Command to see our points
    register_clcmd( "say money", "ShowPoints" );
    register_clcmd( "say /money", "ShowPoints" );
    register_clcmd( "say_team money", "ShowPoints" );
    register_clcmd( "say_team /money", "ShowPoints" );

    
    // Let's register the cvars, a lot of cvars but huh.. stf
    gDrShopOn = register_cvar( "deathrun_shop", "1" );
    gHeCost = register_cvar( "deathrun_he_cost", "3000" );
    gBothGrenadesCost = register_cvar( "deathrun_bothgrenades_cost", "3500" );
    gSilentCost = register_cvar( "deathrun_silent_cost", "6000" );
    gHealthCost = register_cvar( "deathrun_health_cost", "4000" );
    gArmorCost = register_cvar( "deathrun_armor_cost", "4000" );
    gSpeedCost = register_cvar( "deathrun_speed_cost", "16000" );
    gGravityCost = register_cvar( "deathrun_gravity_cost", "16000" );
    gNoclipCost = register_cvar( "deathrun_noclip_cost", "16000" );
    gJetPackCost = register_cvar( "deathrun_jetpack_cost", "16000" );
    gInvisCost = register_cvar( "deathrun_invisibility_cost", "16000" );
    gSpeedCvar = register_cvar( "deathrun_speed_power", "400.0" );
    gNoclipTime = register_cvar( "deathrun_noclip_duration", "3" );
    gJetTime = register_cvar( "deathrun_jetpack_duration", "16000" );
    gDeagleCost = register_cvar( "deathrun_deagle_cost", "16000" );
    gGravityCvar = register_cvar( "deathrun_gravity_power", "0.5" );
    gAdvertiseCvar = register_cvar( "deathrun_advertise_message", "1" );
    gHealthPointCvar = register_cvar( "deathrun_health_points", "255" );
    gArmorPointCvar = register_cvar( "deathrun_armor_points", "400" );
    gAdvertiseTimeCvar = register_cvar( "deathrun_advertise_time", "7.0" );
    gInvisPercent = register_cvar( "deathrun_invisibility_percentage", "0" );
    gKillerPointsCvar = register_cvar( "deathrun_killer_bonuspoints", "5000" );
    gSuiciderPointsCvar = register_cvar( "deathrun_suicider_loose_points", "5000" );
    gSavePlayerPoints = register_cvar( "deathrun_save_points", "0" );
    gLongJumpTime = register_cvar( "deathrun_longjump_duration", "6" );
    gLongJumpCost = register_cvar( "deathrun_longjump_cost", "10000" );
    gGlowCost = register_cvar( "deathrun_glow_cost", "1500" );
    gNvgCost = register_cvar( "deathrun_nvg_cost", "4000" );

    // Let's find/do some stuff here
    gMsgItemPickup = get_user_msgid( "ItemPickup" );
    gMessageNVG = get_user_msgid( "NVGToggle" );
    gMsgMoney = get_user_msgid( "Money" );
    
    // Register the multilingual file
    register_dictionary( "DeathrunShop.txt" );
    
    // Spawn функция будет вызываться после спавна игрока
    RegisterHam(Ham_Spawn, "player", "Spawn", 1);
}

// Precache stuff
public plugin_precache()
{
    gJetSprite = precache_model( "sprites/explode1.spr" );
    precache_sound( PICKUP_SND );
    precache_sound( HEALTH_SOUND );
    precache_sound( ARMOR_SOUND );
    precache_sound( CLOACK_SOUND );
    precache_sound( LJ_SOUND );
}

// Plugin cfg, here we do some ugly shit ever
public plugin_cfg()
{
    new iCfgDir[ 32 ], iFile[ 192 ];
    
    // We need to find the configs directory, and to add the configuration file
    get_configsdir( iCfgDir, charsmax( iCfgDir ) );
    formatex( iFile, charsmax( iFile ), "%s/DeathrunShop.cfg", iCfgDir );
        
    // If file not exists, let's create one but empty
    if( !file_exists( iFile ) )
    {
        server_print( "[Deathrun Shop] %L", LANG_SERVER, "DRSHOP_SVPRINT", iFile );
        write_file( iFile, " ", -1 );
    }
    
    // Else, let's load the cvars from cfg
    else
    {        
        server_print( "[Deathrun Shop] %L", LANG_SERVER, "DRSHOP_SVPRINT_DONE", iFile );
        server_cmd( "exec %s", iFile );
    }
    
    // Set the server maxspeed to a high value, need it for speed item
    server_cmd( "sv_maxspeed 99999999.0" );
}

// When client is connecting, let's reset stuff and load client's points
public client_connect( id )
{
    HasHe[ id ] = false;
    HasBothGren[ id ] = false;
    HasSilent[ id ] = false;
    HasHealth[ id ] = false;
    HasArmor[ id] = false;
    HasSpeed[ id ] = false;
    HasGravity[ id ] = false;
    HasInvis[ id ] = false;
    HasNoclip[ id ] = false;
    HasJet[ id ] = false;
    HasDeagle[ id ] = false;
    HasLongJump[ id ] = false;
    HasGlow[ id ] = false;
    HasNVG[ id ] = false;
    gKillerPoints[id] = 0;
    g_Saved_Money[id] = 0;
    
    // Load client points
    load_client_points( id );
}

// When client has disconnected let's reset stuff and save points
public client_disconnect( id )
{
    HasHe[ id ] = false;
    HasBothGren[ id ] = false;
    HasSilent[ id ] = false;
    HasHealth[ id ] = false;
    HasArmor[ id] = false;
    HasSpeed[ id ] = false;
    HasGravity[ id ] = false;
    HasInvis[ id ] = false;
    HasNoclip[ id ] = false;
    HasJet[ id ] = false;
    HasDeagle[ id ] = false;
    HasLongJump[ id ] = false;
    HasGlow[ id ] = false;
    HasNVG[ id ] = false;
    
    // If player is not a bot, let's save the points
    if( get_pcvar_num( gSavePlayerPoints ) != 0 && !is_user_bot( id ) )
    {
        // Save player points is cvar is 1
        save_client_points( id );
    }
}

// When client has entered on sv, need to show him a hudmessage
public client_putinserver( id )
{
    if( get_pcvar_num( gAdvertiseCvar ) != 0 )
    {
        // Need to set task, 7 default because need to wait for player choosing a team or something
        set_task( get_pcvar_float( gAdvertiseTimeCvar ), "ShowPlayerInfo", id );
    }
}

// Deathrun shop menu with items
public DeathrunShop( id )
{
    // If cvar is set to 0, player can't open the shop
    if( get_pcvar_num( gDrShopOn ) != 1 )
    {
        client_print( id, print_chat, "[Deathrun Shop] %L", id, "DRSHOP_DISABLED" );
        return PLUGIN_HANDLED;
    }
    
    // If player is dead, cant buy items
    if( !is_user_alive( id ) )
    {
        client_print( id, print_chat, "[Deathrun Shop] %L", id, "DRSHOP_ONLY_ALIVE" );
        return PLUGIN_HANDLED;
    }
    
    // Menu stuff
    new szText[ 555 char ];
    formatex( szText, charsmax( szText ), "%L", id, "DRSHOP_MENU_TITLE", VERSION, fm_get_user_money(id) );
    
    new menu = menu_create( szText, "shop_handler" );

    // Menu item 1
    formatex( szText, charsmax( szText ), "%L", id, "DRSHOP_ITEM_1", get_pcvar_num( gHeCost ) );
    menu_additem( menu, szText, "1", 0 );
    
    // Menu item 2
    formatex( szText, charsmax( szText ), "%L", id, "DRSHOP_ITEM_2", get_pcvar_num( gBothGrenadesCost ) );
    menu_additem( menu, szText, "2", 0 );
    
    // Menu item 3
    formatex( szText, charsmax( szText ), "%L", id, "DRSHOP_ITEM_3", get_pcvar_num( gSilentCost ) );
    menu_additem( menu, szText, "3", 0 );
    
    // Menu item 4
    formatex( szText, charsmax( szText ), "%L", id, "DRSHOP_ITEM_4", get_pcvar_num( gHealthPointCvar ), get_pcvar_num( gHealthCost ) );
    menu_additem( menu, szText, "4", 0 );
    
    // Menu item 5
    formatex( szText, charsmax( szText ), "%L", id, "DRSHOP_ITEM_5", get_pcvar_num( gArmorPointCvar ), get_pcvar_num( gArmorCost ) );
    menu_additem( menu, szText, "5", 0 );
    
    // Menu item 6
    formatex( szText, charsmax( szText ), "%L", id, "DRSHOP_ITEM_6", get_pcvar_num( gSpeedCost ) );
    menu_additem( menu, szText, "6", 0 );
    
    // Menu item 7
    formatex( szText, charsmax( szText ), "%L", id, "DRSHOP_ITEM_7", get_pcvar_num( gGravityCost ) );
    menu_additem( menu, szText, "7", 0 );
    
    // Menu item 8
    formatex( szText, charsmax( szText ), "%L", id, "DRSHOP_ITEM_8", get_pcvar_num( gInvisPercent ), get_pcvar_num( gInvisCost ) );
    menu_additem( menu, szText, "8", 0 );
    
    // Menu item 9
    formatex( szText, charsmax( szText ), "%L", id, "DRSHOP_ITEM_9", get_pcvar_num( gNoclipTime ), get_pcvar_num( gNoclipCost ) );
    menu_additem( menu, szText, "9", 0 );
    
    // Menu item 10
    formatex( szText, charsmax( szText ), "%L", id, "DRSHOP_ITEM_10", get_pcvar_num( gJetTime ), get_pcvar_num( gJetPackCost ) );
    menu_additem( menu, szText, "10", 0 );
    
    // Menu item 11
    formatex( szText, charsmax( szText ), "%L", id, "DRSHOP_ITEM_11", get_pcvar_num( gDeagleCost ) );
    menu_additem( menu, szText, "11", 0 );
    
    // Menu item 12
    formatex( szText, charsmax( szText ), "%L", id, "DRSHOP_ITEM_12", get_pcvar_num( gLongJumpTime ), get_pcvar_num( gLongJumpCost ) );
    menu_additem( menu, szText, "12", 0 );
    
    // Menu item 13
    formatex( szText, charsmax( szText ), "%L", id, "DRSHOP_ITEM_13", get_pcvar_num( gGlowCost ) );
    menu_additem( menu, szText, "13", 0 );
    
    // Menu item 14
    formatex( szText, charsmax( szText ), "%L", id, "DRSHOP_ITEM_14", get_pcvar_num( gNvgCost ) );
    menu_additem( menu, szText, "14", 0 );
    
    menu_setprop( menu, MPROP_EXIT, MEXIT_ALL );
    
    // Show the menu, with current page 0
    menu_display( id, menu, 0 );

    return PLUGIN_CONTINUE;
}

// Menu commands
public shop_handler( id, menu, item )
{
    // If key is 0, let's close the menu
    if( item == MENU_EXIT )
    {
        menu_destroy( menu );
        return PLUGIN_HANDLED;
    }
    
    // Getting the menu information
    new data[ 6 ], iName[ 64 ], access, callback;
    menu_item_getinfo( menu, item, access, data, charsmax( data ), iName, charsmax( iName ), callback );

    // Get menu keys
    new key = str_to_num( data );
    
    // Here we find the player points
    new money = fm_get_user_money(id);
    g_Saved_Money[id] = money;
    
    switch( key )
    {
        // Menu item 1
        case 1:
        {
            // If already has item, show a damn print and return
            if( HasHe[ id ] )
            {
                allready_have( id );
                return PLUGIN_HANDLED;
            }
            
            // If player does not have enough points, show a print and return
            if( money < get_pcvar_num( gHeCost ) )
            {
                dont_have( id );
                return PLUGIN_HANDLED;
            }
            
            // Let's give the item, and do some stuff
            give_item( id, "weapon_hegrenade" );
            
            client_print( id, print_chat, "[Deathrun Shop] %L", id, "DRSHOP_GRENADE_ITEM" );
            HasHe[ id ] = true;
            
            fm_set_user_money(id, money - get_pcvar_num(gHeCost));
            emit_sound( id, CHAN_ITEM, PICKUP_SND, VOL_NORM , ATTN_NORM , 0 , PITCH_NORM );
            menu_display( id, menu, 0 );
        }
        
        // Menu item 2
        case 2:
        {
            // If already has item, show a damn print and return
            if( HasBothGren[ id ] )
            {
                allready_have( id );
                return PLUGIN_HANDLED;
            }
            
            // If player does not have enough points, show a print and return
            if( money < get_pcvar_num( gBothGrenadesCost ) )
            {
                dont_have( id );
                return PLUGIN_HANDLED;
            }
            
            // Let's give the item, and do some stuff
            give_item( id, "weapon_hegrenade" );
            give_item( id, "weapon_flashbang" );
            give_item( id, "weapon_flashbang" );
            
            client_print( id, print_chat, "[Deathrun Shop] %L", id, "DRSHOP_BOTHGREN_ITEM" );
            HasBothGren[ id ] = true;
            
            fm_set_user_money(id, money - get_pcvar_num(gBothGrenadesCost));
            emit_sound( id, CHAN_ITEM, PICKUP_SND, VOL_NORM , ATTN_NORM , 0 , PITCH_NORM );
            menu_display( id, menu, 0 );
        }
        
        // Menu item 3
        case 3:
        {
            // If already has item, show a damn print and return
            if( HasSilent[ id ] )
            {
                allready_have( id );
                return PLUGIN_HANDLED;
            }
            
            // If player does not have enough points, show a print and return
            if( money < get_pcvar_num( gSilentCost ) )
            {
                dont_have( id );
                return PLUGIN_HANDLED;
            }    
            
            // Let's give the item, and do some stuff
            set_user_footsteps( id, 1 );
            
            client_print( id, print_chat, "[Deathrun Shop] %L", id, "DRSHOP_SILENTWALK_ITEM" );
            HasSilent[ id ] = true;
            
            fm_set_user_money(id, money - get_pcvar_num(gSilentCost));
            emit_sound( id, CHAN_ITEM, PICKUP_SND, VOL_NORM , ATTN_NORM , 0 , PITCH_NORM );
            menu_display( id, menu, 0 );
        }
        
        // Menu item 4
        case 4:
        {
            // If already has item, show a damn print and return
            if( HasHealth[ id ] )
            {
                allready_have( id );
                return PLUGIN_HANDLED;
            }
            
            // If player does not have enough points, show a print and return
            if( money < get_pcvar_num( gHealthCost ) )
            {
                dont_have( id );
                return PLUGIN_HANDLED;
            }
            
            // Let's give the item, and do some stuff
            set_user_health( id, get_user_health( id ) + get_pcvar_num( gHealthPointCvar ) );
            
            client_print( id, print_chat, "[Deathrun Shop] %L", id, "DRSHOP_HEALTH_ITEM", get_pcvar_num( gHealthPointCvar ) );
            HasHealth[ id ] = true;
            
            fm_set_user_money(id, money - get_pcvar_num(gHealthPointCvar));
            emit_sound( id, CHAN_ITEM, HEALTH_SOUND, VOL_NORM , ATTN_NORM , 0 , PITCH_NORM );
            menu_display( id, menu, 0 );
        }
        
        // Menu item 5
        case 5:
        {
            // If already has item, show a damn print and return
            if( HasArmor[ id ] )
            {
                allready_have( id );
                return PLUGIN_HANDLED;
            }
            
            // If player does not have enough points, show a print and return
            if( money < get_pcvar_num( gArmorCost ) )
            {
                dont_have( id );
                return PLUGIN_HANDLED;
            }
            
            // Let's give the item, and do some stuff
            set_user_armor( id, get_user_armor( id ) + get_pcvar_num( gArmorPointCvar ) );
            
            client_print( id, print_chat, "[Deathrun Shop] %L", id, "DRSHOP_ARMOR_ITEM", get_pcvar_num( gArmorPointCvar ) );    
            HasArmor[ id ] = true;
            
            fm_set_user_money(id, money - get_pcvar_num(gArmorPointCvar));
            emit_sound( id, CHAN_ITEM, ARMOR_SOUND, VOL_NORM , ATTN_NORM , 0 , PITCH_NORM );
            menu_display( id, menu, 0 );
        }
        
        // Menu item 6
        case 6:
        {
            // If already has item, show a damn print and return
            if( HasSpeed[ id ] )
            {
                allready_have( id );
                return PLUGIN_HANDLED;
            }
            
            // If player does not have enough points, show a print and return
            if( money < get_pcvar_num( gSpeedCost ) )
            {
                dont_have( id );
                return PLUGIN_HANDLED;
            }
            
            // Let's give the item, and do some stuff
            set_user_maxspeed( id, get_pcvar_float( gSpeedCvar ) );
            
            client_print( id, print_chat, "[Deathrun Shop] %L", id, "DRSHOP_SPEED_ITEM" );
            HasSpeed[ id ] = true;
            
            fm_set_user_money(id, money - get_pcvar_num(gSpeedCost));
            emit_sound( id, CHAN_ITEM, PICKUP_SND, VOL_NORM , ATTN_NORM , 0 , PITCH_NORM );
            menu_display( id, menu, 0 );
        }
        
        // Menu item 7
        case 7:
        {
            // If already has item, show a damn print and return
            if( HasGravity[ id ] )
            {
                allready_have( id );
                return PLUGIN_HANDLED;
            }
            
            // If player does not have enough points, show a print and return
            if( money < get_pcvar_num( gGravityCost ) )
            {
                dont_have( id );
                return PLUGIN_HANDLED;
            }
            
            // Let's give the item, and do some stuff
            set_user_gravity( id, get_pcvar_float( gGravityCvar ) );
            
            client_print( id, print_chat, "[Deathrun Shop] %L", id, "DRSHOP_GRAVITY_ITEM" );
            HasGravity[ id ] = true;
            
            fm_set_user_money(id, money - get_pcvar_num(gGravityCost));
            emit_sound( id, CHAN_ITEM, PICKUP_SND, VOL_NORM , ATTN_NORM , 0 , PITCH_NORM );
            menu_display( id, menu, 0 );
        }
        
        // Menu item 8
        case 8:
        {
            // If already has item, show a damn print and return
            if( HasInvis[ id ] )
            {
                allready_have( id );
                return PLUGIN_HANDLED;
            }
            
            if( get_user_team( id ) == 2 )
            {
                client_print( id, print_chat, "[Deathrun Shop] %L", id, "DRSHOP_ONLY_T" );
                return PLUGIN_HANDLED;
            }
        
            // If player does not have enough points, show a print and return
            if( money < get_pcvar_num( gInvisCost ) )
            {
                dont_have( id );
                return PLUGIN_HANDLED;
            }
            
            // Let's give the item, and do some stuff
            set_user_rendering( id, kRenderFxNone, 0, 0, 0, kRenderTransAlpha, get_pcvar_num( gInvisPercent ) );
            
            client_print( id, print_chat, "[Deathrun Shop] %L", id, "DRSHOP_INVISIBILITY_ITEM" );
            HasInvis[ id ] = true;
            
            fm_set_user_money(id, money - get_pcvar_num(gInvisCost));
            emit_sound( id, CHAN_ITEM, CLOACK_SOUND, VOL_NORM , ATTN_NORM , 0 , PITCH_NORM );
            menu_display( id, menu, 1 );
        }
        
        // Menu item 9
        case 9:
        {
            // If already has item, show a damn print and return
            if( HasNoclip[ id ] )
            {
                allready_have( id );
                return PLUGIN_HANDLED;
            }
        
            // If player does not have enough points, show a print and return
            if( money < get_pcvar_num( gNoclipCost ) )
            {
                dont_have( id );
                return PLUGIN_HANDLED;
            }
            
            // Let's give the item, and do some stuff
            set_task( float( get_pcvar_num( gNoclipTime ) ), "remove_noclip", id );
            set_user_noclip( id, 1 );
            
            client_print( id, print_chat, "[Deathrun Shop] %L", id, "DRSHOP_NOCLIP_ITEM" );
            HasNoclip[ id ] = true;
            
            fm_set_user_money(id, money - get_pcvar_num(gNoclipCost));
            emit_sound( id, CHAN_ITEM, PICKUP_SND, VOL_NORM , ATTN_NORM , 0 , PITCH_NORM );
            menu_display( id, menu, 1 );
        }
        
        // Menu item 10
        case 10:
        {
            // If already has item, show a damn print and return
            if( HasJet[ id ] )
            {
                allready_have( id );
                return PLUGIN_HANDLED;
            }
        
            // If player does not have enough points, show a print and return
            if( money < get_pcvar_num( gJetPackCost ) )
            {
                dont_have( id );
                return PLUGIN_HANDLED;
            }
            
            // Let's give the item, and do some stuff
            set_task( float( get_pcvar_num( gJetTime ) ), "remove_jetpack", id );
            
            client_print( id, print_chat, "[Deathrun Shop] %L", id, "DRSHOP_JETPACK_ITEM" );
            HasJet[ id ] = true;
            
            fm_set_user_money(id, money - get_pcvar_num(gJetPackCost));
            emit_sound( id, CHAN_ITEM, PICKUP_SND, VOL_NORM , ATTN_NORM , 0 , PITCH_NORM );
            menu_display( id, menu, 1 );
        }
        
        // Menu item 11
        case 11:
        {
            // If already has item, show a damn print and return
            if( HasDeagle[ id ] || user_has_weapon( id, CSW_DEAGLE ) )
            {
                allready_have( id );
                return PLUGIN_HANDLED;
            }
        
            // If player does not have enough points, show a print and return
            if( money < get_pcvar_num( gDeagleCost ) )
            {
                dont_have( id );
                return PLUGIN_HANDLED;
            }
            
            // Let's give the item, and do some stuff
            strip_user_weapons( id );
            give_item( id, "weapon_knife" );
            give_item( id, "weapon_deagle" );
            
            client_print( id, print_chat, "[Deathrun Shop] %L", id, "DRSHOP_DEAGLE_ITEM" );
            HasDeagle[ id ] = true;
            
            fm_set_user_money(id, money - get_pcvar_num(gDeagleCost));
            emit_sound( id, CHAN_ITEM, PICKUP_SND, VOL_NORM , ATTN_NORM , 0 , PITCH_NORM );
            menu_display( id, menu, 1 );
        }
        
        // Menu item 12
        case 12:
        {
            // If already has item, show a damn print and return
            if( HasLongJump[ id ] )
            {
                allready_have( id );
                return PLUGIN_HANDLED;
            }
        
            // If player does not have enough points, show a print and return
            if( money < get_pcvar_num( gLongJumpCost ) )
            {
                dont_have( id );
                return PLUGIN_HANDLED;
            }
            
            // Let's give the item, and do some stuff
            // Setting the temporary long jump
            set_temporary_longjump( id );
            
            client_print( id, print_chat, "[Deathrun Shop] %L", id, "DRSHOP_LJ_ITEM" );
            HasLongJump[ id ] = true;
            
            fm_set_user_money(id, money - get_pcvar_num(gLongJumpCost));
            emit_sound( id, CHAN_ITEM, LJ_SOUND, VOL_NORM , ATTN_NORM , 0 , PITCH_NORM );
            menu_display( id, menu, 1 );
        }
        
        // Menu item 13
        case 13:
        {
            // If already has item, show a damn print and return
            if( HasGlow[ id ] )
            {
                allready_have( id );
                return PLUGIN_HANDLED;
            }
        
            // If player does not have enough points, show a print and return
            if( money < get_pcvar_num( gGlowCost ) )
            {
                dont_have( id );
                return PLUGIN_HANDLED;
            }
            
            // Let's give the item, and do some stuff
            set_user_rendering( id, kRenderFxGlowShell, random( 256 ), random( 256 ), random( 256 ), kRenderNormal, random( 256 ) );
            
            client_print( id, print_chat, "[Deathrun Shop] %L", id, "DRSHOP_GLOW_ITEM" );
            HasGlow[ id ] = true;
            
            fm_set_user_money(id, money - get_pcvar_num(gGlowCost));
            emit_sound( id, CHAN_ITEM, PICKUP_SND, VOL_NORM , ATTN_NORM , 0 , PITCH_NORM );
            menu_display( id, menu, 1 );
        }
        
        // Menu item 13
        case 14:
        {
            // If already has item, show a damn print and return
            if( HasNVG[ id ] || get_user_nvg( id ) )
            {
                allready_have( id );
                return PLUGIN_HANDLED;
            }
        
            // If player does not have enough points, show a print and return
            if( money < get_pcvar_num( gNvgCost ) )
            {
                dont_have( id );
                return PLUGIN_HANDLED;
            }
            
            // Let's give the item, and do some stuff
            set_user_nvg( id, 1 );
            
            client_print( id, print_chat, "[Deathrun Shop] %L", id, "DRSHOP_NVG_ITEM" );
            HasNVG[ id ] = true;
            
            fm_set_user_money(id, money - get_pcvar_num(gNvgCost));
            emit_sound( id, CHAN_ITEM, PICKUP_SND, VOL_NORM , ATTN_NORM , 0 , PITCH_NORM );
            menu_display( id, menu, 1 );
        }
    }
    
    return PLUGIN_HANDLED;
}

// Command for setting points | admin only
public cmdSetPoints( id, level, cid )
{
    // If user doesn't have acces to command, return
    if( !cmd_access( id, level, cid, 2 ) || !get_pcvar_num( gDrShopOn ) )
    {
        return PLUGIN_HANDLED;
    }
    
    // Need to read the first argument
    new argument[ 32 ];
       read_argv( 1, argument, charsmax( argument ) );

    // Need to read second argument
    new give_points[ 5 ];
    read_argv( 2, give_points, charsmax( give_points ) );

    // We are getting the gift from second argument
    new gift = str_to_num( give_points );
    
    new iPlayer[ 32 ], iNum, all;
    get_players( iPlayer, iNum, "c" );

    // Lets see if argument 1 is @all
    if( equal( argument, "@all" ) )
    {
        for( new i; i < iNum; i++ )
        {
            // Find the index
            all = iPlayer[ i ];
            
            // Set points to all
            new i_Money;
            i_Money = fm_get_user_money(all);
            fm_set_user_money(all, i_Money + gift);
            
            // Show a print in chat
            get_user_name( id, gName, charsmax( gName ) );
            client_print( 0, print_chat, "[Deathrun Shop] %L", LANG_PLAYER, "DRSHOP_SHOW_ALLCMD", gName, gift );
        }
    }
            
    else
    {
        // Now, we find the target
        new player = cmd_target( id, argument, 10 );

        // If is not a valid target, return
        if( !player )
        {
               return PLUGIN_HANDLED;
        }
    

        // Get admin, and target name/
        new TargetName[ 32 char ];
        get_user_name( player, TargetName, charsmax( TargetName ) );
        get_user_name( id, gName, charsmax( gName ) );    
    
        // Setting target points
        new i_Money;
        i_Money = fm_get_user_money(player);
        fm_set_user_money(player, i_Money + gift);
        client_print( 0, print_chat, "[Deathrun Shop] %L", LANG_PLAYER, "DRSHOP_SHOW_CMD", gName, gift, TargetName );
    }

    return PLUGIN_HANDLED;
}

// Command for reseting points | admin only
public cmdResetPoints( id, level, cid )
{
    // If user doesn't have acces to command, return
    if( !cmd_access( id, level, cid, 2 ) || !get_pcvar_num( gDrShopOn ) )
    {
        return PLUGIN_HANDLED;
    }
    
    // Need to read the first argument
    new argument[ 32 ];
       read_argv( 1, argument, charsmax( argument ) );
    
    new iPlayer[ 32 ], iNum, all;
    get_players( iPlayer, iNum, "c" );

    // Lets see if argument 1 is @all
    if( equal( argument, "@all" ) )
    {
        for( new i; i < iNum; i++ )
        {
            // Find the index
            all = iPlayer[ i ];
            
            // Set points to all
            fm_set_user_money(all, 0, 1);
            
            // Show a print in chat
            get_user_name( id, gName, charsmax( gName ) );
            client_print( 0, print_chat, "[Deathrun Shop] %L", LANG_PLAYER, "DRSHOP_SHOWRESET_ALLCMD", gName );
        }
    }
            
    else
    {
        // Now, we find the target
        new player = cmd_target( id, argument, 10 );

        // If is not a valid target, return
        if( !player )
        {
               return PLUGIN_HANDLED;
        }
    

        // Get admin, and target name
        new TargetName[ 32 char ];
        get_user_name( player, TargetName, charsmax( TargetName ) );
        get_user_name( id, gName, charsmax( gName ) );    
    
        // Setting target points
        fm_set_user_money(all, 0, 1);
        client_print( 0, print_chat, "[Deathrun Shop] %L", LANG_PLAYER, "DRSHOP_SHOWRESET_CMD", gName, TargetName );
    }

    return PLUGIN_HANDLED;
}
    
// We need to find if player has performed a jump, and set some velocity
public bacon_playerJumping( id )
{
    // If plugin is on, and user has jetpack item
    if( get_pcvar_num( gDrShopOn ) != 0 && HasJet[ id ] )
    {
        // Get user origins from feet
        new iOrigin[ 3 ];
        get_user_origin( id, iOrigin, 0 );
        
        // Modify origin a bit
        iOrigin[ 2 ] -= 20;
        
        // Get player velocity
        new Float:fVelocity[ 3 ];
        pev( id, pev_velocity, fVelocity );

        // Modify velocity a bit
        fVelocity[ 2 ] += 93;
        
        // Set the player velocity and add a flame effect, jetpack style
        set_pev( id, pev_velocity, fVelocity );
        create_flame( iOrigin );
    }
}    

// We need to check is player has changed his weapon
public HookCurWeapon( id )
{
    // If plugin is on, and user has speed item, let's set the speed again
    if( get_pcvar_num( gDrShopOn ) != 0 && HasSpeed[ id ] )
    {
        set_user_maxspeed( id, get_pcvar_float( gSpeedCvar ) );
    }
}

// Command for show points
public ShowPoints( id )
{
    // Set a hud message
    set_hudmessage( 255, 42, 212, 0.03, 0.86, 2, 6.0, 5.0 );
    
    // We show player points on hud
    show_hudmessage( id, "[Deathrun Shop] %L", id, "DRSHOP_POINTS_INFO", fm_get_user_money(id) );
    
    // We show player points on chat
    client_print( id, print_chat, "[Deathrun Shop] %L", id, "DRSHOP_POINTS_INFO", fm_get_user_money(id) );
    
    return PLUGIN_CONTINUE;
}

// Here we show player hud information about this god damn shop
public ShowPlayerInfo( id )
{
    // Set a hud message
    set_hudmessage( 0, 189, 255, -1.0, 0.82, 0, 6.0, 12.0 );
    
    // Now we show the info message in hud channel
    show_hudmessage( id, "%L", id, "DRSHOP_HUD_INFO" );
}

// If player has suicided by console
public forward_kill( id )
{
    // Check if plugin is on, and user is alive
    if( get_pcvar_num( gDrShopOn ) == 1 && is_user_alive( id ) )
    {
        // Set player points with suicide cvar
        client_print( id, print_chat, "[Deathrun Shop] %L", id, "DRSHOP_SHOW_LOOSER", get_pcvar_num( gSuiciderPointsCvar ) );
        gKillerPoints[ id ] -= get_pcvar_num( gSuiciderPointsCvar );
    }
}

// Event for round start */        
public logevent_round_start()
{
    // If plugin is on...
    if( get_pcvar_num( gDrShopOn ) == 1 )
    {
        // I used this native because with get_maxplayers will recieve a damn error with invalid player id..
        // This is good because we can skip the damn bots
        new iPlayers[ 32 ], iNum, i, id;
        get_players( iPlayers, iNum, "c" );
        
        for( i = 0; i < iNum; i++ )
        {
            // Find the index
            id = iPlayers[ i ];
            
            // Reseting items
            HasHe[ id ] = false;
            HasBothGren[ id ] = false;
            HasSilent[ id ] = false;
            HasHealth[ id ] = false;
            HasArmor[ id] = false;
            HasSpeed[ id ] = false;
            HasGravity[ id ] = false;
            HasInvis[ id ] = false;
            HasNoclip[ id ] = false;
            HasJet[ id ] = false;
            HasDeagle[ id ] = false;
            HasLongJump[ id ] = false;
            HasGlow[ id ] = false;
            HasNVG[ id ] = false;
            
            set_user_gravity( id, 1.0 );    
            set_user_maxspeed( id, 0.0 );
            set_user_footsteps( id, 0 );
            set_user_noclip( id, 0 );
            set_user_rendering( id );
            set_user_nvg( id, 0 );
            remove_user_nvg( id );
            remove_task( id );
        }
    }
}

// Event when player died
public Hook_Deathmessage()
{
    // If plugin is on...
    if( get_pcvar_num( gDrShopOn ) == 1 )
    {
        // Get the killer and attacker
        new killer = read_data( 1 );
        new victim = read_data( 2 );

        // If player has died with world / trigger_hurt
        if( killer == victim )
        {
            return PLUGIN_HANDLED;
        }
        
        // Setting killer points when killed a enemy
        gKillerPoints[ killer ] += get_pcvar_num( gKillerPointsCvar );
    
        // Reseting items
        HasHe[ victim ] = false;
        HasBothGren[ victim ] = false;
        HasSilent[ victim ] = false;
        HasHealth[ victim ] = false;
        HasArmor[ victim ] = false;
        HasSpeed[ victim ] = false;
        HasGravity[ victim ] = false;
        HasInvis[ victim ] = false;
        HasNoclip[ victim ] = false;
        HasJet[ victim ] = false;
        HasDeagle[ victim ] = false;
        HasLongJump[ victim ] = false;
        HasGlow[ victim ] = false;
        HasNVG[ victim ] = false;
        
        set_user_gravity( victim, 1.0 );    
        set_user_maxspeed( victim, 0.0 );
        set_user_footsteps( victim, 0 );
        set_user_noclip( victim, 0 );
        set_user_rendering( victim );
        set_user_nvg( victim, 0 );
        remove_user_nvg( victim );
        remove_task( victim );
    }
    
    return PLUGIN_CONTINUE;
}

// Now we need to remove the noclip
public remove_noclip( id )
{
    HasNoclip[ id ] = false;
    set_user_noclip( id, 0 );
    client_print( id, print_chat, "[Deathrun Shop] %L", id, "DRSHOP_NOCLIP_OFF", get_pcvar_num( gNoclipTime ) );
}

// Now we need to remove the jetpack
public remove_jetpack( id )
{
    HasJet[ id ] = false;
    client_print( id, print_chat, "[Deathrun Shop] %L", id, "DRSHOP_JETPACK_OFF", get_pcvar_num( gJetTime ) );
}

// Now we need to remove the longjump
public remove_lj( index )
{
    HasLongJump[ index ] = false;
    engfunc( EngFunc_SetPhysicsKeyValue, index, "slj", "0" );
    client_print( index, print_chat, "[Deathrun Shop] %L", index, "DRSHOP_LJ_OFF", get_pcvar_num( gLongJumpTime ) );
}

// Usefull stocks on this plugin
// Display a message in chat if player already have the item
stock allready_have( id )
{
    client_print( id, print_chat, "[Deathrun Shop] %L", id, "DRSHOP_ALLREADY_HAVE" );
}    

// Display a message in chat if player don't have enough points
stock dont_have( id )
{
    client_print( id, print_chat, "[Deathrun Shop] %L", id, "DRSHOP_DONTHAVE_POINTS" );
}    

// Saving player points
stock save_client_points( index )
{
    // Open the vault file
    gVault = nvault_open( "DeathrunShop_SavedPoints" );
    
    // If vault return -1, lets stop this shit
    if( gVault == INVALID_HANDLE )
    {
        set_fail_state( "[Deathrun Shop] nValut ERROR: =-> Invalid-Handle" );
    }
    
    // Get the player steamid
    get_user_authid( index, gSteamID, charsmax( gSteamID ) );
    
    // Setting stuff on vault file, and close the file
    formatex( vKey, charsmax( vKey ), "%sPOINTS", gSteamID );
    formatex( vData, charsmax( vData ), "%d", gKillerPoints[ index ] );
    nvault_set( gVault, vKey, vData );
    nvault_close( gVault );
}

// Loading client points
stock load_client_points( index )
{
    // Open the vault file
    gVault = nvault_open( "DeathrunShop_SavedPoints" );
    
    // If vault return -1, lets stop this shit
    if( gVault == INVALID_HANDLE )
    {
        set_fail_state( "[Deathrun Shop] nValut ERROR: =-> Invalid-Handle" );
    }
    
    // Get the player steamid
    get_user_authid( index, gSteamID, charsmax( gSteamID ) );
    
    // Get the player points, then, close the nvault vile
    formatex( vKey, charsmax( vKey ), "%sPOINTS", gSteamID );
    gKillerPoints[ index ] = nvault_get( gVault, vKey );
    nvault_close( gVault );
}

// Flame jetpack effect stock
stock create_flame( origin[ 3 ] )
{
    message_begin( MSG_PVS, SVC_TEMPENTITY, origin );
    write_byte( TE_SPRITE );
    write_coord( origin[ 0 ] );
    write_coord( origin[ 1 ] );
    write_coord( origin[ 2 ] );
    write_short( gJetSprite );
    write_byte( 3 );
    write_byte( 99 );
    message_end();
}

// Setting temporary longjump stock
stock set_temporary_longjump( index )
{
    // Let's show to player the jetpack item on hud
    message_begin( MSG_ONE_UNRELIABLE, gMsgItemPickup, _, index );
    write_string( "item_longjump" );
    message_end();

    // Setting the jetpack on
    engfunc( EngFunc_SetPhysicsKeyValue, index, "slj", "1" );
    
    // Setting the time before jetpack will go off
    set_task( float( get_pcvar_num( gLongJumpTime ) ), "remove_lj", index );
}

// Stock for setting user nightvision */
// This stock is more good than cstrike native( give errors )
stock set_user_nvg( index, nvgoggles = 1 )
{
    if( nvgoggles )
    {
        set_pdata_int( index, m_iNvg, get_pdata_int( index, m_iNvg ) | HAS_NVGS );
    }

    else
    {
        set_pdata_int( index, m_iNvg, get_pdata_int( index, m_iNvg ) & ~HAS_NVGS );
    }
}

// Stock for removing turned on nightvision from players. Let's call, force remove nvg
stock remove_user_nvg( index )
{
    new iNvgs = get_pdata_int( index, m_iNvg, m_iLinuxDiff );

    if( !iNvgs )
    {
        return;
    }

    if( iNvgs & USES_NVGS )
    {
        emit_sound( index, CHAN_ITEM, SOUND_NVGOFF, VOL_NORM, ATTN_NORM, 0, PITCH_NORM );

        emessage_begin( MSG_ONE_UNRELIABLE, gMessageNVG, _, index );
        ewrite_byte( 0 );
        emessage_end();
    }

    set_pdata_int( index, m_iNvg, 0, m_iLinuxDiff );
}  
stock fm_get_user_money( index )
{
    new money = get_pdata_int( index, OFFSET_MONEY );
    return money;
}

stock fm_set_user_money( index, money, flash = 1 )
{
    set_pdata_int( index, OFFSET_MONEY, money );
    fm_set_money( index, money, flash );
    return 1;
}
stock fm_set_money( index, money, flash )
{
    message_begin( MSG_ONE_UNRELIABLE, gMsgMoney, {0, 0, 0}, index );
    write_long( money );
    write_byte( flash ? 1 : 0 );
    message_end();
}
public Spawn(id)
{
    // Если кол-во денег больше 0, то выполняем код
    if (gKillerPoints[id] > 0)
    {
        // Даем игроку деньги
        fm_set_user_money(id, gKillerPoints[id]);
        // Обнуляем переменную, чтобы при следующих распавнах ему не выдавались деньги снова
        gKillerPoints[id] = 0;
    }

    g_Saved_Money[id] = fm_get_user_money(id);
}

Большое спасибо за внимание.
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
Статус пользователя STR@TEG
сообщение 8.2.2011, 22:59
Сообщение #12
Стаж: 16 лет

Сообщений: 4186
Благодарностей: 1763
Полезность: 837

my_world243,
Эту строку:
Код
client_print( id, print_chat, "[Deathrun Shop] %L", id, "DRSHOP_BOTHGREN_ITEM" );
Заменяешь на эту:
Код
ColorChat(id, RED, "[Deathrun Shop] ^x01%L", id, "DRSHOP_BOTHGREN_ITEM")

Добавляешь в начало плагина там где:
Код
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <nvault>
#include <hamsandwich>
#include <fakemeta>
Это:
Код
#include <colorchat>

Копируешь инклуд colorchat.inc в папку include.
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
Поблагодарили 1 раз
   + Цитировать сообщение
Статус пользователя my_world243
сообщение 10.2.2011, 13:30
Сообщение #13
Стаж: 15 лет

Сообщений: 29
Благодарностей: 1
Полезность: 28

Все получилось. Спасибо БОЛЬШОЕ
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
  Тема закрытаНачать новую тему
 
0 пользователей и 1 гостей читают эту тему: