Код
#include <amxmodx>
#include <hamsandwich>
#include <amxmisc>
#include <nvault>
#define is_valid_player(%1) (1 <= %1 <= 32)
#pragma semicolon 1
// Настройки
#define FLAG ADMIN_KICK // флаг доступа
#define IMMUNITY ADMIN_BAN // флаг иммунитета
#define TOPADMIN ADMIN_RCON // флаг админа, игнорирующего иммунитет
#define DM_ACTIV // показывать игроку сообщение в чат об установке клейма(закомментируйте, если хотите отключить)
new Float:mult_damage = 2.5; // множитель урона по игроку
new Float:vict_damage = 0.7; // множитель урона игрока
// Словарь
#define DM_PREFIX "D|M" // Префикс в начале сообщения
#define DM_MENU "\yDeath Mark menu:"
#define DM_ACCESS "^1[^4%s^1] ^4В доступе ^3отказано"
#define DM_ON "^1[^4%s^1] ^4Клеймо ^3смерти ^4установлено!"
#define DM_OFF "^1[^4%s^1] ^4Клеймо ^3смерти ^4снято!"
#define DM_ON_A "^1[^4%s^1] На Вас ^4установлено ^3Клеймо ^4смерти ^1игроком ^3%s!"
#define DM_OFF_A "^1[^4%s^1] С Вас ^4снято ^3Клеймо ^4смерти ^1игроком ^3%s!"
new bool:mark[33] = false;
new g_vault;
public plugin_init()
{
register_plugin("Mark of death", "1.0", "Deadly|Darkness");
RegisterHam(Ham_TakeDamage, "player", "Mark_Damage",0);
register_clcmd ("amx_darkmenu","death_markmenu", FLAG);
g_vault = nvault_open("Death__Mark");
}
public plugin_natives ()
{
register_native("give_death_mark", "get_death_mark", 1);
register_native("del_death_mark", "delete_death_mark", 1);
}
public get_death_mark(id)
mark[id] = true;
public delete_death_mark(id)
mark[id] = false;
public client_connect(id)
{
mark[id] = false;
LoadData(id);
}
public client_disconnect(id)
{
SaveData(id);
mark[id] = false;
}
public plugin_end()
nvault_close(g_vault);
public death_markmenu(id)
{
if(~get_user_flags(id) & FLAG)
{
color_chat(id, DM_ACCESS, DM_PREFIX);
return PLUGIN_HANDLED;
}
new i_Menu = menu_create(DM_MENU, "markmenu_handler");
new callback = menu_makecallback ("markmenu_callback");
new s_Players[32], i_Num, i_Player;
new s_Name[32], s_Player[10];
get_players(s_Players, i_Num);
for (new i; i < i_Num; i++)
{
i_Player = s_Players[i];
get_user_name(i_Player, s_Name, charsmax(s_Name));
num_to_str(i_Player, s_Player, charsmax(s_Player));
menu_additem(i_Menu, s_Name, s_Player, 0, callback);
}
menu_display(id, i_Menu, 0);
return PLUGIN_HANDLED;
}
public markmenu_handler(id, menu, item)
{
if (item == MENU_EXIT)
{
menu_destroy(menu);
return PLUGIN_HANDLED;
}
new s_Data[6], s_Name[64], i_Access, i_Callback;
menu_item_getinfo(menu, item, i_Access, s_Data, charsmax(s_Data), s_Name, charsmax(s_Name), i_Callback);
new i_Player = str_to_num(s_Data);
if (!is_valid_player(i_Player))
return PLUGIN_HANDLED;
#if defined DM_ACTIV
new name[32]; get_user_name(id, name, charsmax(name));
#endif
if(!mark[i_Player]){
mark[i_Player] = true;
color_chat(id, DM_ON, DM_PREFIX);
#if defined DM_ACTIV
color_chat(i_Player, DM_ON_A, DM_PREFIX, name);
#endif
}
else {
mark[i_Player] = false;
color_chat(id, DM_OFF, DM_PREFIX);
#if defined DM_ACTIV
color_chat(i_Player, DM_OFF_A, DM_PREFIX, name);
#endif
}
menu_destroy(menu);
return PLUGIN_HANDLED;
}
public markmenu_callback(id, menu, item)
{
new bool:topadmin = bool:(get_user_flags(id) & TOPADMIN);
static access, player, s_Player[6], item_name[41], callback, item_status;
item_status = ITEM_ENABLED;
menu_item_getinfo (menu, item, access, s_Player, charsmax(s_Player), item_name, charsmax(item_name), callback);
player = str_to_num(s_Player);
if (get_user_flags(player) & IMMUNITY) {
if(!topadmin)
item_status = ITEM_DISABLED;
add (item_name, charsmax(item_name), " \r*");
}
else if(mark[player])
add(item_name, charsmax(item_name), "[\yMARKED\w]");
menu_item_setname (menu, item, item_name);
return item_status;
}
public Mark_Damage(victim, inflictor, attacker, Float:damage, damage_bits)
{
if(victim == attacker)
return HAM_IGNORED;
if(!is_valid_player(victim) || !is_valid_player(attacker))
return HAM_IGNORED;
if(mark[attacker])
SetHamParamFloat(4, damage * vict_damage);
if(mark[victim])
SetHamParamFloat(4, damage * mult_damage);
return HAM_IGNORED;
}
public SaveData(id)
{
new AuthID[35];
get_user_authid(id,AuthID,34);
new vaultkey[64];
format(vaultkey,63,"%s-dm",AuthID);
if(mark[id]) nvault_set( g_vault , vaultkey , "1" );
else nvault_remove(g_vault, vaultkey);
return PLUGIN_CONTINUE;
}
public LoadData(id)
{
new AuthID[35];
get_user_authid(id,AuthID,34);
new vaultkey[64];
format(vaultkey,63,"%s-dm",AuthID);
if ( nvault_get( g_vault , vaultkey ) )
mark[id]=true;
else
mark[id]=false;
return PLUGIN_CONTINUE;
}
stock color_chat(const id, const input[], any:...)
{
new count = 1, players[32];
static msg[191];
vformat(msg, 190, input, 3);
replace_all(msg, 190, "!g", "^4");
replace_all(msg, 190, "!y", "^1");
replace_all(msg, 190, "!t", "^3");
if (id) players[0] = id; else get_players(players, count, "ch");
{
for (new i = 0; i < count; i++)
{
if (is_user_connected(players[i]))
{
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i]);
write_byte(players[i]);
write_string(msg);
message_end();
}
}
}
}