#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta>
#include <fun>
#include <zombieplague>
#define PLUGIN "AdvancedHook"
#define VERSION "1.0"
#define AUTHOR "_RedGamer_"
// Не трогать! Пункты для меню
#define Menu_Keys (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7)|(1<<8)|(1<<9)
// Флаги доступа
#define OneFlag ADMIN_LEVEL_G // Флаг - "s"
#define TwoFlag ADMIN_MENU // Флаг - "u"
// Настройка полоски от паутинки
#define TRAIL_LIFE 10
#define TRAIL_WIDTH 10
#define TRAIL_RED 0
#define TRAIL_GREEN 0
#define TRAIL_BLUE 255
#define TRAIL_BRIGTHNESS 220
// Конец настройки полосы от паутинки
// Лимиты паутинки
#define LimitFlagsOne 10 // Лимит использований на раунд(Владелец)
#define LimitFlagsTwo 20 // Лимит использований на раунд(Создатель)
// Связано с предыдущей страницей меню
#define PLAYERS_PER_PAGE 8 //Количество игроков на 1-ой странице
new g_iMenuPlayers[33][32], g_iMenuPosition[33], szPlayerHook[33], szBreakEnd[33];
new g_pEndSpriteBreak[4], g_LoadColor[81], g_LoadSprite[81], g_LoadSound[81], bool:g_iHookEnable = true;
new szPlayerColor[33], szPlayerSprite[33], szPlayerSize[33], szPlayerSound[33], szPlayerSpeed[33], szPlayerView[33], szPlayerEndSprite[33], szPlayerHookOrigin[33][3];
new g_HookColorNum, g_HookColorDefault, g_HookColorName[999][64], g_HookColorRGB[999][4];
new g_HookSpriteNum, g_HookSpriteDefault, g_HookSpriteName[999][64], g_HookSpriteFile[999][64], g_HookSpriteMsg[999];
new g_HookSoundNum, g_HookSoundDefault, g_HookSoundName[999][64], g_HookSoundFile[999][64];
new LimitHook[33]
new g_ScreenFade
new gTrail
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("+hook", "EnableHook")
register_clcmd("-hook", "DisableHook")
register_clcmd("hook_menu", "AdvancedHookMenu")
register_dictionary("zp_advanced_hook.txt")
register_menucmd(register_menuid("Show_AdvancedHookMenu"), Menu_Keys, "Handle_AdvancedHookMenu")
register_menucmd(register_menuid("Show_AdvancedHookTargetMenu"), Menu_Keys, "Handle_AdvancedHookTargetMenu")
register_event("HLTV", "EventRoundStart", "a", "1=0", "2=0")
g_ScreenFade = get_user_msgid("ScreenFade")
}
public EventRoundStart()
{
for(new id = 1; id <= get_maxplayers(); id++)
{
if(get_user_flags(id) & TwoFlag)
{
LimitHook[id] = LimitFlagsTwo
}
else if(get_user_flags(id) & OneFlag)
{
LimitHook[id] = LimitFlagsOne
}
}
}
public plugin_precache()
{
new g_LoadDir[81]
get_configsdir(g_LoadDir, charsmax(g_LoadDir))
formatex(g_LoadDir, charsmax(g_LoadDir), "%s/AdvancedHook", g_LoadDir)
if(!dir_exists(g_LoadDir))
{
new szError[512]
formatex(szError, charsmax(szError), "%L", 0, "ADVANCED_HOOK_ERROR")
set_fail_state(szError)
}
formatex(g_LoadColor, charsmax(g_LoadColor), "%s/advanced_hook_color.ini", g_LoadDir)
formatex(g_LoadSprite, charsmax(g_LoadSprite), "%s/advanced_hook_sprite.ini", g_LoadDir)
formatex(g_LoadSound, charsmax(g_LoadSound), "%s/advanced_hook_sound.ini", g_LoadDir)
if(!file_exists(g_LoadColor))
{
new szError[512]
formatex(szError, charsmax(szError), "%L", 0, "ADVANCED_HOOK_ERROR_COLOR")
set_fail_state(szError)
}
if(!file_exists(g_LoadSprite))
{
new szError[512]
formatex(szError, charsmax(szError), "%L", 0, "ADVANCED_HOOK_ERROR_SPRITE")
set_fail_state(szError)
}
if(!file_exists(g_LoadSound))
{
new szError[512]
formatex(szError, charsmax(szError), "%L", 0, "ADVANCED_HOOK_ERROR_SOUND")
set_fail_state(szError)
}
set_task(0.5, "LoadColor")
set_task(0.5, "LoadSprite")
set_task(0.5, "LoadSound")
new szParse[320], szParseName[64], szParseFile[256], szLine, szNum, szNums
for(szLine = 0; read_file(g_LoadSprite, szLine, szParse, charsmax(szParse), szNum); szLine++)
{
if(szNum > 0 && szParse[0] != ';')
{
++szNums
parse(szParse, szParseFile, charsmax(szParseFile), szParseFile, charsmax(szParseFile))
g_HookSpriteMsg[szNums] = precache_model(szParseFile)
}
}
for(szLine = 0; read_file(g_LoadSound, szLine, szParse, charsmax(szParse), szNum); szLine++)
{
if(szNum > 0 && szParse[0] != ';')
{
++szNums
parse(szParse, szParseFile, charsmax(szParseFile), szParseFile, charsmax(szParseFile))
precache_sound(szParseFile)
}
}
szParseName = szParseName
g_pEndSpriteBreak[0] = engfunc(EngFunc_PrecacheModel, "sprites/AdvancedHook/end_7.spr");
g_pEndSpriteBreak[1] = engfunc(EngFunc_PrecacheModel, "sprites/AdvancedHook/end_6.spr");
g_pEndSpriteBreak[2] = engfunc(EngFunc_PrecacheModel, "sprites/AdvancedHook/end_3.spr");
g_pEndSpriteBreak[3] = engfunc(EngFunc_PrecacheModel, "sprites/AdvancedHook/end_4.spr");
gTrail = precache_model("sprites/AdvancedHook/speed.spr");
}
public LoadColor()
{
new szParse[256], szParseName[64], szParseColor[32], szParseDefault[32], szParseRed[32], szParseGreen[32], szParseBlue[32], szParseDefaultNum, szLine, szNum
for(szLine = 0; read_file(g_LoadColor, szLine, szParse, charsmax(szParse), szNum); szLine++)
{
if(szNum > 0 && szParse[0] != ';' && szParse[0] != '?')
{
++g_HookColorNum
parse(szParse, szParseName, charsmax(szParseName), szParseColor, charsmax(szParseColor), szParseDefault, charsmax(szParseDefault))
parse(szParseColor, szParseRed, charsmax(szParseRed), szParseGreen, charsmax(szParseGreen), szParseBlue, charsmax(szParseBlue))
g_HookColorName[g_HookColorNum] = szParseName
g_HookColorRGB[g_HookColorNum][0] = str_to_num(szParseRed)
g_HookColorRGB[g_HookColorNum][1] = str_to_num(szParseGreen)
g_HookColorRGB[g_HookColorNum][2] = str_to_num(szParseBlue)
szParseDefaultNum = str_to_num(szParseDefault)
if(szParseDefaultNum && !g_HookColorDefault)
{
g_HookColorDefault = g_HookColorNum
}
}
}
if(!g_HookColorNum)
{
new szError[512]
formatex(szError, charsmax(szError), "%L", 0, "ADVANCED_HOOK_NOCOLOR")
set_fail_state(szError)
}
if(!g_HookColorDefault)
{
new szError[512]
formatex(szError, charsmax(szError), "%L", 0, "ADVANCED_HOOK_NOCOLOR_DEFAULT")
set_fail_state(szError)
}
}
public LoadSprite()
{
new szParse[256], szParseName[64], szParseFile[32], szParseDefault[32], szParseDefaultNum, szLine, szNum
for(szLine = 0; read_file(g_LoadSprite, szLine, szParse, charsmax(szParse), szNum); szLine++)
{
if(szNum > 0 && szParse[0] != ';' && szParse[0] != '?')
{
++g_HookSpriteNum
parse(szParse, szParseName, charsmax(szParseName), szParseFile, charsmax(szParseFile), szParseDefault, charsmax(szParseDefault))
g_HookSpriteName[g_HookSpriteNum] = szParseName
g_HookSpriteFile[g_HookSpriteNum] = szParseFile
szParseDefaultNum = str_to_num(szParseDefault)
if(szParseDefaultNum)
{
if(!g_HookSpriteDefault)
{
g_HookSpriteDefault = g_HookSpriteNum
}
}
}
}
if(!g_HookSpriteNum)
{
new szError[512]
formatex(szError, charsmax(szError), "%L", 0, "ADVANCED_HOOK_NOSPRITE")
set_fail_state(szError)
}
if(!g_HookSpriteDefault)
{
new szError[512]
formatex(szError, charsmax(szError), "%L", 0, "ADVANCED_HOOK_NOSPRITE_DEFAULT")
set_fail_state(szError)
}
}
public LoadSound()
{
new szParse[256], szParseName[64], szParseFile[32], szParseDefault[32], szParseDefaultNum, szLine, szNum
for(szLine = 0; read_file(g_LoadSound, szLine, szParse, charsmax(szParse), szNum); szLine++)
{
if(szNum > 0 && szParse[0] != ';' && szParse[0] != '?')
{
++g_HookSoundNum
parse(szParse, szParseName, charsmax(szParseName), szParseFile, charsmax(szParseFile), szParseDefault, charsmax(szParseDefault))
g_HookSoundName[g_HookSoundNum] = szParseName
g_HookSoundFile[g_HookSoundNum] = szParseFile
szParseDefaultNum = str_to_num(szParseDefault)
if(szParseDefaultNum && !g_HookSoundDefault)
{
g_HookSoundDefault = g_HookSoundNum
}
}
}
if(!g_HookSoundNum)
{
new szError[512]
formatex(szError, charsmax(szError), "%L", 0, "ADVANCED_HOOK_NOSOUND")
set_fail_state(szError)
}
if(!g_HookSoundDefault)
{
new szError[512]
formatex(szError, charsmax(szError), "%L", 0, "ADVANCED_HOOK_NOSOUND_DEFAULT")
set_fail_state(szError)
}
}
public client_putinserver(id)
{
if(get_user_flags(id) & OneFlag | TwoFlag)
{
szPlayerHook[id] = true;
szPlayerColor[id] = g_HookColorDefault
szPlayerSprite[id] = g_HookSpriteDefault
szPlayerSize[id] = 0
szPlayerSound[id] = g_HookSoundDefault
szPlayerSpeed[id] = 0
szPlayerView[id] = 0
szPlayerEndSprite[id] = 0
}
}
public client_disconnect(id)
{
RemoveHook(id)
szPlayerHook[id] = false
}
public AdvancedHookMenu(id)
{
if(get_user_flags(id) & OneFlag | TwoFlag)
{
if(zp_is_plague_round() || zp_is_swarm_round() || zp_is_survivor_round() || zp_is_nemesis_round())
{
ChatColor(id, "%L", id, "ADVANCED_HOOK_NO_ROUND")
return PLUGIN_HANDLED
}
if(zp_get_user_zombie(id) || zp_get_user_survivor(id) || zp_get_user_last_human(id))
{
ChatColor(id, "%L", id, "ADVANCED_HOOK_NO_ZM")
return PLUGIN_HANDLED
}
return Show_AdvancedHookMenu(id)
} else ChatColor(id, "%L", id, "ADVANCED_HOOK_NOACCESS")
return PLUGIN_HANDLED
}
public Show_AdvancedHookMenu(id)
{
new szMenu[512], iKeys = (1<<9), iLen = formatex(szMenu, charsmax(szMenu), "%L^n^n", id, "ADVANCED_MENU_TITLE")
if(g_iHookEnable)
{
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r[\w1\r] \w%L^n", id, "ADVANCED_MENU_MODE_COLOR", g_HookColorName[szPlayerColor[id]])
iKeys |= (1<<0)
}
else iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d[#] \d%L^n", id, "ADVANCED_MENU_MODE_COLOR_FALLS", g_HookColorName[szPlayerColor[id]])
if(g_iHookEnable)
{
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r[\w2\r] \w%L^n", id, "ADVANCED_MENU_MODE_HOOK", g_HookSpriteName[szPlayerSprite[id]])
iKeys |= (1<<1)
}
else iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d[#] \d%L^n", id, "ADVANCED_MENU_MODE_HOOK_FALLS", g_HookSpriteName[szPlayerSprite[id]])
if(g_iHookEnable)
{
switch(szPlayerSize[id])
{
case 0: iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r[\w3\r] \w%L^n", id, "ADVANCED_MENU_MODE_SIZE_0")
case 1: iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r[\w3\r] \w%L^n", id, "ADVANCED_MENU_MODE_SIZE_1")
case 2: iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r[\w3\r] \w%L^n", id, "ADVANCED_MENU_MODE_SIZE_2")
case 3: iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r[\w3\r] \w%L^n", id, "ADVANCED_MENU_MODE_SIZE_3")
}
iKeys |= (1<<2)
}
else iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d[#] \d%L^n", id, "ADVANCED_MENU_MODE_SIZE_0_FALLS")
if(g_iHookEnable)
{
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r[\w4\r] \w%L^n", id, "ADVANCED_MENU_MODE_SOUND", g_HookSoundName[szPlayerSound[id]])
iKeys |= (1<<3)
}
else iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d[#] \d%L^n", id, "ADVANCED_MENU_MODE_SOUND_FALLS", g_HookSoundName[szPlayerSound[id]])
if(g_iHookEnable)
{
switch(szPlayerSpeed[id])
{
case 0: iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r[\w5\r] \w%L^n", id, "ADVANCED_MENU_MODE_SPEED_0")
case 1: iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r[\w5\r] \w%L^n", id, "ADVANCED_MENU_MODE_SPEED_1")
case 2: iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r[\w5\r] \w%L^n", id, "ADVANCED_MENU_MODE_SPEED_2")
}
iKeys |= (1<<4)
}
else iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d[#] \d%L^n", id, "ADVANCED_MENU_MODE_SPEED_0_FALLS")
if(g_iHookEnable)
{
switch(szPlayerView[id])
{
case 0: iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r[\w6\r] \w%L^n", id, "ADVANCED_MENU_MODE_VIEW_0");
case 1: iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r[\w6\r] \w%L^n", id, "ADVANCED_MENU_MODE_VIEW_1");
case 2: iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r[\w6\r] \w%L^n", id, "ADVANCED_MENU_MODE_VIEW_2");
}
iKeys |= (1<<5);
}
else iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d[#] \d%L^n", id, "ADVANCED_MENU_MODE_VIEW_0_FALLS");
if(g_iHookEnable)
{
switch(szPlayerEndSprite[id])
{
case 0: iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r[\w7\r] \w%L^n", id, "ADVANCED_MENU_MODE_END_0");
case 1: iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r[\w7\r] \w%L^n", id, "ADVANCED_MENU_MODE_END_1");
case 2: iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r[\w7\r] \w%L^n", id, "ADVANCED_MENU_MODE_END_2");
case 3: iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r[\w7\r] \w%L^n", id, "ADVANCED_MENU_MODE_END_3");
case 4: iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r[\w7\r] \w%L^n", id, "ADVANCED_MENU_MODE_END_4");
}
iKeys |= (1<<6);
}
else iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d[#] \d%L^n", id, "ADVANCED_MENU_MODE_END_0_FALLS");
if(get_user_flags(id) & TwoFlag|OneFlag && g_iHookEnable)
{
if(g_iHookEnable) iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r[\w8\r] \w%L^n", id, "ADVANCED_MENU_MODE_HOOK_TARGET_MENU");
iKeys |= (1<<7);
}
else iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\d[#] \d%L^n", id, "ADVANCED_MENU_MODE_HOOK_TARGET_MENU_FALLS");
if(get_user_flags(id) & TwoFlag)
{
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r[\w9\r] \w%L^n^n", id, g_iHookEnable ? "ADVANCED_HOOK_ENABLE" : "ADVANCED_HOOK_DISABLE");
iKeys |= (1<<8);
}
else iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d[#] %L^n^n", id, g_iHookEnable ? "ADVANCED_HOOK_ENABLE" : "ADVANCED_HOOK_DISABLE");
formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r[\w0\r] \w%L", id, "ADVANCED_MENU_MODE_EXIT");
return show_menu(id, iKeys, szMenu, -1, "Show_AdvancedHookMenu");
}
public Handle_AdvancedHookMenu(id, iKey)
{
switch(iKey)
{
case 0:
{
if(g_iHookEnable)
{
++szPlayerColor[id]
if(szPlayerColor[id] == g_HookColorNum + 1)
szPlayerColor[id] = 1
}
}
case 1:
{
if(g_iHookEnable)
{
++szPlayerSprite[id]
if(szPlayerSprite[id] == g_HookSpriteNum + 1)
szPlayerSprite[id] = 1
}
}
case 2:
{
if(g_iHookEnable)
{
++szPlayerSize[id]
if(szPlayerSize[id] == 4)
szPlayerSize[id] = 0
}
}
case 3:
{
if(g_iHookEnable)
{
++szPlayerSound[id]
if(szPlayerSound[id] == g_HookSoundNum + 1)
szPlayerSound[id] = 1
}
}
case 4:
{
if(g_iHookEnable)
{
++szPlayerSpeed[id]
if(szPlayerSpeed[id] == 3)
szPlayerSpeed[id] = 0
}
}
case 5:
{
if(g_iHookEnable)
{
++szPlayerView[id]
if(szPlayerView[id] == 3)
szPlayerView[id] = 0
}
}
case 6:
{
if(g_iHookEnable)
{
++szPlayerEndSprite[id]
if(szPlayerEndSprite[id] == 5)
szPlayerEndSprite[id] = 0
}
}
case 7: if(g_iHookEnable) return Cmd_AdvancedHookTargetMenu(id);
case 8:
{
new szName[32]
get_user_name(id, szName, charsmax(szName))
if(g_iHookEnable && get_user_flags(id) & TwoFlag)
{
g_iHookEnable = false
ChatColor(0, "%L", id, "ADVANCED_MENU_MODE_HOOK_OFF_CHAT_CREATOR", szName)
}
else
{
g_iHookEnable = true
ChatColor(0, "%L", id, "ADVANCED_MENU_MODE_HOOK_ON_CHAT_CREATOR", szName)
}
}
case 9: return PLUGIN_HANDLED
}
return Show_AdvancedHookMenu(id)
}
public Cmd_AdvancedHookTargetMenu(id)
return Show_AdvancedHookTargetMenu(id, g_iMenuPosition[id] = 0);
Show_AdvancedHookTargetMenu(id, iPos)
{
if(iPos < 0 || !is_user_connected(id))
return PLUGIN_HANDLED
new iPlayersNum
for(new i = 1; i <= get_maxplayers(); i++)
{
if(!is_user_connected(i)) continue;
g_iMenuPlayers[id][iPlayersNum++] = i
}
new iStart = iPos * PLAYERS_PER_PAGE;
if(iStart > iPlayersNum) iStart = iPlayersNum;
iStart = iStart - (iStart % 8);
g_iMenuPosition[id] = iStart / PLAYERS_PER_PAGE;
new iEnd = iStart + PLAYERS_PER_PAGE;
if(iEnd > iPlayersNum) iEnd = iPlayersNum;
new szMenu[512], iLen, iPagesNum = (iPlayersNum / PLAYERS_PER_PAGE + ((iPlayersNum % PLAYERS_PER_PAGE) ? 1 : 0))
switch(iPagesNum)
{
case 0:
{
ChatColor(id, "%L", id, "ADVANCED_HOOK_MODE_PLAYER")
return PLUGIN_HANDLED
}
default: iLen = formatex(szMenu, charsmax(szMenu), "\y%L^n^n", id, "ADVANCED_HOOK_MODE_TARGET_HOOK", iPos + 1, iPagesNum)
}
new szName[32], i, iKeys = (1<<9), b;
for(new a = iStart; a < iEnd; a++)
{
i = g_iMenuPlayers[id][a];
get_user_name(i, szName, charsmax(szName));
iKeys |= (1<<b);
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r[\w%d\r] \w%s %L^n", ++b, szName, i, szPlayerHook[i] ? "ADVANCED_HOOK_MODE_HOOK_TAKE" : "ADVANCED_HOOK_MODE_HOOK_GIVE");
}
for(new i = b; i < PLAYERS_PER_PAGE; i++) iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n");
if(iEnd < iPlayersNum)
{
iKeys |= (1<<8);
formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r[\w9\r] \w%L^n", id, "ADVANCED_MENU_MODE_NEXT", id, iPos ? "ADVANCED_MENU_MODE_BACK" : "ADVANCED_MENU_MODE_EXIT");
}
else formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r[\w0\r] \w%L", id, iPos ? "ADVANCED_MENU_MODE_BACK" : "ADVANCED_MENU_MODE_EXIT");
return show_menu(id, iKeys, szMenu, -1, "Show_AdvancedHookTargetMenu");
}
public Handle_AdvancedHookTargetMenu(id, iKey)
{
switch(iKey)
{
case 8: return Show_AdvancedHookTargetMenu(id, ++g_iMenuPosition[id]);
case 9: return Show_AdvancedHookTargetMenu(id, --g_iMenuPosition[id]);
default:
{
new iTarget = g_iMenuPlayers[id][g_iMenuPosition[id] * PLAYERS_PER_PAGE + iKey];
new szName[32], szTargetName[32];
get_user_name(id, szName, charsmax(szName))
get_user_name(iTarget, szTargetName, charsmax(szTargetName))
if(!szPlayerHook[iTarget])
{
szPlayerSpeed[iTarget] = szPlayerSpeed[id]
szPlayerSize[iTarget] = szPlayerSize[id]
szPlayerColor[iTarget] = szPlayerColor[id]
szPlayerSound[iTarget] = szPlayerSound[id]
szPlayerSprite[iTarget] = szPlayerSprite[id]
szPlayerEndSprite[iTarget] = szPlayerEndSprite[id]
szPlayerView[iTarget] = szPlayerView[id]
szPlayerHook[iTarget] = true
if(get_user_flags(id) & TwoFlag)
{
ChatColor(0, "%L", LANG_PLAYER, "ADVANCED_HOOK_MODE_HOOK_GIVE_CHAT_CREATOR", szName, szTargetName)
}
else
if(get_user_flags(id) & OneFlag)
{
ChatColor(0, "%L", LANG_PLAYER, "ADVANCED_HOOK_MODE_HOOK_GIVE_CHAT_OWNER", szName, szTargetName)
}
}
else
{
szPlayerHook[iTarget] = false
if(get_user_flags(id) & TwoFlag)
{
ChatColor(0, "%L", LANG_PLAYER, "ADVANCED_HOOK_MODE_HOOK_TAKE_CHAT_CREATOR", szName, szTargetName)
}
else
if(get_user_flags(id) & OneFlag)
{
ChatColor(0, "%L", LANG_PLAYER, "ADVANCED_HOOK_MODE_HOOK_TAKE_CHAT_OWNER", szName, szTargetName)
}
return Show_AdvancedHookTargetMenu(id, g_iMenuPosition[id])
}
}
}
return Show_AdvancedHookTargetMenu(id, g_iMenuPosition[id]);
}
public EnableHook(id)
{
if(get_user_flags(id) & OneFlag || get_user_flags(id) & TwoFlag)
{
if(zp_is_plague_round() || zp_is_swarm_round() || zp_is_survivor_round() || zp_is_nemesis_round())
{
ChatColor(id, "%L", id, "ADVANCED_HOOK_NO_ROUND")
return PLUGIN_HANDLED
}
if(zp_get_user_zombie(id) || zp_get_user_survivor(id) || zp_get_user_last_human(id))
{
ChatColor(id, "%L", id, "ADVANCED_HOOK_NO_ZM")
return PLUGIN_HANDLED
}
if(is_user_alive(id) && szPlayerHook[id] && g_iHookEnable)
{
if(LimitHook[id] > 0)
{
get_user_origin(id, szPlayerHookOrigin[id], 3)
if(callfunc_begin("detect_cheat", "prokreedz.amxx") == 1)
{
callfunc_push_int(id)
callfunc_push_str("Hook")
callfunc_end()
}
emit_sound(id, CHAN_STATIC, g_HookSoundFile[szPlayerSound[id]], 1.0, ATTN_NORM, 0, PITCH_NORM)
set_task(0.1, "AdvancedHookTask", id, "", 0, "ab")
AdvancedHookTask(id)
szBreakEnd[id] = szPlayerEndSprite[id] + 1
break_end(id)
set_task(1.0, "CTask__UpdateUserGlowColor", id + 1557, "", 0, "b")
CTask__UpdateUserGlowColor(id)
if(is_user_alive(id) && szPlayerHook[id] && get_user_flags(id) & OneFlag)
{
set_user_rendering(id, kRenderFxGlowShell, 255, 0, 255, kRenderNormal, 0)
}
ScreenFade(id)
LimitHook[id]--
if(get_user_flags(id) & TwoFlag)
{
ChatColor(id, "%L", LANG_PLAYER, "ADVANCED_HOOK_LEFT_TWO", LimitHook[id], LimitFlagsTwo)
}
else if(get_user_flags(id) & OneFlag)
{
ChatColor(id, "%L", LANG_PLAYER, "ADVANCED_HOOK_LEFT_ONE", LimitHook[id], LimitFlagsOne)
}
} else ChatColor(id, "%L", LANG_PLAYER, "ADVANCED_HOOK_END")
}
} else ChatColor(id, "%L", id, "ADVANCED_MENU_MODE_NOACCESS")
return PLUGIN_HANDLED
}
public DisableHook(id)
{
RemoveHook(id)
if(zp_get_user_nemesis(id)) return PLUGIN_HANDLED
set_user_rendering(id)
remove_task(id + 1557)
RemoveScreenFade(id)
return PLUGIN_HANDLED
}
public AdvancedHookTask(id)
{
if(!is_user_connected(id) || !is_user_alive(id)) RemoveHook(id) && RemoveBeam(id)
DrawHook(id)
Trail_Hook(id)
new szOrigin[3], Float:szVelocity[3]
get_user_origin(id, szOrigin)
new szDistance = get_distance(szPlayerHookOrigin[id], szOrigin)
if(szDistance > 25)
{
if(szPlayerSpeed[id] == 0)
{
szVelocity[0] = (szPlayerHookOrigin[id][0] - szOrigin[0]) * (3.0 * 280 / szDistance)
szVelocity[1] = (szPlayerHookOrigin[id][1] - szOrigin[1]) * (3.0 * 280 / szDistance)
szVelocity[2] = (szPlayerHookOrigin[id][2] - szOrigin[2]) * (3.0 * 280 / szDistance)
}
else if(szPlayerSpeed[id] == 1)
{
szVelocity[0] = (szPlayerHookOrigin[id][0] - szOrigin[0]) * (3.0 * 150 / szDistance)
szVelocity[1] = (szPlayerHookOrigin[id][1] - szOrigin[1]) * (3.0 * 150 / szDistance)
szVelocity[2] = (szPlayerHookOrigin[id][2] - szOrigin[2]) * (3.0 * 150 / szDistance)
}
else if(szPlayerSpeed[id] == 2)
{
szVelocity[0] = (szPlayerHookOrigin[id][0] - szOrigin[0]) * (3.0 * 400 / szDistance)
szVelocity[1] = (szPlayerHookOrigin[id][1] - szOrigin[1]) * (3.0 * 400 / szDistance)
szVelocity[2] = (szPlayerHookOrigin[id][2] - szOrigin[2]) * (3.0 * 400 / szDistance)
}
entity_set_vector(id, EV_VEC_velocity, szVelocity)
}
}
public DrawHook(id)
{
new szSize, szView
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(1)
write_short(id)
write_coord(szPlayerHookOrigin[id][0])
write_coord(szPlayerHookOrigin[id][1])
write_coord(szPlayerHookOrigin[id][2])
write_short(g_HookSpriteMsg[szPlayerSprite[id]])
write_byte(7)
write_byte(7)
write_byte(100)
switch(szPlayerSize[id])
{
case 0: szSize = 34
case 1: szSize = 18
case 2: szSize = 48
case 3: szSize = 80
}
write_byte(szSize)
switch(szPlayerView[id])
{
case 0: szView = 0
case 1: szView = 7
case 2: szView = 35
}
write_byte(szView)
write_byte(g_HookColorRGB[szPlayerColor[id]][0])
write_byte(g_HookColorRGB[szPlayerColor[id]][1])
write_byte(g_HookColorRGB[szPlayerColor[id]][2])
write_byte(250)
write_byte(7)
message_end()
}
public RemoveHook(id)
{
if(task_exists(id))
remove_task(id)
RemoveBeam(id)
}
public RemoveBeam(id)
{
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(99)
write_short(id)
message_end()
}
public break_end(id)
{
new Origin[3], szSprite
switch(szBreakEnd[id])
{
case 1: szSprite = g_pEndSpriteBreak[0]
case 2: szSprite = g_pEndSpriteBreak[1]
case 3: szSprite = g_pEndSpriteBreak[2]
case 4: szSprite = g_pEndSpriteBreak[3]
}
get_user_origin(id, Origin, 3)
message_begin(MSG_ALL, SVC_TEMPENTITY, {0,0,0}, id)
write_byte(TE_SPRITETRAIL)
write_coord(Origin[0])
write_coord(Origin[1])
write_coord(Origin[2] + 20)
write_coord(Origin[0])
write_coord(Origin[1])
write_coord(Origin[2] + 80)
write_short(szSprite)
write_byte(30)
write_byte(20)
write_byte(2)
write_byte(20)
write_byte(10)
message_end()
}
public ScreenFade(id)
{
message_begin(MSG_ONE_UNRELIABLE, g_ScreenFade, {0,0,0}, id)
write_short(10<<12)
write_short(10<<16)
write_short(1<<1)
write_byte(255)
write_byte(0)
write_byte(255)
write_byte(95)
message_end()
}
public RemoveScreenFade(id)
{
message_begin(MSG_ONE_UNRELIABLE, g_ScreenFade, {0,0,0}, id)
write_short(10<<12)
write_short(10<<16)
write_short(1<<1)
write_byte(255)
write_byte(255)
write_byte(255)
write_byte(255)
message_end()
}
public Trail_Hook(id)
{
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
write_byte(TE_BEAMFOLLOW)
write_short(id)
write_short(gTrail)
write_byte(TRAIL_LIFE)
write_byte(TRAIL_WIDTH)
write_byte(TRAIL_RED)
write_byte(TRAIL_GREEN)
write_byte(TRAIL_BLUE)
write_byte(TRAIL_BRIGTHNESS)
message_end()
}
public CTask__UpdateUserGlowColor(id)
{
id -= 1557
if(!is_user_alive(id))
{
remove_task(id)
return
}
new iHueNow, Float: flColor[3]
HUEtoRGB(iHueNow, flColor)
if ((iHueNow += 5) && iHueNow >= 360)
iHueNow = 0
// render
if(szPlayerHook[id] && get_user_flags(id) & TwoFlag)
set_user_rendering(id, kRenderFxGlowShell, floatround(flColor[0]), floatround(flColor[1]), floatround(flColor[2]), kRenderNormal, 0)
}
stock HUEtoRGB(hue, Float:rgb[3])
{
rgb[0] = (hue / 255.0) + 1.0 / 3.0;
rgb[1] = (hue / 255.0);
rgb[2] = (hue / 255.0) - 1.0 / 3.0;
for (new i = 0; i < 3; i++)
{
if (rgb[i] < 0.0)
{
rgb[i] += 1.0;
}
if (rgb[i] > 1.0)
{
rgb[i] -= 1.0;
}
if (6.0 * rgb[i] < 1)
{
rgb[i] = rgb[i] * 6.0
continue;
}
if (2.0 * rgb[i] < 1)
{
rgb[i] = 1.0;
continue;
}
if (3.0 * rgb[i] < 2.0)
{
rgb[i] = ((2.0 / 3.0) - rgb[i]) * 6.0
continue;
}
rgb[i] = 0.0;
}
rgb[0] *= 255.0;
rgb[1] *= 255.0;
rgb[2] *= 255.0;
}
stock ChatColor(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();
}
}
}
}