#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fun>
#include <hamsandwich>
#include <fakemeta>
#include <WPMGPrintChatColor>
#define PLUGIN "deathmenu"
#define VERSION "1.0"
#define AUTHOR "Author"
new gMaxPlayer;
new bool:isGhost[33];
new bool:isSpeed[33];
new bool:isGravity[33];
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_menu("MenuId", 1023, "MenuFunc");
register_clcmd("deathmenu","startMenu")
register_clcmd("say /deathmenu","startMenu")
register_clcmd("say_team /deathmenu","startMenu")
gMaxPlayer = get_maxplayers();
RegisterHam(Ham_Item_PreFrame, "player", "Ham_ItemPreFrame_Pre", 0);
RegisterHam(Ham_TakeDamage,"player","TakeDamage",0)
RegisterHam(Ham_Spawn,"player","player_respawn",1)
register_event("HLTV", "roundStart", "a", "1=0", "2=0")
RegisterHam(Ham_Use, "func_button", "HamHook_UseButtons", 0);
RegisterHam(Ham_Touch, "weaponbox", "HamHook_TouchWeapon", 0);
RegisterHam(Ham_Touch, "armoury_entity", "HamHook_TouchWeapon", 0);
RegisterHam(Ham_Touch, "weapon_hegrenade", "HamHook_TouchWeapon", 0);
register_forward(FM_EmitSound,"Sound_Hook")
}
public HamHook_UseButtons(ent, id, iCallerId, iUseType, Float:flValue) {
if(isGhost[id]) {
if(pev(ent, pev_frame) > 0.0) return HAM_IGNORED;
return HAM_SUPERCEDE;
}
return HAM_IGNORED;
}
public HamHook_TouchWeapon(ent,id) {
if(isGhost[id]) {
if(!is_valid_ent(ent)) return HAM_IGNORED;
return HAM_SUPERCEDE;
}
return HAM_IGNORED;
}
enum _:STRSCORE {
SC_KILL,
SC_DEATH
}
new gPlScore[33][STRSCORE];
public Sound_Hook(id,channel,sample[]) {
if(0 < id <= 32) {
if(isGhost[id]) {
return FMRES_SUPERCEDE;
}
}
return FMRES_IGNORED;
}
public player_respawn(id) {
if(!is_user_alive(id))
return;
if(isGhost[id]) {
if(gPlScore[id][SC_KILL] == -1)
gPlScore[id][SC_KILL] = get_user_frags(id);
if(gPlScore[id][SC_DEATH] == -1)
gPlScore[id][SC_DEATH] = cs_get_user_deaths(id);
set_task(0.1,"taskSpawn",id );
set_entity_visibility(id,0);
} else {
if(gPlScore[id][SC_KILL] != -1) {
set_user_frags(id,gPlScore[id][SC_KILL]);
}
if(gPlScore[id][SC_DEATH] != -1) {
cs_set_user_deaths(id,gPlScore[id][SC_DEATH]);
}
set_entity_visibility(id,1);
if(is_user_alive(id))
set_user_footsteps(id,0);
}
}
public taskSpawn(id) {
if(!is_user_alive(id))
return;
set_pev(id,pev_health,100.0);
set_pev(id, pev_deadflag, DEAD_RESPAWNABLE)
set_user_footsteps(id,1);
set_pev(id, pev_solid, SOLID_NOT)
set_entity_visibility( id, 0 );
strip_user_weapons(id);
set_user_godmode(id,0)
message_begin(MSG_ALL, get_user_msgid("ScoreAttrib"))
write_byte(id)
write_byte((1<<0))
message_end()
}
public roundStart() {
for( new id=1;id<=gMaxPlayer;id++ ) {
if(!is_user_connected(id))
continue;
if(isGhost[id]) {
isGhost[id] = false;
}
if(gPlScore[id][SC_KILL] != -1) {
set_user_frags(id,gPlScore[id][SC_KILL]);
}
if(gPlScore[id][SC_DEATH] != -1) {
cs_set_user_deaths(id,gPlScore[id][SC_DEATH]);
}
}
}
public client_putinserver(id) {
isGhost[id] = false;
isSpeed[id] = false;
isGravity[id] = false;
gPlScore[id][SC_KILL] = -1;
gPlScore[id][SC_DEATH] = -1;
}
public TakeDamage(victim, inflicator, attacker) {
if(isGhost[victim] || isGhost[attacker]) {
return HAM_SUPERCEDE;
}
return HAM_IGNORED;
}
public Ham_ItemPreFrame_Pre(id) {
if(is_user_connected(id) && is_user_alive(id)) {
if(isGhost[id] && isSpeed[id]) {
set_user_maxspeed(id,500.0);
return HAM_SUPERCEDE;
}
}
return HAM_IGNORED;
}
public startMenu(id) {
if(is_user_alive(id)) {
PrintChatColor(id, PRINT_COLOR_PLAYERTEAM,"!g[!yМеню мёртвого!g] !yМеню доступно только мёртвым!");
return;
}
static menu[512],len,key;
len = 0;
len += formatex(menu[len], charsmax(menu) - len, "\yМеню мёртвого:^n^n");
if(!isGhost[id]) {
len += formatex(menu[len], charsmax(menu) - len, "\y[1\y] \wСтать призраком^n" );
key = MENU_KEY_0|MENU_KEY_1
} else {
len += formatex(menu[len], charsmax(menu) - len, "\y[1\y] \wВернуться в мир мёртвых^n^n" );
len += formatex(menu[len], charsmax(menu) - len, "\y[3\y] \wНет преград \d[\r%s\d]^n",get_user_noclip(id) ? "Выкл":"Вкл" );
len += formatex(menu[len], charsmax(menu) - len, "\y[4\y] \wСкорость \d[\r%s\d]^n",isSpeed[id] ? "Вкл":"Выкл" );
len += formatex(menu[len], charsmax(menu) - len, "\y[5\y] \wГравитация \d[\r%s\d]^n",isGravity[id] ? "Вкл":"Выкл" );
key = MENU_KEY_0|MENU_KEY_1|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5
}
len += formatex(menu[len], charsmax(menu) - len, "^n\y[0\y] \wВыход");
show_menu(id,key, menu, -1, "MenuId");
}
public MenuFunc(id,key) {
if(key == 9) {
return;
}
if(is_user_alive(id)) {
return;
}
if(!isGhost[id]) {
isGhost[id] = true;
ExecuteHam( Ham_CS_RoundRespawn,id);
} else {
switch(key) {
case 0: {
isGhost[id] = false;
set_pev(id, pev_deadflag, DEAD_NO)
user_silentkill(id);
}
case 2: {
set_user_noclip(id, get_user_noclip(id) ? 0:1);
}
case 3: {
if(isSpeed[id]) {
set_user_maxspeed(id,250.0);
isSpeed[id] = false;
} else {
set_user_maxspeed(id,500.0);
isSpeed[id] = true;
}
}
case 4: {
if(isGravity[id]) {
set_pev(id,pev_gravity,1.0);
isGravity[id] = false;
} else {
set_pev(id,pev_gravity,0.5);
isGravity[id] = true;
}
}
}
}
startMenu(id);
}