Пользователь
- Сообщения
- 21
- Реакции
- 1
Неверный раздел форума
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <reapi>
#define PLUGIN "Unreal Mini Damager"
#define VERSION "1.2"
#define AUTHOR "Karaulov"
new g_hSyncObjAttacker;
new g_hSyncObjTarget;
new bool:g_bDmgEnabled[50] = {true, ...};
// Установите флаг для доступа к дамагеру
//#define DAMAGE_FLAG ADMIN_RESERVATION
// Установите флаг для тех кто будет видеть урон через стены
//#define INVISIBLED_FLAG ADMIN_BAN
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
register_clcmd("say /damager","toggle_damager",_,"Вкл/выкл damager");
register_clcmd("say_team /damager","toggle_damager",_,"Вкл/выкл damager");
g_hSyncObjAttacker = CreateHudSyncObj();
g_hSyncObjTarget = CreateHudSyncObj();
RegisterHookChain(RG_CBasePlayer_TakeDamage, "TakeDamage_Post", true);
}
public toggle_damager(id){
g_bDmgEnabled[id] = !g_bDmgEnabled[id];
set_hudmessage(0, 100, 200, -1.0, 0.55, 0, 0.1, 2.0, 0.02, 0.02, -1);
show_hudmessage(id, "Отображение урона %s", g_bDmgEnabled[id] ? "ВКЛЮЧЕНО" : "ВЫКЛЮЧЕНО");
}
public client_putinserver(id)
{
g_bDmgEnabled[id] = true;
}
public print_damage_to_spectators(attacker,target,damage)
{
new iPlayers[32], iNum, specPlayer;
get_players(iPlayers, iNum,"bch") ;
for(new i = 0; i < iNum; i++)
{
specPlayer = iPlayers;
new specTarget = get_entvar(specPlayer, var_iuser2);
if( specTarget == attacker )
{
set_hudmessage(0, 50, 200, -1.0, 0.45, 0, 0.1, 2.5, 0.02, 0.02, 2);
if (is_user_alive(target))
{
ShowSyncHudMsg(specPlayer, g_hSyncObjAttacker, "%i^n", damage);
}
else
{
ShowSyncHudMsg(specPlayer, g_hSyncObjAttacker, "%i - СМЕРТЕЛЬНЫЙ^n",damage);
}
}
else if( specTarget == target )
{
set_hudmessage(200, 20, 20, -1.0, 0.55, 0, 0.1, 2.5, 0.02, 0.02, 3);
if (is_user_alive(target))
{
ShowSyncHudMsg(specPlayer, g_hSyncObjTarget, "%i^n", damage);
}
else
{
ShowSyncHudMsg(specPlayer, g_hSyncObjTarget, "%i - СМЕРТЕЛЬНЫЙ^n",damage);
}
}
}
}
public print_damage_to_player(attacker,target,damage)
{
new bool:bIsAttackerConnected = is_user_connected(attacker) > 0;
new bool:bIsTargetConnected = is_user_connected(target) > 0;
#if defined INVISIBLED_FLAG
new bool:bIsVisibled = true;
if (bIsAttackerConnected && bIsTargetConnected)
bIsVisibled = is_user_visibled(attacker,target);
#endif
if (attacker != target && bIsAttackerConnected && g_bDmgEnabled[attacker])
{
#if defined DAMAGE_FLAG
if (get_user_flags(attacker) & DAMAGE_FLAG)
#endif
#if defined INVISIBLED_FLAG
if (bIsVisibled || get_user_flags(attacker) & INVISIBLED_FLAG)
#endif
{
set_hudmessage(0, 50, 200, -1.0, 0.45, 0, 0.1, 2.5, 0.02, 0.02, 2);
if (is_user_alive(target))
{
ShowSyncHudMsg(attacker, g_hSyncObjAttacker, "%i^n", damage);
}
else
{
ShowSyncHudMsg(attacker, g_hSyncObjAttacker, "%i - СМЕРТЕЛЬНЫЙ^n",damage);
}
}
}
if (bIsTargetConnected && g_bDmgEnabled[target])
{
#if defined DAMAGE_FLAG
if (get_user_flags(target) & DAMAGE_FLAG)
#endif
{
set_hudmessage(200, 20, 20, -1.0, 0.55, 0, 0.1, 2.5, 0.02, 0.02, 3);
if (is_user_alive(target))
{
ShowSyncHudMsg(target, g_hSyncObjTarget, "%i^n", damage);
}
else
{
ShowSyncHudMsg(target, g_hSyncObjTarget, "%i - СМЕРТЕЛЬНЫЙ^n",damage);
}
}
}
}
public TakeDamage_Post(const pevVictim, pevInflictor, pevAttacker, Float:flDamage, bitsDamageType)
{
new iDamage = floatround(flDamage);
if (iDamage > 1)
{
print_damage_to_player(pevAttacker,pevVictim,iDamage);
print_damage_to_spectators(pevAttacker,pevVictim,iDamage);
}
}
stock bool:is_user_visibled(const pevAttacker, const pevVictim)
{
static Float:f_vRes[3];
new Float:f_vOrigAttacker[3], Float:f_vOrigVictim[3];
get_entvar(pevAttacker,var_origin,f_vOrigAttacker);
get_entvar(pevVictim,var_origin,f_vOrigVictim);
return trace_line(pevAttacker, f_vOrigAttacker, f_vOrigVictim, f_vRes) == pevVictim;
}
#include <amxmisc>
#include <engine>
#include <reapi>
#define PLUGIN "Unreal Mini Damager"
#define VERSION "1.2"
#define AUTHOR "Karaulov"
new g_hSyncObjAttacker;
new g_hSyncObjTarget;
new bool:g_bDmgEnabled[50] = {true, ...};
// Установите флаг для доступа к дамагеру
//#define DAMAGE_FLAG ADMIN_RESERVATION
// Установите флаг для тех кто будет видеть урон через стены
//#define INVISIBLED_FLAG ADMIN_BAN
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
register_clcmd("say /damager","toggle_damager",_,"Вкл/выкл damager");
register_clcmd("say_team /damager","toggle_damager",_,"Вкл/выкл damager");
g_hSyncObjAttacker = CreateHudSyncObj();
g_hSyncObjTarget = CreateHudSyncObj();
RegisterHookChain(RG_CBasePlayer_TakeDamage, "TakeDamage_Post", true);
}
public toggle_damager(id){
g_bDmgEnabled[id] = !g_bDmgEnabled[id];
set_hudmessage(0, 100, 200, -1.0, 0.55, 0, 0.1, 2.0, 0.02, 0.02, -1);
show_hudmessage(id, "Отображение урона %s", g_bDmgEnabled[id] ? "ВКЛЮЧЕНО" : "ВЫКЛЮЧЕНО");
}
public client_putinserver(id)
{
g_bDmgEnabled[id] = true;
}
public print_damage_to_spectators(attacker,target,damage)
{
new iPlayers[32], iNum, specPlayer;
get_players(iPlayers, iNum,"bch") ;
for(new i = 0; i < iNum; i++)
{
specPlayer = iPlayers;
new specTarget = get_entvar(specPlayer, var_iuser2);
if( specTarget == attacker )
{
set_hudmessage(0, 50, 200, -1.0, 0.45, 0, 0.1, 2.5, 0.02, 0.02, 2);
if (is_user_alive(target))
{
ShowSyncHudMsg(specPlayer, g_hSyncObjAttacker, "%i^n", damage);
}
else
{
ShowSyncHudMsg(specPlayer, g_hSyncObjAttacker, "%i - СМЕРТЕЛЬНЫЙ^n",damage);
}
}
else if( specTarget == target )
{
set_hudmessage(200, 20, 20, -1.0, 0.55, 0, 0.1, 2.5, 0.02, 0.02, 3);
if (is_user_alive(target))
{
ShowSyncHudMsg(specPlayer, g_hSyncObjTarget, "%i^n", damage);
}
else
{
ShowSyncHudMsg(specPlayer, g_hSyncObjTarget, "%i - СМЕРТЕЛЬНЫЙ^n",damage);
}
}
}
}
public print_damage_to_player(attacker,target,damage)
{
new bool:bIsAttackerConnected = is_user_connected(attacker) > 0;
new bool:bIsTargetConnected = is_user_connected(target) > 0;
#if defined INVISIBLED_FLAG
new bool:bIsVisibled = true;
if (bIsAttackerConnected && bIsTargetConnected)
bIsVisibled = is_user_visibled(attacker,target);
#endif
if (attacker != target && bIsAttackerConnected && g_bDmgEnabled[attacker])
{
#if defined DAMAGE_FLAG
if (get_user_flags(attacker) & DAMAGE_FLAG)
#endif
#if defined INVISIBLED_FLAG
if (bIsVisibled || get_user_flags(attacker) & INVISIBLED_FLAG)
#endif
{
set_hudmessage(0, 50, 200, -1.0, 0.45, 0, 0.1, 2.5, 0.02, 0.02, 2);
if (is_user_alive(target))
{
ShowSyncHudMsg(attacker, g_hSyncObjAttacker, "%i^n", damage);
}
else
{
ShowSyncHudMsg(attacker, g_hSyncObjAttacker, "%i - СМЕРТЕЛЬНЫЙ^n",damage);
}
}
}
if (bIsTargetConnected && g_bDmgEnabled[target])
{
#if defined DAMAGE_FLAG
if (get_user_flags(target) & DAMAGE_FLAG)
#endif
{
set_hudmessage(200, 20, 20, -1.0, 0.55, 0, 0.1, 2.5, 0.02, 0.02, 3);
if (is_user_alive(target))
{
ShowSyncHudMsg(target, g_hSyncObjTarget, "%i^n", damage);
}
else
{
ShowSyncHudMsg(target, g_hSyncObjTarget, "%i - СМЕРТЕЛЬНЫЙ^n",damage);
}
}
}
}
public TakeDamage_Post(const pevVictim, pevInflictor, pevAttacker, Float:flDamage, bitsDamageType)
{
new iDamage = floatround(flDamage);
if (iDamage > 1)
{
print_damage_to_player(pevAttacker,pevVictim,iDamage);
print_damage_to_spectators(pevAttacker,pevVictim,iDamage);
}
}
stock bool:is_user_visibled(const pevAttacker, const pevVictim)
{
static Float:f_vRes[3];
new Float:f_vOrigAttacker[3], Float:f_vOrigVictim[3];
get_entvar(pevAttacker,var_origin,f_vOrigAttacker);
get_entvar(pevVictim,var_origin,f_vOrigVictim);
return trace_line(pevAttacker, f_vOrigAttacker, f_vOrigVictim, f_vRes) == pevVictim;
}