best players

Статус
В этой теме нельзя размещать новые ответы.
Сообщения
9
Реакции
3
Помог
1 раз(а)
Ошибка
// C:\Users\admin2\Desktop\Compiler 1.9.0\best_player_of_the_round.sma(172) : warning 209: function "CBasePlayer_TakeDamage" should return a value
// C:\Users\admin2\Desktop\Compiler 1.9.0\best_player_of_the_round.sma(174) : error 010: invalid function or declaration
// C:\Users\admin2\Desktop\Compiler 1.9.0\best_player_of_the_round.sma(175) : error 010: invalid function or declaration
// C:\Users\admin2\Desktop\Compiler 1.9.0\best_player_of_the_round.sma(178) : error 010: invalid function or declaration
// C:\Users\admin2\Desktop\Compiler 1.9.0\best_player_of_the_round.sma(180) : error 010: invalid function or declaration
// C:\Users\admin2\Desktop\Compiler 1.9.0\best_player_of_the_round.sma(184) : error 010: invalid function or declaration
Компилятор
Локальный
Amx Mod X
1.9.0
Исходный код
/**
*
* Name: Best player of the round
* Version: 0.61 (07.01.2018)
* Author: F@nt0M
* Thanks: Got Milk?, HoHoL, Safety1st
*
* Requirements: AmxModX 1.8.3 or higher, ReAPI
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/

/**
* Use Advanced Experience System points as bonus
*/
// #define USE_AES

#include <amxmodx>
#include <reapi>

#if defined USE_AES
#include <aes_v>
#endif

#define CheckBit(%1,%2) (%1 & (1 << (%2 & 31)))
#define SetBit(%1,%2) (%1 |= (1 << (%2 & 31)))
#define ClearBit(%1,%2) (%1 &= ~(1 << (%2 & 31)))
#define ToggleBit(%1,%2) (%1 ^= (1 << (%2 & 31)))
#define ResetBits(%1) (%1 &= 0)
#define FillBits(%1) (%1 &= ~0)

new const g_Cases[] = {2, 0, 1, 1, 1, 2};
new const g_Titles[2][3][] = {
{"BPR_KILL_1", "BPR_KILL_2", "BPR_KILL_3"},
{"BPR_HS_1", "BPR_HS_2", "BPR_HS_3"}
}

new g_HudSync;
new g_FriendlyFire = 0;
new g_ShowAll = 1;
new g_ShowInfo = 1;
new g_NameNewLine = 1;
new g_MoneyBonus = 200;
#if defined AES_MAX_LEVEL_LENGTH
new g_AesExp = 5;
new g_AesBonus = 1;
#endif
new g_HudEnabled;

enum _:PLAYER_DATA {
PLAYER_KILLS,
PLAYER_DMG,
PLAYER_HS
}

new g_PlayerData[MAX_CLIENTS + 1][PLAYER_DATA];

public plugin_init() {
register_plugin("[ReAPI] Best player of the round", "0.6", "F@nt0M");

register_dictionary("best_player_of_the_round.txt");

RegisterHookChain(RG_CSGameRules_RestartRound, "CSGameRules_RestartRound", 1);
RegisterHookChain(RG_RoundEnd, "RoundEnd", 1);
RegisterHookChain(RG_CBasePlayer_TakeDamage, "CBasePlayer_TakeDamage", 1);
RegisterHookChain(RG_CBasePlayer_Killed, "CBasePlayer_Killed", 1);

g_HudSync = CreateHudSyncObj();

new pcvar;

pcvar = register_cvar("bpr_money", "1000");
bind_pcvar_num(pcvar, g_MoneyBonus);

pcvar = register_cvar("bpr_show_all", "1");
bind_pcvar_num(pcvar, g_ShowAll);

pcvar = register_cvar("bpr_show_info", "1");
bind_pcvar_num(pcvar, g_ShowInfo);

pcvar = register_cvar("bpr_name_newline", "1");
bind_pcvar_num(pcvar, g_NameNewLine);

#if defined AES_MAX_LEVEL_LENGTH
pcvar = register_cvar("bpr_aes_exp", "5");
bind_pcvar_num(pcvar, g_AesExp);

pcvar = register_cvar("bpr_aes_bonus", "1");
bind_pcvar_num(pcvar, g_AesBonus);
#endif

pcvar = get_cvar_pointer("mp_friendlyfire");
bind_pcvar_num(pcvar, g_FriendlyFire);

register_clcmd("say /hud", "CmdToggle");
register_clcmd("say_team /hud", "CmdToggle");

FillBits(g_HudEnabled);
}

