Менял функции на мапс но не компилиться. что то я упускаю. скажите какие функции менять? Хотелось бы не каждый раунд проверять а в конце карты.
Код:
/**
* Use Advanced Experience System points as bonus
*/
#define USE_AES
/**
* Use Advanced Experience System points as bonus
*/
#define ALLOW_DISABLE
#include <amxmodx>
#include <reapi>
#if defined USE_AES
#include <aes_v>
#endif
#define clearPlayer(%0) arrayset(Players[%0], 0, sizeof(Players[]))
#define eventBit(%0) (1 << _:%0)
new const Titles[2][3][] = {
{"BPR_KILL_1", "BPR_KILL_2", "BPR_KILL_3"},
{"BPR_HS_1", "BPR_HS_2", "BPR_HS_3"}
}
const ROUND_EVENTS = eventBit(ROUND_GAME_COMMENCE) | eventBit(ROUND_GAME_RESTART) | eventBit(ROUND_GAME_OVER);
new HudSync;
new MoneyBonus, NameNewLine, ShowInfo, ShowAll;
#if defined USE_AES
new Float:AesExp, AesBonus;
#endif
enum _:Player {
PlayerKills,
PlayerDmg,
PlayerHS
}
new Players[MAX_CLIENTS + 1][Player];
#if defined ALLOW_DISABLE
new bool:PlayersHudEnabled[MAX_PLAYERS + 1];
#endif
public plugin_init() {
register_plugin("[ReAPI] Best player of the round", "1.1.2", "F@nt0M");
register_dictionary("best_player_of_the_round.txt");
RegisterHookChain(RG_CBasePlayer_TakeDamage, "CBasePlayer_TakeDamage_Post", true);
RegisterHookChain(RG_CBasePlayer_Killed, "CBasePlayer_Killed_Post", true);
RegisterHookChain(RG_RoundEnd, "RoundEnd_Post", true);
#if defined ALLOW_DISABLE
register_clcmd("say /bpr", "CmdToggle");
register_clcmd("say_team /bpr", "CmdToggle");
#endif
HudSync = CreateHudSyncObj();
bind_pcvar_num(create_cvar(
"bpr_money", "0", .has_min = true, .min_val = 0.0
), MoneyBonus);
#if defined USE_AES
bind_pcvar_float(create_cvar(
"bpr_aes_exp", "5", .has_min = true, .min_val = 0.0
), AesExp);
bind_pcvar_num(create_cvar(
"bpr_aes_bonus", "30", .has_min = true, .min_val = 0.0
), AesBonus);
#endif
bind_pcvar_num(create_cvar(
"bpr_name_newline", "1", .has_min = true, .min_val = 0.0, .has_max = true, .max_val = 1.0
), NameNewLine);
bind_pcvar_num(create_cvar(
"bpr_show_info", "1", .has_min = true, .min_val = 0.0, .has_max = true, .max_val = 2.0
), ShowInfo);
bind_pcvar_num(create_cvar(
"bpr_show_all", "1", .has_min = true, .min_val = 0.0, .has_max = true, .max_val = 1.0
), ShowAll);
}
public client_putinserver(id) {
clearPlayer(id);
#if defined ALLOW_DISABLE
PlayersHudEnabled[id] = !is_user_bot(id);
#endif
}
public client_disconnected(id) {
clearPlayer(id);
#if defined ALLOW_DISABLE
PlayersHudEnabled[id] = false;
#endif
}
#if defined ALLOW_DISABLE
public CmdToggle(id) {
PlayersHudEnabled[id] = !PlayersHudEnabled[id];
client_print_color(
id, print_team_default, "%l",
PlayersHudEnabled[id] ? "BPR_HUD_ENABLED" : "BPR_HUD_DISABLED"
);
}
#endif
public CBasePlayer_TakeDamage_Post(id, inflictor, attacker, Float:damage, damageType) {
if (
id == attacker ||
!is_user_connected(attacker) ||
!rg_is_player_can_takedamage(id, attacker) ||
(inflictor != attacker && ~damageType & DMG_GRENADE)
) {
return HC_CONTINUE;
}
Players[attacker][PlayerDmg] += floatround(damage);
return HC_CONTINUE;
}
public CBasePlayer_Killed_Post(id, attacker) {
if (
id == attacker ||
!is_user_connected(attacker) ||
!rg_is_player_can_takedamage(id, attacker)
) {
return HC_CONTINUE;
}
Players[attacker][PlayerKills]++;
if (get_member(id, m_LastHitGroup) == HIT_HEAD) {
Players[attacker][PlayerHS]++;
}
return HC_CONTINUE;
}
public RoundEnd_Post(WinStatus:status, ScenarioEventEndRound:event) {
if (eventBit(event) & ROUND_EVENTS == 0 && event != ROUND_NONE) {
set_task(1.0, "TaskRoundEnd");
} else {
for (new i = 1; i <= MaxClients; i++) {
clearPlayer(i);
}
}
}
public TaskRoundEnd() {
new players[MAX_CLIENTS], num;
get_players(players, num, "h");
if (num <= 0) {
return;
}
new maxId;
for (new i = 0, player; i < num; i++) {
player = players[i];
if (
Players[player][PlayerKills] > Players[maxId][PlayerKills] ||
(
Players[player][PlayerKills] == Players[maxId][PlayerKills] &&
Players[player][PlayerDmg] > Players[maxId][PlayerDmg]
)
) {
maxId = player;
}
}
if (maxId == 0) {
for (new i = 0; i < num; i++) {
clearPlayer(players[i]);
}
return;
}
new message[190], len;
if (MoneyBonus > 0) {
rg_add_account(maxId, MoneyBonus, AS_ADD, true);
len += formatex(message[len], charsmax(message) - len, "^1[^4%d $^1] ", MoneyBonus);
}
#if defined AES_MAX_LEVEL_LENGTH
if (AesExp > 0.0) {
aes_set_player_exp(maxId, aes_get_player_exp(maxId) + AesExp);
len += formatex(message[len], charsmax(message) - len, "^1[^4%0.0f EXP^1] ", AesExp);
}
if (AesBonus > 0) {
aes_set_player_bonus(maxId, aes_get_player_bonus(maxId) + AesBonus);
len += formatex(message[len], charsmax(message) - len, "^1[^4%d BONUS^1] ", AesBonus);
}
#endif
new name[MAX_NAME_LENGTH], num1, num2;
get_user_name(maxId, name, charsmax(name));
num1 = makeNumber(Players[maxId][PlayerKills]);
num2 = makeNumber(Players[maxId][PlayerHS]);
set_hudmessage(0, 255, 255, -1.0, 0.17, 0, .fxtime = 0.0, .holdtime = 5.0, .channel = 4);
for (new i = 0, player; i < num; i++) {
player = players[i];
if (player != maxId) {
clearPlayer(player);
}
if (!isHudEnabled(player)) {
continue;
}
SetGlobalTransTarget(player);
if (ShowInfo == 1) {
ShowSyncHudMsg(player, HudSync, "%l:%c%s^n%d %l, %d %l %l %d %l",
"BRP_MESSAGE", (NameNewLine ? "^n" : " "), name,
Players[maxId][PlayerKills], Titles[0][num1],
Players[maxId][PlayerHS], Titles[1][num2],
"BPR_AND", Players[maxId][PlayerDmg], "BPR_DMG"
);
} else if (ShowInfo == 2) {
ShowSyncHudMsg(player, HudSync, "%l:%c%s",
"BRP_MESSAGE", (NameNewLine ? "^n" : " "), name
);
}
if (len > 0) {
if (player == maxId) {
client_print_color(player, maxId, "%l %l", "BPR_PREFIX", "BPR_BONUS", message);
} else if (ShowAll) {
client_print_color(player, maxId, "%l %l", "BPR_PREFIX", "BPR_BONUS_ALL", name, message);
}
}
}
clearPlayer(maxId);
}
bool:isHudEnabled(const id) {
#if defined ALLOW_DISABLE
return PlayersHudEnabled[id];
#else
return !is_user_bot(id));
#endif
}
stock const Cases[] = {2, 0, 1, 1, 1, 2};
stock makeNumber(number) {
if (4 < (number % 100) < 20) {
return 2;
} else if ((number % 10) < 5) {
return Cases[number % 10];
} else {
return 2;
}
}