Скриптер
Участник
Пользователь
- Сообщения
- 397
- Реакции
- 221
- Помог
- 13 раз(а)
b0t., почему не верно писало в массиве
RG_RoundEnd
вызывается раньше чем RG_CBasePlayer_TakeDamage
. Последний выстрел не записывался.b0t., почему не верно писало в массиве
RG_RoundEnd
вызывается раньше чем RG_CBasePlayer_TakeDamage
. Последний выстрел не записывался.b0t. Something is wrong and i don't know what. The plugin doesn't calculate correctely the hits... 1 SHOT and it says 12...daydreamind,
Код:#include <amxmodx> #include <reapi> //new const g_szIP[] = "185.248.103.12:15555"; #define MAX_DMG_100 //Maximum damage dealt to one enemy = 100. #define SHOT_A_GRENADE //Count grenade damage as a hit. #define MAXPLAYERS 11 //Maximum number of slots on the server enum any: DATA { damage, Shot }; new e_InfoClient[DATA][MAXPLAYERS +1], bool:b_Chat; public plugin_init() { register_plugin("GameInfo", "1.2", "b0t."); RegisterHookChain(RG_CBasePlayer_TakeDamage, "RG_CBasePlayerTakeDamage_Post", 1); RegisterHookChain(RG_RoundEnd,"RG_RoundEnd_Post", 1); register_clcmd("say /damageinfo", "Info_Menu"); } public RG_CBasePlayerTakeDamage_Post(const pVictim, const iInflictor, const pAttacer, const Float:fDamage, const iBitDamage) { if(!is_user_connected(pAttacer) || fDamage <= 0.0 || !rg_is_player_can_takedamage(pVictim, pAttacer) || pVictim == pAttacer) return HC_CONTINUE; #if !defined SHOT_A_GRENADE if(iBitDamage & DMG_GRENADE) return HC_CONTINUE; #endif new iDemage = floatround(fDamage); #if defined MAX_DMG_100 if((e_InfoClient[Demage][pAttacer] +iDemage) > 100) e_InfoClient[Demage][pAttacer] = 100; else e_InfoClient[Damage][pAttacer] += iDamage; #else e_InfoClient[Demage][pAttacer] += iDemage; #endif ++e_InfoClient[Shot][pAttacer]; return HC_CONTINUE; } public RG_RoundEnd_Post() { RequestFrame("RequestFrame__PrintInfo"); } public RequestFrame__PrintInfo() { for(new i = 1; i <= MAXPLAYERS; ++i) { if(!is_user_connected(i)) continue; UTIL_ShowRoundInfo(s); } arrayset(e_InfoClient[_:0][0], 0, sizeof(e_InfoClient) * sizeof(e_InfoClient[])); } public Info_Menu(const pId) { new i_Menu = menu_create("\yMenu Informer", "Damager_Handler"); menu_additem(i_Menu, "Show damage information in console", "1"); menu_additem(i_Menu, "Show damage information in chat", "2"); menu_setprop(i_Menu, MPROP_EXITNAME, "Exit"); menu_display(pId, i_Menu); } public Damager_Handler(const pId, const iMenu, const iItem) { menu_destroy(iMenu); if(iItem != MENU_EXIT) b_Chat = bool:iItem; return PLUGIN_HANDLED; } stock UTIL_ShowRoundInfo(const id) { for(new i = 1; i <= MAXPLAYERS; ++i) { if(!is_user_connected(i) || i == id) continue; if(e_InfoClient[Demage][id] == 0 && e_InfoClient[Demage][i] == 0) continue; client_print(id, b_Chat ? print_chat : print_console, "You* -> |%i with %i|, Opponent -> |%i with %i|, %n -> |%.0fHP|", e_InfoClient[Demage][id], e_InfoClient[Shot][id], e_InfoClient[Demage][i], e_InfoClient[Shot][i], i, !is_user_alive(i) ? 0 : get_entvar(i, var_health) ); } }
e_InfoClient[DATA][MAXPLAYERS +1],
на трехмерный, так как у тебя в твой массив записывает урон и попадания в сумме от всех игроков, урон бы тоже отображало бы в разы больше, если закоментировать это - #define DAMAGE_DEFAULT
The problem is that i don't know how...claudiuandrei10, you need to convert the two-dimensional arraye_InfoClient[DATA][MAXPLAYERS +1],
into a three-dimensional one, since the total damage from all players is recorded in your array
#include <amxmodx>
#include <reapi>
#define IS_TEAM(%0,%1) bool:(get_member(%0, m_iTeam) == %1)
/*---------------------------------Настройки-------------------------------------------*/
#define DAMAGE_DEFAULT //Максимальный нанёсённый урон по одному противнику = 100.
#define SHOT_A_GRENADE //Засчитывать урон от гранаты за попадание.
/*-------------------------------------------------------------------------------------*/
enum any: DATA {
Float:DAMAGE,
SHOTS
};
new
e_Client[DATA][MAX_PLAYERS +1][MAX_PLAYERS +1],
bool:b_ViewChat,
gl_iMenu;
public plugin_init() {
register_plugin("GameInfo", "24.01.24", "b0t.");
RegisterHookChain(RG_CBasePlayer_TakeDamage, "RG_CBasePlayerTakeDamage_Post", 1);
RegisterHookChain(RG_RoundEnd,"RG_RoundEnd_Post", 1);
register_clcmd("say /damageinfo", "Info_Menu");
CREATE_Mmenu();
}
public RG_CBasePlayerTakeDamage_Post(const pVictim, const iInflictor, const pAttacker, const Float:fDamage, const iBitDamage) {
if(!is_user_connected(pAttacker) || !rg_is_player_can_takedamage(pVictim, pAttacker) || pVictim == pAttacker)
return HC_CONTINUE;
#if !defined SHOT_A_GRENADE
if(iBitDamage & DMG_GRENADE)
return HC_CONTINUE;
#endif
#if defined DAMAGE_DEFAULT
if(e_Client[DAMAGE][pAttacker][pVictim] +fDamage > 100.0)
e_Client[DAMAGE][pAttacker][pVictim] = 100.0;
else e_Client[DAMAGE][pAttacker][pVictim] += fDamage;
#else
e_Client[DAMAGE][pAttacker][pVictim] += fDamage;
#endif
++e_Client[SHOTS][pAttacker][pVictim];
return HC_CONTINUE;
}
public RG_RoundEnd_Post()
RequestFrame("RequestFrame_PrintInfo");
public RequestFrame_PrintInfo() {
for(new id = 1; id <= MaxClients; ++id) {
if(!is_user_connected(id))
continue;
UTIL_ShowRoundInfo(id);
}
arrayset(e_Client[_:0][0][0], 0, sizeof(e_Client) * sizeof(e_Client[]) * sizeof(e_Client[][]));
}
CREATE_Mmenu() {
gl_iMenu = menu_create("\yИнформер меню", "Damager_Handler");
menu_additem(gl_iMenu, "Показывать информацию об уроне в чате", "1");
menu_additem(gl_iMenu, "Показывать информацию об уроне в консоли", "2");
menu_setprop(gl_iMenu, MPROP_EXITNAME, "Выход");
}
public Info_Menu(const pId) {
if(is_user_connected(pId))
menu_display(pId, gl_iMenu);
return PLUGIN_HANDLED;
}
public Damager_Handler(const pId, const iMenu, const iItem) {
if(iItem != MENU_EXIT)
b_ViewChat = bool:iItem;
}
stock UTIL_ShowRoundInfo(const id) {
for(new pClient = 1; pClient <= MaxClients ; ++pClient) {
if(!is_user_connected(pClient) || pClient == id || IS_TEAM(pClient, TEAM_UNASSIGNED) || IS_TEAM(pClient, TEAM_SPECTATOR))
continue;
if(e_Client[DAMAGE][id][pClient] == 0.0 && e_Client[DAMAGE][pClient][id] == 0.0)
continue;
client_print(id, !b_ViewChat ? print_chat : print_console,
"Вы* -> |%.0f урон * %i попаданий|, Противник -> |%.0f урон * %i попаданий|, %n -> |%.0f HP остаток|",
e_Client[DAMAGE][id][pClient], e_Client[SHOTS][id][pClient],
e_Client[DAMAGE][pClient][id], e_Client[SHOTS][pClient][id],
pClient, !is_user_alive(pClient) ? 0 : get_entvar(pClient, var_health)
);
}
}
Ty. I will test and reply.Например так,
Код:#include <amxmodx> #include <reapi> #define IS_TEAM(%0,%1) bool:(get_member(%0, m_iTeam) == %1) /*---------------------------------Настройки-------------------------------------------*/ #define DAMAGE_DEFAULT //Максимальный нанёсённый урон по одному противнику = 100. #define SHOT_A_GRENADE //Засчитывать урон от гранаты за попадание. const MAXPLAYERS = 11; //Максимальное количество слотов на сервере /*-------------------------------------------------------------------------------------*/ enum any: DATA { Float:DAMAGE, SHOTS }; new e_Client[DATA][MAXPLAYERS +1][MAXPLAYERS +1], bool:b_ViewChat; public plugin_init() { register_plugin("GameInfo", "24.01.24", "b0t."); RegisterHookChain(RG_CBasePlayer_TakeDamage, "RG_CBasePlayerTakeDamage_Post", 1); RegisterHookChain(RG_RoundEnd,"RG_RoundEnd_Post", 1); register_clcmd("say /damageinfo", "Info_Menu"); } public RG_CBasePlayerTakeDamage_Post(const pVictim, const iInflictor, const pAttacker, const Float:fDamage, const iBitDamage) { if(!is_user_connected(pAttacker) || !rg_is_player_can_takedamage(pVictim, pAttacker) || pVictim == pAttacker) return HC_CONTINUE; #if !defined SHOT_A_GRENADE if(iBitDamage & DMG_GRENADE) return HC_CONTINUE; #endif #if defined DAMAGE_DEFAULT if(e_Client[DAMAGE][pAttacker][pVictim] +fDamage > 100.0) e_Client[DAMAGE][pAttacker][pVictim] = 100; else e_Client[DAMAGE][pAttacker][pVictim] += fDamage; #else e_Client[DAMAGE][pAttacker][pVictim] += fDamage; #endif ++e_Client[SHOTS][pAttacker][pVictim]; return HC_CONTINUE; } public RG_RoundEnd_Post() RequestFrame("RequestFrame_PrintInfo"); public RequestFrame_PrintInfo() { for(new id = 1; id <= MAXPLAYERS; ++id) { if(!is_user_connected(id)) continue; UTIL_ShowRoundInfo(id); } arrayset(e_Client[_:0][0][0], 0, sizeof(e_Client) * sizeof(e_Client[]) * sizeof(e_Client[][])); } public Info_Menu(const pId) { new i_Menu = menu_create("\yИнформер меню", "Damager_Handler"); menu_additem(i_Menu, "Показывать информацию об уроне в чате", "1"); menu_additem(i_Menu, "Показывать информацию об уроне в консоли", "2"); menu_setprop(i_Menu, MPROP_EXITNAME, "Выход"); menu_display(pId, i_Menu); return PLUGIN_HANDLED; } public Damager_Handler(const pId, const iMenu, const iItem) { menu_destroy(iMenu); if(iItem != MENU_EXIT) b_ViewChat = bool:iItem; } stock UTIL_ShowRoundInfo(const id) { for(new pClient = 1; pClient <= MAXPLAYERS; ++pClient) { if(!is_user_connected(pClient) || pClient == id || IS_TEAM(pClient, TEAM_UNASSIGNED) || IS_TEAM(pClient, TEAM_SPECTATOR)) continue; if(e_Client[DAMAGE][id][pClient] == 0.0 && e_Client[DAMAGE][pClient][id] == 0.0) continue; client_print(id, !b_ViewChat ? print_chat : print_console, "Вы* -> |%.0f урон * %i попаданий|, Противник -> |%.0f урон * %i попаданий|, %n -> |%.0f HP остаток|", e_Client[DAMAGE][id][pClient], e_Client[SHOTS][id][pClient], e_Client[DAMAGE][pClient][id], e_Client[SHOTS][pClient][id], pClient, !is_user_alive(pClient) ? 0 : get_entvar(pClient, var_health) ); } }
Язык на английский и количество игроков, уже смените сами 25 Янв 2024
Code_0xABC Вы* -> |0 урон * 1 попаданий|, Противник -> |0 урон * 0 попаданий|, Dan -> |0 HP оста�Ty. I will test and reply.
-e_Client[DAMAGE][pAttacker][pVictim] = 100;
+e_Client[DAMAGE][pAttacker][pVictim] = 100.0;
Code_0xABCclaudiuandrei10, replace line 43, I'm sorry, I didn't notice, the variable type was changed to Float for a more accurate display of damage
Код:-e_Client[DAMAGE][pAttacker][pVictim] = 100; +e_Client[DAMAGE][pAttacker][pVictim] = 100.0;
А то по символам не влазят, обрезает, либо переведи на английскийВы* -> |0 урон * 1 попаданий|, Противник -> |0 урон * 0 попаданий|, Dan -> |0 HP оста�
Code_0xABC i'm using 1.9.0и строку надо уменьшить А то по символам не влазят, обрезает, либо переведи на английскийclaudiuandrei10, компилируй компилятором 1.9.0 и выше 25 Янв 2024
Code_0xABC Yeah...It’s strange, even an online compiler without warnings, this is the first time I’ve encountered something like this
Code_0xABC ok, I did that, but i got this now...claudiuandrei10, compile with an online compiler for the test
что тут не так?You* -> |100 with 2|, Opponent -> |0 with 0|, Misu -> |50HP|
Code_0xABC well, i hit him 2 ( 25 + 25 ) but the pluging says i give him 100There are 2 options:
1. This is through the enum structure, but it works with an integer, but the result will not be accurate, since the fractional damage number will be rounded.
2. Make separate arrays, one float the other int (This method is more suitable)claudiuandrei10 25 Янв 2024
what's wrong here?
client_print(id, !b_ViewChat ? print_chat : print_console,
"Вы* -> |%.0f урон * %i попаданий|, Противник -> |%.0f урон * %i попаданий|, %n -> |%.0f HP остаток|",
e_Client[DAMAGE][id][pClient], e_Client[SHOTS][id][pClient],
e_Client[DAMAGE][pClient][id], e_Client[SHOTS][pClient][id],
pClient, !is_user_alive(pClient) ? 0 : get_entvar(pClient, var_health)
);
client_print(id, !b_ViewChat ? print_chat : print_console,
"Вы* -> |%.0f урон * %i попаданий|, Противник -> |%.0f урон * %i попаданий|, %n -> |%.0f HP остаток|",
e_Client[DAMAGE][id][pClient], e_Client[SHOTS][id][pClient],
e_Client[DAMAGE][pClient][id], e_Client[SHOTS][pClient][id],
pClient, !is_user_alive(pClient) ? 0.0 : get_entvar(pClient, var_health)
);