public OnConfigsExecuted() {
g_MoneyBonus = get_cvar_num("bpr_money");
g_ShowAll = get_cvar_num("bpr_show_all");
g_ShowInfo = get_cvar_num("bpr_show_info");
g_NameNewLine = get_cvar_num("bpr_name_newline");
#if defined AES_MAX_LEVEL_LENGTH
g_AesExp = get_cvar_num("bpr_aes_exp");
g_AesBonus = get_cvar_num("bpr_aes_bonus");
#endif
g_FriendlyFire = get_cvar_num("mp_friendlyfire");
}

public client_putinserver(id) {
arrayset(g_PlayerData[id], 0, PLAYER_DATA);
SetBit(g_HudEnabled, id);
}

public client_disconnected(id) {
arrayset(g_PlayerData[id], 0, PLAYER_DATA);
ClearBit(g_HudEnabled, id);
}

public CmdToggle(id) {
ToggleBit(g_HudEnabled, id);
if (CheckBit(g_HudEnabled, id)) {
client_print_color(id, print_team_default, "%L", id, "BPR_HUD_ENABLED");
} else {
client_print_color(id, print_team_default, "%L", id, "BPR_HUD_DISABLED");
}
}

public CSGameRules_RestartRound() {
for(new i = 0; i <= MAX_CLIENTS; i++) {
arrayset(g_PlayerData[i], 0, PLAYER_DATA);
}
}

public RoundEnd(WinStatus:status, ScenarioEventEndRound:event) {
#pragma unused status

if (event == ROUND_GAME_COMMENCE || event == ROUND_GAME_RESTART || event == ROUND_GAME_OVER) {
return HC_CONTINUE;
}

if (get_playersnum(0) <= 0) {
return HC_CONTINUE;
}

set_task(1.0, "TaskRoundEnd");

return HC_CONTINUE;
}

public CBasePlayer_TakeDamage(id, inflictor, attacker, Float:damage, damageType) {
if (id == attacker || attacker < 1 || attacker > MaxClients) {
return HC_CONTINUE;
}

if (rg_is_player_can_takedamage(id, attacker))
return HC_CONTINUE;
}

if (inflictor != attacker && ~damageType & DMG_GRENADE) {
return HC_CONTINUE;
}

g_PlayerData[attacker][PLAYER_DMG] += floatround(damage);

if( get_member(id, m_LastHitGroup) == HIT_HEAD) {
g_PlayerData[attacker][PLAYER_HS]++;
}

return HC_CONTINUE;
}

public CBasePlayer_Killed(id, attacker) {
if (id == attacker || attacker < 1 || attacker > MaxClients) {
return HC_CONTINUE;
}

if (g_FriendlyFire != 0 && get_member(id, m_iTeam) == get_member(attacker, m_iTeam)) {
return HC_CONTINUE;
}

g_PlayerData[attacker][PLAYER_KILLS]++;

return HC_CONTINUE;
}

