/* Copyright � 2008, ConnorMcLeod func_door is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with func_door; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define CHATCOLOR #define MAKE_DOORS_SILENT #include #include #include #include #include #include new const VERSION[] = "1.1.2"; #pragma semicolon 1 #define SetIdBits(%1,%2) %1 |= 1<<(%2 & 31) #define ClearIdBits(%1,%2) %1 &= ~( 1<<(%2 & 31) ) #define GetIdBits(%1,%2) %1 & 1<<(%2 & 31) #define SetEntBits(%1,%2) %1[%2>>5] |= 1<<(%2 & 31) #define ClearEntBits(%1,%2) %1[%2>>5] &= ~( 1 << (%2 & 31) ) #define GetEntBits(%1,%2) %1[%2>>5] & 1<<(%2 & 31) enum _:BlocksClasses { FUNC_DOOR, FUNC_WALL_TOGGLE, FUNC_BUTTON, TRIGGER_MULTIPLE } new const Float:VEC_DUCK_HULL_MIN[3] = {-16.0, -16.0, -18.0 }; new const Float:VEC_DUCK_HULL_MAX[3] = { 16.0, 16.0, 32.0 }; new const Float:VEC_DUCK_VIEW[3] = { 0.0, 0.0, 12.0 }; new const Float:VEC_NULL[3] = { 0.0, 0.0, 0.0 }; const PLAYERS_ARRAY_SIZE = 33; const MAX_ENTSARRAYS_SIZE = 64; // x * 32 // 2048 (should be 1800 on default servers settings) new g_bitPresentClass; const KEYS = ((1<<0)|(1<<1)|(1<<9)); new g_iBlock[ PLAYERS_ARRAY_SIZE ]; new Float:g_flFirstTouch[ PLAYERS_ARRAY_SIZE ]; new Float:g_flJumpOrigin[ PLAYERS_ARRAY_SIZE ][3]; new Float:g_flJumpAngles[ PLAYERS_ARRAY_SIZE ][3]; new Float:g_flJumpGravity[ PLAYERS_ARRAY_SIZE ]; new g_bBlocks[MAX_ENTSARRAYS_SIZE], g_bBlocksByPlugin[MAX_ENTSARRAYS_SIZE]; new g_bOnGround, g_bTeleported, g_bAdmin; new bool:g_bBlockEntityTouch; new bool:g_bActive; new bool:g_bSafeInform = true; new g_iFhAddToFullPack; new g_iAdminDoor[PLAYERS_ARRAY_SIZE]; new szConfigFile[64]; new Trie:g_iBlocksClass; new g_iMaxPlayers, g_iMaxEnts; #define IsPlayer(%1) ( 1 <= %1 <= g_iMaxPlayers ) public plugin_init() { register_plugin("MultiPlayer Bhop", VERSION, "ConnorMcLeod"); new pCvar = register_cvar("mp_bhop_version", VERSION, FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_SPONLY); set_pcvar_string(pCvar, VERSION); new const szPossibleBlockClass[][] = {"func_door", "func_wall_toggle", "func_button", "trigger_multiple"}; g_iBlocksClass = TrieCreate(); for(new i; i set blocks so they can't move when players touch them"); register_concmd("kz_mpbhop_entitytouch", "ConCmd_EntityTouch", ADMIN_CFG, "<0/1> set blocks so they can't move when other entities than players touch them"); register_concmd("kz_safe_inform", "ClCmd_SafeInform", ADMIN_CFG, "<0/1> Inform recorders that their demo will be safe or not safe according to plugin state"); register_clcmd("kz_mpbhopmenu", "ClCmd_BhopMenu", ADMIN_CFG); register_clcmd("kz_showblocks", "ClCmd_ShowBlocks", ADMIN_CFG); register_clcmd("fullupdate", "ClCmd_FullUpdate"); register_menucmd(register_menuid("MpBhop Menu"), KEYS ,"MpBhopMenuAction"); g_iMaxPlayers = get_maxplayers(); g_iMaxEnts = global_get(glb_maxEntities); new iCount; iCount += Set_Doors(); iCount += Set_Wall_Toggle(); iCount += Set_Buttons(); iCount += SetBlocksByFile(); server_print("[MPBHOP] %d bhop blocks detected", iCount); SetTriggerMultiple(); } public plugin_cfg() { new szConfigPath[96]; get_localinfo("amxx_configsdir", szConfigPath, charsmax(szConfigPath)); format(szConfigPath, charsmax(szConfigPath), "%s/mpbhop.cfg", szConfigPath); if(file_exists(szConfigPath)) { new buffer[2], n; read_file(szConfigPath, 0, buffer, charsmax(buffer), n); if(buffer[0] == ';') goto ForceWrite; server_cmd("exec %s", szConfigPath); server_exec(); } else { ForceWrite: new fp = fopen(szConfigPath, "wt"); if(!fp) return; new szPluginFileName[96], szPluginName[64], szAuthor[32], szVersion[32], szStatus[2]; new iPlugin = get_plugin(-1, szPluginFileName, charsmax(szPluginFileName), szPluginName, charsmax(szPluginName), szVersion, charsmax(szVersion), szAuthor, charsmax(szAuthor), szStatus, charsmax(szStatus) ); // server_print("Plugin id is %d", iPlugin); fprintf(fp, "// ^"%s^" configuration file^n", szPluginName); fprintf(fp, "// Author : ^"%s^"^n", szAuthor); fprintf(fp, "// Version : ^"%s^"^n", szVersion); fprintf(fp, "// File : ^"%s^"^n", szPluginFileName); new iMax, i, szCommand[64], iCommandAccess, szCmdInfo[128], szFlags[32]; iMax = get_concmdsnum(-1, -1); fprintf(fp, "^n// Console Commands :^n"); for(i=0; i 0.25 ) // 0.3 == exploit on cg_cbblebhop oO { if( flTime - g_flFirstTouch[id] > 0.7 ) { g_flFirstTouch[id] = flTime; return HAM_SUPERCEDE; } Util_TeleportPlayerBack( id ); } return HAM_SUPERCEDE; } Util_TeleportPlayerBack(id) { SetIdBits(g_bTeleported, id); // apply null velocity on next PreThink() new flags = pev(id, pev_flags); if( flags & FL_BASEVELOCITY ) { flags &= ~FL_BASEVELOCITY; set_pev(id, pev_basevelocity, VEC_NULL); } set_pev(id, pev_velocity, VEC_NULL); set_pev(id, pev_flags, flags | FL_DUCKING); engfunc(EngFunc_SetSize, id, VEC_DUCK_HULL_MIN, VEC_DUCK_HULL_MAX); engfunc(EngFunc_SetOrigin, id, g_flJumpOrigin[id]); set_pev(id, pev_view_ofs, VEC_DUCK_VIEW); set_pev(id, pev_v_angle, VEC_NULL); set_pev(id, pev_angles, g_flJumpAngles[id]); set_pev(id, pev_punchangle, VEC_NULL); set_pev(id, pev_fixangle, 1); set_pev(id, pev_gravity, g_flJumpGravity[id]); set_pev(id, pev_fuser2, 0.0); } public ConCmd_MpBhop(id, lvl, cid) { if( cmd_access(id, lvl, cid, 2) ) { new szStatus[2]; read_argv(1, szStatus, charsmax(szStatus)); static HamHook:iHhPlayerPreThink; switch( szStatus[0] ) { case '0': { if( !g_bActive ) { return PLUGIN_HANDLED; } if( iHhPlayerPreThink ) { DisableHamForward( iHhPlayerPreThink ); } SetTouch( false ); g_bActive = false; if( g_bSafeInform ) { client_print(0, print_console, "MpBhop has been De-Activated, recording is now SAFE"); #if defined CHATCOLOR client_print_color(0, print_chat, "^1 * ^4[MpBhop] ^1MpBhop has been ^3De-Activated^1, recording is now ^4SAFE"); #else client_print(id, print_chat, " * [MpBhop] MpBhop has been De-Activated, recording is now SAFE"); #endif } } case '1': { if( g_bActive ) { return PLUGIN_HANDLED; } if( !iHhPlayerPreThink ) { RegisterHam(Ham_Player_PreThink, "player", "CBasePlayer_PreThink"); } else { EnableHamForward( iHhPlayerPreThink ); } SetTouch( true ); g_bActive = true; if( g_bSafeInform ) { client_print(0, print_console, "MpBhop has been Activated, recording is now NOT SAFE"); #if defined CHATCOLOR client_print_color(0, print_chat, "^1 * ^4[MpBhop] ^1MpBhop has been ^4Activated^1, recording is now ^3NOT SAFE"); #else client_print(id, print_chat, " * MpBhop has been Activated, recording is now NOT SAFE"); #endif } } default: { client_print(id, print_console, "Usage: kz_mpbhop <0/1>"); } } } return PLUGIN_HANDLED; } public ConCmd_EntityTouch(id, lvl, cid) { if( cmd_access(id, lvl, cid, 2) ) { new szStatus[2]; read_argv(1, szStatus, charsmax(szStatus)); g_bBlockEntityTouch = !!str_to_num(szStatus); } return PLUGIN_HANDLED; } Set_Doors() { new iDoor = FM_NULLENT, i; new Float:flMovedir[3], szNoise[32], Float:flSize[3], Float:flDmg, Float:flSpeed; new const szNull[] = "common/null.wav"; while( (iDoor = find_ent_by_class( iDoor, "func_door")) ) { // definitly not a bhop block pev(iDoor, pev_dmg, flDmg); if( flDmg ) { #if defined MAKE_DOORS_SILENT set_pev(iDoor, pev_noise1, szNull); // while here, set healing doors silent xD set_pev(iDoor, pev_noise2, szNull); set_pev(iDoor, pev_noise3, szNull); #endif continue; } // this func_door goes UP, not a bhop block ? // or bhop block but let them move up (kz_megabhop for example) pev(iDoor, pev_movedir, flMovedir); if( flMovedir[2] > 0.0 ) { continue; } // too small : real door ? could this one be skipped ? pev(iDoor, pev_size, flSize); if( ( flSize[0] < 24.0 && flSize[1] > 50.0 ) ||( flSize[1] < 24.0 && flSize[0] > 50.0 ) ) { continue; } // real door ? not all doors make sound though... pev(iDoor, pev_noise1, szNoise, charsmax(szNoise)); if( szNoise[0] && !equal(szNoise, szNull) ) { continue; } pev(iDoor, pev_noise2, szNoise, charsmax(szNoise)); if( szNoise[0] && !equal(szNoise, szNull) ) { continue; } // not a bhop block ? too slow // this at least detects the big ent on kzsca_sewerbhop pev(iDoor, pev_speed, flSpeed); if( flSpeed < 80.0 ) { continue; } // Pray for this to be a bhop block SetEntBits(g_bBlocksByPlugin, iDoor); SetEntBits(g_bBlocks, iDoor); g_bitPresentClass |= 1<