#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta>
#include <hamsandwich>
#include <fun>
#include <xs>
#include <cstrike>
#include <army_ranks_ultimate>
#if AMXX_VERSION_NUM < 183
#include <colorchat>
#include <dhudmessage>
#define client_disconnected client_disconnect
#define MAX_NAME_LENGTH 32
#define MAX_PLAYERS 32
#endif
#define PLUGIN "Knife Duel"
#define VERSION "1.1"
#define AUTHOR "Raizo"
#define CHAT_TAG "^3[^4Дуэли^3]^1 "
#define MOVE_UP 0
#define MOVE_DOWN 1
#define MOVE_RIGHT 2
#define MOVE_LEFT 3
#define MOVE_FRONT 4
#define MOVE_BACK 5
new Entity, maxplayers
new mapid[32], szName[MAX_NAME_LENGTH], map_default_hp, rounds;
new Float:vOrigin[3], Float:fOrigin[3], Float:his_spawn[33][3], Float:move_size[33], Float:fVelocity[3];
new bool:in_Duel[MAX_PLAYERS+1], g_Challenge[MAX_PLAYERS+1], g_Area[MAX_PLAYERS+1] = 0, g_DuelK[MAX_PLAYERS+1] = 0, g_DuelC[MAX_PLAYERS+1] = 0, g_MenuCallback;
new bool:Arena1in = false, bool:Arena2in = false;
new bool:his_offline[MAX_PLAYERS+1]
new bool:slash_attack[33];
new bool:stab_attack[33];
new bool:hs_attack[33];
new bool:Non_Stop[33];
new bool:most = false
new const ARENA_FILE_AAA[] = "%s/plat_A/%s.cfg"
new const ARENA_FILE_BBB[] = "%s/plat_B/%s.cfg"
new const DATE[] = "models/lickmyknife/knife_platform.mdl"
new const DATE2[] = "models/lickmyknife/knife_most.mdl"
#define SPAWN_TASK_ID 1271841
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("say /duel","Duel_Menu");
register_clcmd("say /plm","EntityMenu");
register_clcmd("endduel","End_Duel");
rounds = register_cvar("rush_rounds","10")
g_MenuCallback = menu_makecallback("menuitem_callback");
RegisterHam(Ham_Touch, "weaponbox", "hamTouchWeapon");
RegisterHam(Ham_Touch, "armoury_entity", "hamTouchWeapon");
RegisterHam(Ham_Touch, "weapon_shield", "hamTouchWeapon");
RegisterHam(Ham_TakeDamage, "player", "TakeDMG");
RegisterHam(Ham_Killed, "player", "PlayerKilled");
RegisterHam(Ham_Spawn, "player", "PlayerSpawn", 1);
RegisterHam(Ham_Player_Jump, "player", "pfw_UpdateClientData");
RegisterHam(Ham_Player_Duck, "player", "pfw_UpdateClientData");
register_forward(FM_PlayerPreThink,"FW_Prethink")
Load_Coords()
Load_Coords2()
maxplayers = get_maxplayers();
register_forward(FM_CmdStart,"Fw_Cmd_Slash");
register_forward(FM_CmdStart,"Fw_Cmd_Stab");
register_forward(FM_CmdStart,"NonStop");
register_forward(FM_UpdateClientData, "pfw_UpdateClientData", 1)
RegisterHam(Ham_TraceAttack, "player", "Forward_TraceAttack");
get_mapname(mapid,charsmax(mapid))
if(containi(mapid,"35hp") != -1)
map_default_hp = 35
else if(containi(mapid,"1hp") != -1)
map_default_hp = 1
else map_default_hp = 35
}
public plugin_cfg()
{
new cfgdir[32], urlfile[64]
get_configsdir(cfgdir, charsmax(cfgdir))
formatex(urlfile, charsmax(urlfile), "%s/plat_A", cfgdir)
if(!dir_exists(urlfile))
{
mkdir(urlfile)
server_print("%sCreated new folder: %s",CHAT_TAG,urlfile)
}
new cfdir[32], urfile[64]
get_configsdir(cfdir, charsmax(cfdir))
formatex(urfile, charsmax(urfile), "%s/plat_B", cfdir)
if(!dir_exists(urfile))
{
mkdir(urfile)
server_print("%sCreated new folder: %s",CHAT_TAG,urfile)
}
}
public KDC_Menu(id)
{
new gMenu = menu_create("\yВыбери тип дуэли:", "kdc_menu_handler")
menu_additem(gMenu, "\wОбычный", "1")
menu_additem(gMenu, "\wНон-стоп", "2")
menu_additem(gMenu, "\wТолько правой", "3")
menu_additem(gMenu, "\wТолько левой", "4")
menu_additem(gMenu, "\wТолько в голову", "5")
menu_display(id, gMenu, 0)
}
public kdc_menu_handler(id, menu, item)
{
if (item == MENU_EXIT)
{
menu_destroy(menu)
return PLUGIN_HANDLED;
}
switch(item)
{
case 0: knf_d(id)
case 1: Dont_Stop(id)
case 2: Block_Slash(id)
case 3: Block_Stab(id)
case 4: Hs_Only(id)
}
return PLUGIN_HANDLED;
}
public Fw_Cmd_Slash(id, uc_handle, seed)
{
if(!is_user_alive(id) || !slash_attack[id])
return FMRES_IGNORED;
new iButtons = get_uc(uc_handle,UC_Buttons);
new trash[2], iWeapon = get_user_weapon(id,trash[0], trash[1]);
if((iButtons & IN_ATTACK) && iWeapon == CSW_KNIFE)
{
iButtons = iButtons & ~IN_ATTACK;
set_uc(uc_handle, UC_Buttons, iButtons);
return FMRES_SUPERCEDE;
}
return FMRES_IGNORED;
}
public Fw_Cmd_Stab(id, uc_handle, seed)
{
if(!is_user_alive(id) || !stab_attack[id])
return FMRES_IGNORED;
new iButtons = get_uc(uc_handle,UC_Buttons);
new trash[2], iWeapon = get_user_weapon(id,trash[0], trash[1]);
if((iButtons & IN_ATTACK2) && iWeapon == CSW_KNIFE)
{
iButtons = iButtons & ~IN_ATTACK2;
set_uc(uc_handle, UC_Buttons, iButtons);
return FMRES_SUPERCEDE;
}
return FMRES_IGNORED;
}
public Forward_TraceAttack(iVictim, iKiller, Float:dmg, Float:dir[3], tr, dmgbit)
{
if (iVictim == iKiller || !is_user_alive(iKiller) || !hs_attack[iKiller])
return FMRES_IGNORED;
if(iKiller && get_tr2(tr, TR_iHitgroup) != HIT_HEAD)
return HAM_SUPERCEDE;
return HAM_IGNORED;
}
public knf_d(Challenged)
{
get_user_name(Challenged , szName , charsmax(szName));
set_dhudmessage(0, 206, 209, -1.0, 0.1, 0, 1.0, 5.0, 0.1, 0.2)
show_dhudmessage(Challenged, "%s выбрал обычный режим!", szName)
show_dhudmessage(g_Challenge[Challenged], "%s выбрал обычный режим!", szName)
}
public Dont_Stop(Challenged)
{
get_user_name(Challenged , szName , charsmax(szName));
if (is_user_alive(Challenged) && is_user_alive(g_Challenge[Challenged]))
{
set_task(0.5, "GoToSpawn", Challenged+SPAWN_TASK_ID);
set_task(0.5, "GoToSpawn", g_Challenge[Challenged]+SPAWN_TASK_ID);
Non_Stop[Challenged] = true
Non_Stop[g_Challenge[Challenged]] = true
set_dhudmessage(0, 206, 209, -1.0, 0.1, 0, 1.0, 5.0, 0.1, 0.2)
show_dhudmessage(Challenged, "%s выбрал режим нон-стоп!", szName)
show_dhudmessage(g_Challenge[Challenged], "%s выбрал режим нон-стоп!", szName)
}
}
public Block_Slash(Challenged)
{
get_user_name(Challenged , szName , charsmax(szName));
if (is_user_alive(Challenged) && is_user_alive(g_Challenge[Challenged]))
{
slash_attack[Challenged] = true
slash_attack[g_Challenge[Challenged]] = true
set_dhudmessage(0, 206, 209, -1.0, 0.1, 0, 1.0, 5.0, 0.1, 0.2)
show_dhudmessage(Challenged, "%s выбрал режим только правой!", szName)
show_dhudmessage(g_Challenge[Challenged], "%s выбрал режим только правой!", szName)
}
}
public Block_Stab(Challenged)
{
get_user_name(Challenged , szName , charsmax(szName));
if (is_user_alive(Challenged) && is_user_alive(g_Challenge[Challenged]))
{
stab_attack[Challenged] = true
stab_attack[g_Challenge[Challenged]] = true
set_dhudmessage(0, 206, 209, -1.0, 0.1, 0, 1.0, 5.0, 0.1, 0.2)
show_dhudmessage(Challenged, "%s выбрал режим только левой!", szName)
show_dhudmessage(g_Challenge[Challenged], "%s выбрал режим только левой!", szName)
}
}
public Hs_Only(Challenged)
{
get_user_name(Challenged , szName , charsmax(szName));
if (is_user_alive(Challenged) && is_user_alive(g_Challenge[Challenged]))
{
hs_attack[Challenged] = true
hs_attack[g_Challenge[Challenged]] = true
set_dhudmessage(0, 206, 209, -1.0, 0.1, 0, 1.0, 5.0, 0.1, 0.2)
show_dhudmessage(Challenged, "%s выбрал режим только в голову!", szName)
show_dhudmessage(g_Challenge[Challenged], "%s выбрал режим только в голову!", szName)
}
}
public client_putinserver(id)
{
his_offline[id] = false
return PLUGIN_CONTINUE
}
public toggle_offline(id)
{
his_offline[id] = !his_offline[id]
client_print_color(id, print_team_default, "^4[^3Дуэли^4] ^3Ты ^4%s ^3дуэли!", his_offline[id] ? "отключил" : "снова включил")
}
public toggle_most(id)
{
most = !most
}
public FW_Prethink(id)
{
if (pev(id,pev_button) & IN_ATTACK && pev(id,pev_button) & IN_ATTACK2)
Duel_Menu(id)
}
public Duel_Menu(id)
{
new gMenu = menu_create("\yМеню дуэлей", "Duel_menu_handler")
menu_additem(gMenu, "\wВызвать на дуэль", "0")
menu_additem(gMenu, "\wСдаться [\yВ дуэли\w]", "0")
if(!his_offline[id])
{
menu_additem(gMenu, "\wОтключить дуэли", "0")
}
else
{
menu_additem(gMenu, "\wВключить дуэли", "0")
}
if(most)
{
menu_additem(gMenu, "\wМесто: [\rМост\w]", "0")
}
else
{
menu_additem(gMenu, "\wМесто: [\rПлатформа\w]", "0")
}
menu_display(id, gMenu, 0)
}
public Duel_menu_handler(id, menu, item)
{
if (item == MENU_EXIT)
{
menu_destroy(menu)
return PLUGIN_HANDLED;
}
switch(item)
{
case 0: choose_playermenu(id, id)
case 1: End_Duel(id);
case 2: toggle_offline(id), Duel_Menu(id)
case 3: toggle_most(id), Duel_Menu(id)
}
return PLUGIN_HANDLED;
}
public client_command(id)
{
static const szJoinCommand[] = "jointeam";
static const szJoinCommand1[] = "chooseteam";
static szCommand[10];
read_argv(0, szCommand, 9);
if ((equal(szCommand, szJoinCommand) && CS_TEAM_T <= cs_get_user_team(id) <= CS_TEAM_CT)
|| equal(szCommand, szJoinCommand1))
return PLUGIN_HANDLED;
return PLUGIN_CONTINUE;
}
public hamTouchWeapon(id)
{
return 4;
}
public TakeDMG(victim, idinflictor, attacker, Float:damage, Float:direction[3], tracehandle, damagebits)
{
if (victim != attacker)
{
if (in_Duel[victim] && !in_Duel[attacker])
{
return 4;
}
}
return 1;
}
public PlayerKilled(victim, killer, shouldgib)
{
if (is_user_alive(killer))
{
new victimname[MAX_NAME_LENGTH] , attackername[MAX_NAME_LENGTH];
get_user_name(victim, victimname, charsmax(victimname));
get_user_name(killer, attackername, charsmax(attackername));
if (victim != killer && killer != 0)
{
if (in_Duel[killer] && in_Duel[victim])
{
if (killer)
{
g_DuelK[killer]+=1;
}
if (g_Challenge[killer])
{
g_DuelC[g_Challenge[killer]]+=1;
}
}
}
if (in_Duel[killer] && in_Duel[victim])
{
if(g_DuelK[killer]<get_pcvar_num(rounds) && g_DuelC[g_Challenge[killer]]<get_pcvar_num(rounds))
{
if (!g_Challenge[victim])
{
return PLUGIN_HANDLED;
}
else
{
return PLUGIN_HANDLED;
}
}
else
{
if (victim)
{
client_print_color(0, print_team_default, "^3[^4Дуэли^3] ^1%s ^3%i^4:^3%i ^1%s^3. Победил - ^4%s. ^1Награда: 10000$",
attackername,
g_DuelC[g_Challenge[killer]],
g_DuelK[victim],
victimname,
attackername);
DisableChecks(victim);
/* GoToSpawn(killer+SPAWN_TASK_ID); */
/* GoToSpawn(victim+SPAWN_TASK_ID); */
}
if (g_Challenge[victim])
{
client_print_color(0, print_team_default, "^3[^4Дуэли^3] ^1%s ^3%i^4:^3%i ^1%s^3. Победил - ^4%s. ^1Награда: 10000$",
attackername,
g_DuelK[killer],
g_DuelC[g_Challenge[victim]],
victimname,
attackername);
DisableChecks(g_Challenge[victim]);
/* GoToSpawn(killer+SPAWN_TASK_ID); */
/* GoToSpawn(victim+SPAWN_TASK_ID); */
}
ar_set_user_addxp(killer, ar_get_user_addxp ,(killer) + 777);
g_DuelC[killer] = 0;
g_DuelK[victim] = 0;
g_DuelC[victim] = 0;
g_DuelK[killer] = 0
slash_attack[victim] = false
slash_attack[g_Challenge[victim]] = false
stab_attack[victim] = false
stab_attack[g_Challenge[victim]] = false
hs_attack[victim] = false
hs_attack[g_Challenge[victim]] = false
Non_Stop[victim] = false
Non_Stop[g_Challenge[victim]] = false
slash_attack[killer] = false
slash_attack[g_Challenge[killer]] = false
stab_attack[killer] = false
stab_attack[g_Challenge[killer]] = false
hs_attack[killer] = false
hs_attack[g_Challenge[killer]] = false
Non_Stop[killer] = false
Non_Stop[g_Challenge[killer]] = false
}
}
}
return HAM_IGNORED
}
public PlayerSpawn(id)
{
new alive = is_user_alive(id);
new alive2 = is_user_alive(g_Challenge[id]);
new in_duel1 = in_Duel[id];
new in_duel2 = in_Duel[g_Challenge[id]];
client_print(0, print_console, "Player %d | alive %d | in_duel %d | pl2 %d | a %d | in_duel %d",
id, alive, in_duel1, g_Challenge[id], alive2, in_duel2);
if (alive && in_duel1 && alive2 && in_duel2)
{
whileinduel(id);
whileinduel(g_Challenge[id]);
set_user_health(id, map_default_hp);
set_user_health(g_Challenge[id], map_default_hp);
}
}
public whileinduel(id)
{
switch (g_Area[id])
{
case 1:
{
set_spawn_positions(id,vOrigin)
set_spawn_positions(g_Challenge[id],vOrigin)
}
case 2:
{
set_spawn_positions(id,fOrigin)
set_spawn_positions(g_Challenge[id],fOrigin)
}
}
}
public GoToSpawn(killer) {
killer -= SPAWN_TASK_ID;
if(is_user_connected(killer)){
ExecuteHamB(Ham_CS_RoundRespawn, killer);
}
}
public DisableChecks(id)
{
if(in_Duel[id])
{
client_print(0, print_console, "DC %d area %d | %d area %d ", id, g_Area[id], g_Challenge[id],
g_Area[g_Challenge[id]]);
if (!g_Area[id])
{
switch (g_Area[g_Challenge[id]])
{
case 1:
{
Arena1in = false;
}
case 2:
{
Arena2in = false;
}
}
dArena(g_Area[g_Challenge[id]]);
g_Area[g_Challenge[id]] = 0;
}
else
{
switch (g_Area[id])
{
case 1:
{
Arena1in = false;
}
case 2:
{
Arena2in = false;
}
}
dArena(g_Area[id])
g_Area[id] = 0;
}
in_Duel[g_Challenge[id]] = false;
in_Duel[id] = false;
slash_attack[id] = false;
slash_attack[g_Challenge[id]] = false ;
stab_attack[id] = false ;
stab_attack[g_Challenge[id]] = false ;
hs_attack[id] = false ;
hs_attack[g_Challenge[id]] = false;
Non_Stop[id] = false ;
Non_Stop[g_Challenge[id]] = false ;
}
if(g_Challenge[id])
{
new temp_id = g_Challenge[id];
g_Challenge[g_Challenge[id]] = 0;
g_Challenge[id] = 0;
GoToSpawn(id+SPAWN_TASK_ID);
GoToSpawn(temp_id+SPAWN_TASK_ID);
}
}
public client_disconnected(id)
{
new cname[MAX_NAME_LENGTH], ccname[MAX_NAME_LENGTH];
get_user_name(g_Challenge[id], ccname, charsmax(ccname));
get_user_name(g_Challenge[g_Challenge[id]], cname, charsmax(cname));
if (in_Duel[g_Challenge[id]])
{
set_task(0.5, "GoToSpawn", g_Challenge[id]+SPAWN_TASK_ID);
client_print_color(g_Challenge[id], print_team_default, "^3[^4Дуэли^3] ^4%s ^3вышел с сервера.", cname);
}
if (in_Duel[g_Challenge[g_Challenge[id]]])
{
set_task(0.5, "GoToSpawn", g_Challenge[g_Challenge[id]]+SPAWN_TASK_ID);
client_print_color(g_Challenge[g_Challenge[id]], print_team_default, "^3[^4Дуэли^3] ^4%s ^3вышел с сервера.", ccname);
}
g_DuelC[g_Challenge[id]] = 0;
g_DuelC[id] = 0;
g_DuelK[g_Challenge[id]] = 0;
g_DuelK[id] = 0;
slash_attack[id] = false
slash_attack[g_Challenge[id]] = false
stab_attack[id] = false
stab_attack[g_Challenge[id]] = false
hs_attack[id] = false
hs_attack[g_Challenge[id]] = false
Non_Stop[id] = false
Non_Stop[g_Challenge[id]] = false
his_offline[id] = false
DisableChecks(id);
}
public End_Duel(id)
{
if(in_Duel[id])
{
new his_name[33];
get_user_name(id,his_name[id],charsmax(his_name));
g_DuelC[g_Challenge[id]] = 0;
g_DuelC[id] = 0;
g_DuelK[g_Challenge[id]] = 0;
g_DuelK[id] = 0;
Non_Stop[id] = false;
Non_Stop[g_Challenge[id]] = false;
hs_attack[id] = false;
hs_attack[g_Challenge[id]] = false;
stab_attack[id] = false;
stab_attack[g_Challenge[id]] = false;
slash_attack[id] = false;
slash_attack[g_Challenge[id]] = false;
set_dhudmessage(255, 0, 0, -1.0, 0.1, 0, 1.0, 5.0, 0.1, 0.2)
show_dhudmessage(0, "%s Сдался в дуэли! Лох!", his_name[id])
client_print_color(0, print_team_default, "^4[^3Дуэли^4] %s ^3решил сдаться.", his_name[id]);
DisableChecks(id);
}
}
public choose_playermenu(Challenger, Challenged)
{
if ((!in_Duel[Challenger] && is_user_alive(Challenger)) && (Arena1in && Arena2in))
{
client_print_color(Challenger, print_team_default, "^3[^4Дуэли^3] Все арены заняты.");
return PLUGIN_HANDLED
}
if(his_offline[Challenged])
{
client_print_color(Challenger, print_team_default, "^3[^4Дуэли^3] Ты не можешь вызывать на дуэль, когда ты их ^4отключил.")
return PLUGIN_HANDLED
}
if(!available_duelers(Challenged))
{
client_print_color(Challenged, print_team_default, "%s^4Некого^1 вызвать на дуэль.",CHAT_TAG)
return PLUGIN_HANDLED
}
if (in_Duel[Challenger] || !is_user_alive(Challenger))
return PLUGIN_HANDLED
new menu = menu_create("\y[\rДуэль\y]", "choose_playermenu_handler");
menu_additem(menu, "\r[!]\yОбновить список\r[!]^n\wВыбери, кого вызвать:", "0", 0);
new players[MAX_PLAYERS], pnum;
new szName[MAX_NAME_LENGTH], szTempid[32], Desc[64];
get_players(players, pnum);
for (new i; i < pnum; i++)
{
Challenged = players[i];
if (is_user_alive(Challenged) && (Challenger != Challenged))
{
get_user_name(Challenged, szName, charsmax(szName));
formatex(Desc, charsmax(Desc), in_Duel[Challenged] ? "\d%s \y[\rВ дуэли\y]" : "%s", szName);
if(his_offline[Challenged])
{
formatex(Desc, charsmax(Desc), his_offline[Challenged] ? "\d%s \y[\rОтключил дуэли\y]" : "%s", szName);
}
num_to_str(Challenged, szTempid, charsmax(szTempid));
menu_additem(menu, Desc, szTempid, 0, g_MenuCallback);
}
}
menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
menu_display(Challenger, menu, 0);
return PLUGIN_HANDLED
}
public menuitem_callback(Challenger, menu, item)
{
new data[6], szName[64];
new access, callback;
menu_item_getinfo(menu, item, access, data, charsmax(data), szName,charsmax(szName), callback);
new tempid = str_to_num(data);
if ((in_Duel[tempid] || !is_user_alive(tempid)) || his_offline[tempid])
return ITEM_DISABLED;
return ITEM_ENABLED;
}
public choose_playermenu_handler(Challenger, menu, item)
{
if (item == MENU_EXIT)
{
menu_destroy(menu);
return PLUGIN_HANDLED;
}
new data[6], szName[64];
new access, callback;
menu_item_getinfo(menu, item, access, data,charsmax(data), szName, charsmax(szName), callback);
new tempid = str_to_num(data);
switch(item)
{
case 0: choose_playermenu(Challenger, Challenger);
}
if (is_user_alive(tempid) && !in_Duel[tempid])
{
g_Challenge[Challenger] = tempid;
g_Challenge[tempid] = Challenger;
Questionm(tempid);
}
menu_destroy(menu);
return PLUGIN_HANDLED;
}
public Questionm(Challenged)
{
if (is_user_alive(Challenged) && is_user_alive(g_Challenge[Challenged]))
{
new szAddItemText[555 char], ChallengerName[MAX_NAME_LENGTH];
get_user_name(g_Challenge[Challenged], ChallengerName, charsmax(ChallengerName));
format(szAddItemText, charsmax(szAddItemText), "\r%s \wвызывает тебя на дуэль.^n\yПринять?", ChallengerName);
new menu = menu_create(szAddItemText, "Questionm_handler")
menu_additem(menu, "\wДа!", "1", 0);
menu_additem(menu, "\wНет!", "2", 0);
menu_setprop(menu, MPROP_PERPAGE, 0);
menu_display(Challenged, menu, 0);
return PLUGIN_HANDLED
}
return PLUGIN_HANDLED
}
public Questionm_handler(Challenged, menu, item)
{
new data[6], szName[64], ccname[MAX_NAME_LENGTH], cname[MAX_NAME_LENGTH];
new access, callback;
menu_item_getinfo(menu, item, access, data, charsmax(data), szName, charsmax(szName), callback);
new key = str_to_num(data);
get_user_name(Challenged, ccname, charsmax(ccname));
get_user_name(g_Challenge[Challenged], cname, charsmax(cname));
switch(key)
{
case 1:
{
if (in_Duel[g_Challenge[Challenged]])
{
if (task_exists(Challenged))
{
menu_destroy(menu);
remove_task(Challenged);
}
client_print_color(Challenged, print_team_default, "^3[^4Дуэли^3] ^4Ты опоздал, ^3%s ^4начал другую дуэль.", cname);
DisableChecks(Challenged);
return PLUGIN_HANDLED
}
if (!is_user_alive(Challenged))
{
if (task_exists(Challenged))
{
menu_destroy(menu);
remove_task(Challenged);
}
client_print_color(Challenged, print_team_default, "^3[^4Дуэли^3] ^4Ты ^3мёртв.", ccname);
DisableChecks(Challenged);
return PLUGIN_HANDLED
}
if (!is_user_alive(g_Challenge[Challenged]))
{
if (task_exists(Challenged))
{
menu_destroy(menu);
remove_task(Challenged);
}
client_print_color(Challenged, print_team_default, "^3[^4Дуэли^3] ^4%s ^3мертв или вышел.", cname);
DisableChecks(Challenged);
return PLUGIN_HANDLED
}
if (task_exists(Challenged))
{
menu_destroy(menu);
remove_task(Challenged);
}
if (!g_Challenge[Challenged])
{
menu_destroy(menu);
return PLUGIN_HANDLED
}
else
{
new chId = Challenged;
new chOppositeId = g_Challenge[Challenged];
g_Challenge[chId] = chOppositeId;
g_Challenge[chOppositeId] = chId;
choose_area(chId);
client_print_color(0, print_team_default,
"^3[^4Дуэли^3] ^3Началась дуэль ^4%s ^3против ^4%s^3.", ccname, cname);
in_Duel[chId] = true;
in_Duel[chOppositeId] = true;
}
return PLUGIN_HANDLED
}
case 2:
{
if (task_exists(Challenged))
{
menu_destroy(menu);
remove_task(Challenged);
}
client_print_color(g_Challenge[Challenged], print_team_default, "^3[^4Дуэли^3] ^4%s ^3отклонил твой вызов.", ccname);
DisableChecks(Challenged);
return PLUGIN_HANDLED
}
}
menu_destroy(menu);
return PLUGIN_HANDLED
}
public choose_area(Challenged)
{
if (cs_get_user_team(g_Challenge[Challenged]) == cs_get_user_team(Challenged))
{
switch (cs_get_user_team(g_Challenge[Challenged]))
{
case CS_TEAM_CT: cs_set_user_team(Challenged, CS_TEAM_T, CS_T_LEET);
case CS_TEAM_T: cs_set_user_team(Challenged, CS_TEAM_CT, CS_CT_GIGN);
}
}
g_Area[Challenged] = 1;
g_Area[g_Challenge[Challenged]] = 1;
switch (g_Area[Challenged])
{
case 1:
{
if (Arena1in) { g_Area[Challenged]+=1; }
switch (g_Area[Challenged])
{
case 2:
{
if (Arena2in)
{
new cccname[MAX_NAME_LENGTH];
get_user_name(Challenged, cccname, charsmax(cccname));
client_print_color(Challenged, print_team_default, "^3[^4Дуэли^3] Все арены заняты, ты слишком долго думаешь.");
client_print_color(g_Challenge[Challenged], print_team_default, "^3[^4Дуэли^3] Все арены заняты ^4%s ^3слишком долго думал.", cccname);
DisableChecks(Challenged);
}
}
}
}
}
startduel(Challenged);
}
public startduel(Challenged)
{
if (task_exists(Challenged+SPAWN_TASK_ID))
{
remove_task(Challenged + SPAWN_TASK_ID);
}
set_user_health(Challenged, map_default_hp);
set_user_health(g_Challenge[Challenged], map_default_hp);
set_user_armor(Challenged, 0);
set_user_armor(g_Challenge[Challenged], 0);
strip_user_weapons(Challenged);
strip_user_weapons(g_Challenge[Challenged]);
give_item(Challenged, "weapon_knife");
give_item(g_Challenge[Challenged], "weapon_knife");
set_user_maxspeed(Challenged, 250.0);
set_user_maxspeed(g_Challenge[Challenged], 250.0);
set_user_gravity(Challenged, 1.0);
set_user_gravity(g_Challenge[Challenged], 1.0);
KDC_Menu(g_Challenge[Challenged])
switch (g_Area[Challenged])
{
case 1:
{
Arena1in = true;
makewall1()
set_spawn_positions(Challenged,vOrigin)
set_spawn_positions(g_Challenge[Challenged],vOrigin)
}
case 2:
{
Arena2in = true;
makewall2()
set_spawn_positions(Challenged,fOrigin)
set_spawn_positions(g_Challenge[Challenged],fOrigin)
}
}
most = false
return PLUGIN_HANDLED
}
public plugin_precache()
{
precache_model(DATE)
precache_model(DATE2)
}
public client_PostThink(id)
{
if(is_user_alive(id) && in_Duel[id])
{
new flags = entity_get_int(id, EV_INT_flags);
new Float:origin[3], Float:dest[3];
entity_get_vector(id, EV_VEC_origin, origin);
dest[0] = origin[0];
dest[1] = origin[1];
dest[2] = origin[2] + 340.0;
new ptr = create_tr2();
engfunc(EngFunc_TraceHull, origin, dest, 0, flags & FL_DUCKING ? HULL_HEAD : HULL_HUMAN, id, ptr);
new Float:flFraction;
get_tr2(ptr, TR_flFraction, flFraction);
if(flFraction >= 1.0)
{
ExecuteHamB(Ham_CS_RoundRespawn, id)
//user_kill(id)
client_print_color(id, print_team_default, "^4[^3Дуэли^4] ^3Не покидай ^4арену.");
free_tr2(ptr);
return;
}
get_tr2(ptr, TR_vecPlaneNormal, dest);
free_tr2(ptr);
}
}
public NonStop(id)
{
if(in_Duel[id] && Non_Stop[id])
{
set_user_health(id, 65)
if(get_user_team(id) == 1)
{
fVelocity[0] = 260.0;
fVelocity[1] = 0.0;
fVelocity[2] = 0.0;
set_pev(id, pev_velocity, fVelocity)
}
if(get_user_team(id) == 2)
{
fVelocity[0] = -260.0;
fVelocity[1] = 0.0;
fVelocity[2] = 0.0;
set_pev(id, pev_velocity, fVelocity)
}
}
}
public pfw_UpdateClientData(id, weapons, cd)
{
if(in_Duel[id] && Non_Stop[id])
{
set_cd(cd, CD_flNextAttack, 1.0)
if((entity_get_int(id, EV_INT_button) & (IN_BACK | IN_MOVELEFT | IN_MOVERIGHT)))
set_cd(cd, CD_MaxSpeed, 1.0)
static iOldbuttons;
iOldbuttons = entity_get_int(id, EV_INT_oldbuttons)
if(!(iOldbuttons & IN_JUMP & IN_DUCK))
{
entity_set_int(id, EV_INT_oldbuttons, iOldbuttons | IN_JUMP | IN_DUCK)
return HAM_HANDLED
}
return HAM_IGNORED
}
return FMRES_IGNORED
}
stock dArena(const iarena)
{
new ent = -1;
switch (iarena)
{
case 1:
{
while ((ent = find_ent_by_class(ent, "ARENA_NUMBER_A")))
{
remove_entity(ent);
}
}
case 2:
{
while ((ent = find_ent_by_class(ent, "ARENA_NUMBER_B")))
{
remove_entity(ent);
}
}
}
}
public EntityMenu(id)
{
new flags = get_user_flags(id)
if(!(flags & ADMIN_RCON))
{
client_print(id,print_chat,"^4У тебя ^3нет доступа ^4к настройке дуэлей")
return PLUGIN_HANDLED
}
new gMenu = menu_create("\yНастройка дуэли", "entity_menu")
menu_additem(gMenu, "\wАрена A", "0")
menu_additem(gMenu, "\wАрена B", "0")
menu_additem(gMenu, "\wДвигать арену", "0")
menu_additem(gMenu, "\wСохранить арену A", "0")
menu_additem(gMenu, "\wСохранить арену B", "0")
menu_additem(gMenu, "\wУдалить арену", "0")
menu_display(id, gMenu, 0)
return PLUGIN_HANDLED;
}
public entity_menu(id, menu, item, code)
{
if (item == MENU_EXIT)
{
menu_destroy(menu)
return PLUGIN_HANDLED;
}
switch(item)
{
case 0: Make_Entity(id)
case 1: Make_Entity2(id)
case 2: move_menu(id,code)
case 3: save_first_arena(id)
case 4: save_second_arena(id)
case 5: remove_arena(id)
}
return PLUGIN_HANDLED;
}
public Make_Entity(id)
{
if(!is_user_connected(id))
return PLUGIN_HANDLED
static Float:xorigin[3];
get_user_hitpoint(id,xorigin)
Entity = create_entity("info_target");
if(fake_arena_exists_a(id))
{
client_print_color(id, print_team_default, "%s ^3Maximum arenas reached.^1",CHAT_TAG)
return PLUGIN_HANDLED
}
if(is_valid_ent(Entity))
{
entity_set_string(Entity , EV_SZ_classname, "ARENA_NUMBER_A");
entity_set_int(Entity , EV_INT_solid, SOLID_BBOX);
entity_set_model(Entity , DATE);
entity_set_size(Entity , Float:{ -350.0, -230.0, 0.0 }, Float:{ 350.0, 230.0, 10.0 });
entity_set_origin(Entity, xorigin);
}
EntityMenu(id)
return PLUGIN_HANDLED
}
public Make_Entity2(id)
{
if(!is_user_connected(id))
return PLUGIN_HANDLED
static Float:xorigin[3];
get_user_hitpoint(id,xorigin)
Entity = create_entity("info_target");
if(fake_arena_exists_b(id))
{
client_print_color(id, print_team_default, "%s ^3Maximum arenas reached.^1",CHAT_TAG)
return PLUGIN_HANDLED
}
if(is_valid_ent(Entity))
{
entity_set_string(Entity , EV_SZ_classname, "ARENA_NUMBER_B");
entity_set_int(Entity , EV_INT_solid, SOLID_BBOX);
entity_set_model(Entity , DATE);
entity_set_size(Entity , Float:{ -350.0, -230.0, 0.0 }, Float:{ 350.0, 230.0, 10.0 });
entity_set_origin(Entity, xorigin);
}
EntityMenu(id)
return PLUGIN_HANDLED
}
public remove_arena(id)
{
new ent = -1;
while ((ent = find_ent_by_class(ent, "ARENA_NUMBER_A")))
{
remove_entity(ent);
}
while ((ent = find_ent_by_class(ent, "ARENA_NUMBER_B")))
{
remove_entity(ent);
}
EntityMenu(id)
}
public move_menu(id,code)
{
new menu
menu = menu_create("\rMove arena:", "move_handler");
new nameu[32];
new code_t[32];
num_to_str(code,code_t,charsmax(code_t))
formatex(nameu,charsmax(nameu), "Move up");
menu_additem(menu, nameu, code_t, 0);
formatex(nameu,charsmax(nameu), "Move down");
menu_additem(menu, nameu, code_t, 0);
formatex(nameu,charsmax(nameu), "Move front");
menu_additem(menu, nameu, code_t, 0);
formatex(nameu,charsmax(nameu), "Move back");
menu_additem(menu, nameu, code_t, 0);
formatex(nameu,charsmax(nameu), "Move right");
menu_additem(menu, nameu, code_t, 0);
formatex(nameu,charsmax(nameu), "Move left");
menu_additem(menu, nameu, code_t, 0);
formatex(nameu,charsmax(nameu), "Move size: %.2f",move_size[id]);
menu_additem(menu, nameu, code_t, 0);
menu_display(id, menu, 0);
return PLUGIN_HANDLED
}
public move_handler(id, menu, item)
{
if (item == MENU_EXIT)
{
menu_destroy(menu);
return PLUGIN_HANDLED;
}
new szData[32], szName[64];
new _access, item_callback;
menu_item_getinfo(menu, item, _access, szData,charsmax(szData), szName,charsmax(szName), item_callback);
new code = str_to_num(szData)
if(containi(szName,"move size:") != -1)
{
move_size[id]+= 10.0
if(move_size[id] > 100.0)
{
move_size[id] = 10.0
}
}
else if(equali(szName,"move up"))
{
move_the_fake_arena(id,code,MOVE_UP)
}
else if(equali(szName,"move down"))
{
move_the_fake_arena(id,code,MOVE_DOWN)
}
else if(equali(szName,"move right"))
{
move_the_fake_arena(id,code,MOVE_RIGHT)
}
else if(equali(szName,"move left"))
{
move_the_fake_arena(id,code,MOVE_LEFT)
}
else if(equali(szName,"move front"))
{
move_the_fake_arena(id,code,MOVE_FRONT)
}
else if(equali(szName,"move back"))
{
move_the_fake_arena(id,code,MOVE_BACK)
}
menu_destroy(menu);
move_menu(id,code)
return PLUGIN_CONTINUE;
}
public move_the_fake_arena(id,code,moveto)
{
new ent = -1;
new Float:origin[3];
while ((ent = find_ent_by_class(ent, "ARENA_NUMBER_A")))
{
pev(ent,pev_origin,origin);
switch(moveto)
{
case MOVE_UP:
{
origin[2]+=move_size[id]
}
case MOVE_DOWN:
{
origin[2]-=move_size[id]
}
case MOVE_RIGHT:
{
origin[1]+=move_size[id]
}
case MOVE_LEFT:
{
origin[1]-=move_size[id]
}
case MOVE_FRONT:
{
origin[0]+=move_size[id]
}
case MOVE_BACK:
{
origin[0]-=move_size[id]
}
}
engfunc(EngFunc_SetOrigin,ent,origin);
}
while ((ent = find_ent_by_class(ent, "ARENA_NUMBER_B")))
{
pev(ent,pev_origin,origin);
switch(moveto)
{
case MOVE_UP:
{
origin[2]+=move_size[id]
}
case MOVE_DOWN:
{
origin[2]-=move_size[id]
}
case MOVE_RIGHT:
{
origin[1]+=move_size[id]
}
case MOVE_LEFT:
{
origin[1]-=move_size[id]
}
case MOVE_FRONT:
{
origin[0]+=move_size[id]
}
case MOVE_BACK:
{
origin[0]-=move_size[id]
}
}
engfunc(EngFunc_SetOrigin,ent,origin);
}
}
public save_first_arena(id)
{
new found;
new cfgdir[32], mapname[32], urlfile[64]
get_configsdir(cfgdir, charsmax(cfgdir))
get_mapname(mapname, charsmax(mapname))
formatex(urlfile, charsmax(urlfile), ARENA_FILE_AAA, cfgdir, mapname)
if (file_exists(urlfile))
delete_file(urlfile)
new lineset[128]
new Float:origin[3]
new ent=-1;
while ((ent = find_ent_by_class(ent, "ARENA_NUMBER_A")))
{
found++
pev(ent,pev_origin,origin);
format(lineset, charsmax(lineset), "%.f %.f %.f", origin[0], origin[1], origin[2])
write_file(urlfile, lineset,found)
}
if(!found)
client_print_color(id, print_team_default, "%s Couldn't save:^3No arenas found.",CHAT_TAG)
else client_print_color(id, print_team_default, "%s %d ^3Arena Number 1 coords saved.",CHAT_TAG,found)
EntityMenu(id)
Load_Coords()
Load_Coords2()
}
public save_second_arena(id)
{
new found;
new cfdir[32], mapname[32], urfile[64]
get_configsdir(cfdir, charsmax(cfdir))
get_mapname(mapname, charsmax(mapname))
formatex(urfile, charsmax(urfile), ARENA_FILE_BBB, cfdir, mapname)
if (file_exists(urfile))
delete_file(urfile)
new lineset[128]
new Float:origin[3]
new ent=-1;
while ((ent = find_ent_by_class(ent, "ARENA_NUMBER_B")))
{
found++
pev(ent,pev_origin,origin);
format(lineset, charsmax(lineset), "%.f %.f %.f", origin[0], origin[1], origin[2])
write_file(urfile, lineset,found)
}
if(!found)
client_print_color(id, print_team_default, "%s Couldn't save:^3No arenas found.",CHAT_TAG)
else client_print_color(id, print_team_default, "%s %d ^3Arena Number 2 coords saved.",CHAT_TAG,found)
EntityMenu(id)
Load_Coords()
Load_Coords2()
}
public Load_Coords()
{
new cfgdir[32], mapname[32], filepath[512]
get_configsdir(cfgdir, charsmax(cfgdir))
get_mapname(mapname, charsmax(mapname))
new readdata[128]
new txtlen
formatex(filepath, charsmax(filepath), ARENA_FILE_AAA, cfgdir, mapname)
if (file_exists(filepath))
{
new sOrigins[3][16];
new i
new fsize = file_size(filepath,1)
for (new line=0;line<=fsize;line++)
{
read_file(filepath,line,readdata,127,txtlen)
parse(readdata, sOrigins[0], 15, sOrigins[1], 15, sOrigins[2], 15)
for(i = 0; i < 3; i++)
{
vOrigin[i] = str_to_float(sOrigins[i])
}
}
}
return PLUGIN_CONTINUE
}
public Load_Coords2()
{
new cfgdir[32], mapname[32], filepath[512]
get_configsdir(cfgdir, charsmax(cfgdir))
get_mapname(mapname, charsmax(mapname))
new readdata[128]
new txtlen
formatex(filepath, charsmax(filepath), ARENA_FILE_BBB, cfgdir, mapname)
if (file_exists(filepath))
{
new sOrigins[3][16];
new i
new fsize = file_size(filepath,1)
for (new line=0;line<=fsize;line++)
{
read_file(filepath,line,readdata,127,txtlen)
parse(readdata, sOrigins[0], 15, sOrigins[1], 15, sOrigins[2], 15)
for(i = 0; i < 3; i++)
{
fOrigin[i] = str_to_float(sOrigins[i])
}
}
}
return PLUGIN_CONTINUE
}
public fake_arena_exists_a(code)
{
new ent = -1
while ((ent = find_ent_by_class(ent, "ARENA_NUMBER_A")))
{
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
public fake_arena_exists_b(code)
{
new ent = -1
while ((ent = find_ent_by_class(ent, "ARENA_NUMBER_B")))
{
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
public makewall1()
{
Entity = create_entity("info_target");
if(is_valid_ent(Entity))
{
if(most)
{
entity_set_string(Entity , EV_SZ_classname, "ARENA_NUMBER_A");
entity_set_int(Entity , EV_INT_solid, SOLID_BBOX);
entity_set_model(Entity , DATE2);
entity_set_size(Entity , Float:{ -352.0, -11.0, 0.0 }, Float:{ 352.0, 11.0, 10.0 });
entity_set_origin(Entity, vOrigin);
}
else
{
entity_set_string(Entity , EV_SZ_classname, "ARENA_NUMBER_A");
entity_set_int(Entity , EV_INT_solid, SOLID_BBOX);
entity_set_model(Entity , DATE);
entity_set_size(Entity , Float:{ -347.0, -222.0, 0.0 }, Float:{ 347.0, 222.0, 10.0 });
entity_set_origin(Entity, vOrigin);
}
}
}
public makewall2()
{
Entity = create_entity("info_target");
if(is_valid_ent(Entity))
{
if(most)
{
entity_set_string(Entity , EV_SZ_classname, "ARENA_NUMBER_B");
entity_set_int(Entity , EV_INT_solid, SOLID_BBOX);
entity_set_model(Entity , DATE2);
entity_set_size(Entity , Float:{ -352.0, -11.0, 0.0 }, Float:{ 352.0, 11.0, 10.0 });
entity_set_origin(Entity, fOrigin);
}
else
{
entity_set_string(Entity , EV_SZ_classname, "ARENA_NUMBER_B");
entity_set_int(Entity , EV_INT_solid, SOLID_BBOX);
entity_set_model(Entity , DATE);
entity_set_size(Entity , Float:{ -347.0, -222.0, 0.0 }, Float:{ 347.0, 222.0, 10.0 });
entity_set_origin(Entity, fOrigin);
}
}
}
public set_spawn_positions(id,Float:origin[3])
{
if(!is_user_connected(id))return;
if(cs_get_user_team(id) == CS_TEAM_T)
{
his_spawn[id][0] = origin[0]-320.0;
his_spawn[id][1] = origin[1];
his_spawn[id][2] = origin[2]+50.0;
set_Angle(id, Float:{0.0, 0.0, 0.0});
}
else if(cs_get_user_team(id) == CS_TEAM_CT)
{
his_spawn[id][0] = origin[0]+320.0;
his_spawn[id][1] = origin[1];
his_spawn[id][2] = origin[2]+50.0;
set_Angle(id, Float:{0.0, 180.0, 0.0});
}
entity_set_origin(id,his_spawn[id]);
}
public stuck_check(Float:origin[3],Float:radius)
{
new player=-1;
while((player = find_ent_in_sphere(player,origin,radius)) != 0)
{
if(is_user_alive(player))
{
if(is_player_stuck(player))
{
his_spawn[player][0] = origin[0]
his_spawn[player][1] = origin[1]
his_spawn[player][2] = origin[2]+50.0
entity_set_origin(player,his_spawn[player])
}
}
}
}
stock set_Angle(index , Float:fAngle[ 3 ])
{
entity_set_vector(index , EV_VEC_angles , fAngle);
entity_set_int(index , EV_INT_fixangle , 1);
}
stock get_user_hitpoint(id,Float:hOrigin[3]) {
if(!is_user_alive(id))
return 0;
new Float:fOrigin[3],Float:fvAngle[3],Float:fvOffset[3],Float:fvOrigin[3],Float:feOrigin[3];
new Float:fTemp[3];
pev(id,pev_origin,fOrigin);
pev(id,pev_v_angle,fvAngle);
pev(id,pev_view_ofs,fvOffset);
xs_vec_add(fOrigin,fvOffset,fvOrigin);
engfunc(EngFunc_AngleVectors,fvAngle,feOrigin,fTemp,fTemp);
xs_vec_mul_scalar(feOrigin,9999.9,feOrigin);
xs_vec_add(fvOrigin,feOrigin,feOrigin);
engfunc(EngFunc_TraceLine,fvOrigin,feOrigin,0,id);
global_get(glb_trace_endpos,hOrigin);
return 1;
}
stock is_player_stuck(id)
{
static Float:originF[3]
pev(id, pev_origin, originF)
engfunc(EngFunc_TraceHull, originF, originF, 0, (pev(id, pev_flags) & FL_DUCKING) ? HULL_HEAD : HULL_HUMAN, id, 0)
if (get_tr2(0, TR_StartSolid) || get_tr2(0, TR_AllSolid) || !get_tr2(0, TR_InOpen))
return true;
return false;
}
stock available_duelers(asker)
{
new num;
num = 0 // just incase...
for(new id;id < maxplayers;id++)
{
if(is_user_alive(id))
{
if(/*!in_Duel[id] && */id != asker && !is_user_bot(id))
{
num++
}
}
}
return num
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1048\\ f0\\ fs16 \n\\ par }
*/