public TaskRoundEnd(id) {
new players[MAX_CLIENTS], num, player, i;
new maxId, maxKills, maxDmg;
new name[MAX_NAME_LENGTH], num1, num2;

new message[190], len;

get_players(players, num, "h");
for (i = 0; i < num; i++) {
player = players[i];
if (g_PlayerData[player][PLAYER_KILLS] > maxKills || g_PlayerData[player][PLAYER_DMG] > maxDmg) {
maxId = player;
maxKills = g_PlayerData[player][PLAYER_KILLS];
maxDmg = g_PlayerData[player][PLAYER_DMG];
}
}

if (maxId == 0) {
return;
}

if (g_MoneyBonus > 0) {
rg_add_account(maxId, g_MoneyBonus, AS_ADD, true);
}

#if defined AES_MAX_LEVEL_LENGTH
if (g_AesExp > 0) {
aes_set_player_exp(maxId, aes_get_player_exp(maxId) + float(g_AesExp));
}

if (g_AesBonus > 0) {
aes_set_player_bonus(maxId, aes_get_player_bonus(maxId) + g_AesBonus);
}
#endif

get_user_name(maxId, name, charsmax(name));
num1 = makeNumber(g_PlayerData[maxId][PLAYER_KILLS]);
num2 = makeNumber(g_PlayerData[maxId][PLAYER_HS]);
set_hudmessage(0, 255, 255, -1.0, 0.17, 0, .fxtime = 0.0, .holdtime = 5.0, .channel = 4);

if (g_MoneyBonus > 0)
len += formatex(message[len], charsmax(message) - len, "^1[^4%d $^1] ", g_MoneyBonus);
#if defined AES_MAX_LEVEL_LENGTH
if (g_AesExp > 0)
len += formatex(message[len], charsmax(message) - len, "^1[^4%d EXP^1] ", g_AesExp);
if (g_AesBonus > 0)
len += formatex(message[len], charsmax(message) - len, "^1[^4%d BONUS^1] ", g_AesBonus);
#endif
for (i = 0; i < num; i++) {
player = players[i];

if (!CheckBit(g_HudEnabled, player) || is_user_bot(player)) {
continue;
}

if (g_ShowInfo == 1) {
ShowSyncHudMsg(player, g_HudSync, "%L:%c%s^n%d %L, %d %L %L %d %L",
player, "BRP_MESSAGE", (g_NameNewLine == 1 ? "^n" : " "), name,
g_PlayerData[maxId][PLAYER_KILLS], player, g_Titles[0][num1],
g_PlayerData[maxId][PLAYER_HS], player, g_Titles[1][num2],
player, "BPR_AND",
g_PlayerData[maxId][PLAYER_DMG], player, "BPR_DMG"
);
} else if (g_ShowInfo == 2) {
ShowSyncHudMsg(player, g_HudSync, "%L:%c%s",
player, "BRP_MESSAGE", (g_NameNewLine == 1 ? "^n" : " "), name
);
}
#if defined AES_MAX_LEVEL_LENGTH
if (g_MoneyBonus || g_AesExp || g_AesBonus > 0) {
#else
if (g_MoneyBonus) {
#endif
if (player == maxId)
client_print_color(player, maxId, "%L %L", player, "BPR_PREFIX", player, "BPR_BONUS", message);
else if (g_ShowAll == 1)
client_print_color(player, maxId, "%L %L", player, "BPR_PREFIX", player, "BPR_BONUS_ALL", name, message);
}
}
}

stock makeNumber(number) {
if (4 < (number % 100) < 20) {
return 2;
} else if ((number % 10) < 5) {
return g_Cases[number % 10];
} else {
return 2;
}
}
Здравствуйте.
В этом
посте указали решение на фикс бага этого момента.
При компиляции выходят следующие ошибки.
 
В этой теме было размещено решение! Перейти к решению.
Сообщения
1,335
Реакции
528
Помог
91 раз(а)
Сообщения
9
Реакции
3
Помог
1 раз(а)
в 192 строке тоже надо заменить строку, будьте внимательны.
Я конечно не очень силен в скриптинге, но вроде как написал "BlackSignature" только здесь.
TwinG4_20, поменяв в хуке TakeDamage

Да и даже если менять в 2-ух, то также идут ошибки.
// C:\Users\admin2\Desktop\Compiler 1.9.0\best_player_of_the_round.sma(172) : warning 209: function "CBasePlayer_TakeDamage" should return a value
// C:\Users\admin2\Desktop\Compiler 1.9.0\best_player_of_the_round.sma(174) : error 010: invalid function or declaration
// C:\Users\admin2\Desktop\Compiler 1.9.0\best_player_of_the_round.sma(175) : error 010: invalid function or declaration
// C:\Users\admin2\Desktop\Compiler 1.9.0\best_player_of_the_round.sma(178) : error 010: invalid function or declaration
// C:\Users\admin2\Desktop\Compiler 1.9.0\best_player_of_the_round.sma(180) : error 010: invalid function or declaration
// C:\Users\admin2\Desktop\Compiler 1.9.0\best_player_of_the_round.sma(184) : error 010: invalid function or declaration
// C:\Users\admin2\Desktop\Compiler 1.9.0\best_player_of_the_round.sma(194) : warning 209: function "CBasePlayer_Killed" should return a value
// C:\Users\admin2\Desktop\Compiler 1.9.0\best_player_of_the_round.sma(196) : error 010: invalid function or declaration
// C:\Users\admin2\Desktop\Compiler 1.9.0\best_player_of_the_round.sma(198) : error 010: invalid function or declaration
 
Сообщения
1,175
Реакции
2,144
Помог
57 раз(а)
Silvester,
Код:
-if (rg_is_player_can_takedamage(id, attacker))
+if (rg_is_player_can_takedamage(id, attacker)) {
 

d3m37r4

111111
Сообщения
1,420
Реакции
1,162
Помог
10 раз(а)
Проверки типа id == attacker можно убрать, если используется натив rg_is_player_can_takedamage
Код:
public CBasePlayer_TakeDamage(id, inflictor, attacker, Float:damage, damageType) {
    if (!is_user_connected(attacker)) {
        return HC_CONTINUE;
    }

    if (rg_is_player_can_takedamage(id, attacker)) {
        return HC_CONTINUE;
    }

    if (inflictor != attacker && ~damageType & DMG_GRENADE) {
        return HC_CONTINUE;
    }

    g_PlayerData[attacker][PLAYER_DMG] += floatround(damage);

    if( get_member(id, m_LastHitGroup) == HIT_HEAD) {
        g_PlayerData[attacker][PLAYER_HS]++;
    }

    return HC_CONTINUE;
}

Поскольку там возвращается значение из функции CSGameRules()->FPlayerCanTakeDamage , в которой эти проверки есть, также там проверяется и friendly fire (если переписывать код public CBasePlayer_Killed, чтобы не дергать значения кваров и команды атакующего и жертвы).

 
Сообщения
9
Реакции
3
Помог
1 раз(а)
BlackSignature, d3m37r4, благодарю за помощь с компиляцией.
В обоих случаях в конце раунда не выводит info "Попадания в голову" и "Общий урон" (просто 0).
Но если наносить урон по союзнику в начале (баг который был описан), то в конце раунда будет выводить попадания в голову и общий урон, который ты этим союзникам сделал.

p.s. сейчас стоит данный код
Код:
public CBasePlayer_TakeDamage(id, inflictor, attacker, Float:damage, damageType) {
    if (!is_user_connected(attacker)) {
        return HC_CONTINUE;
    }

    if (rg_is_player_can_takedamage(id, attacker)) {
        return HC_CONTINUE;
    }

    if (inflictor != attacker && ~damageType & DMG_GRENADE) {
        return HC_CONTINUE;
    }

    g_PlayerData[attacker][PLAYER_DMG] += floatround(damage);

    if( get_member(id, m_LastHitGroup) == HIT_HEAD) {
        g_PlayerData[attacker][PLAYER_HS]++;
    }

    return HC_CONTINUE;
12 Май 2019
В связи с обновлением плагина просьба закрыть тему.


p.s. в новой версии (1.0.0-beta) недочетов пока не замечал, спасибо fantom плагина за update.
 
Последнее редактирование модератором:
Статус
В этой теме нельзя размещать новые ответы.

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу