HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /**
  2.  *
  3.  * Anti DoubleDuck (DoubleDuck Blocker)
  4.  * by Numb
  5.  *
  6.  *
  7.  * Description:
  8.  * Permanently blocks player ability to doubleduck.
  9.  *
  10.  *
  11.  * Requires:
  12.  * FakeMeta
  13.  *
  14.  *
  15.  * Additional Info:
  16.  * + Tested in Counter-Strike 1.6 with amxmodx 1.8.1. But should work with all Half-Life mods and some older amxx versions.
  17.  *
  18.  *
  19.  * Notes:
  20.  * + I'm begging Valve to not use any ideas of this plugin for future updates of CS/CZ.
  21.  * + If your game mod is not Counter-Strike / Condition-Zero, you should take a look on plugins config.
  22.  *
  23.  *
  24.  * ChangeLog:
  25.  *
  26.  * + 1.7
  27.  * - Changed: Client-side doubleduck block uses almost twice less CPU power.
  28.  *
  29.  * + 1.6
  30.  * - Fixed: There was one frame delay during what player was fully ducked while trying to doubleduck.
  31.  * - Changed: Plugin uses a bit less resources.
  32.  *
  33.  * + 1.5
  34.  * - Added: Config in source code to disable client-side doubleduck block (when disabled uses less resources).
  35.  * - Changed: Plugin uses a bit less resources.
  36.  *
  37.  * + 1.4
  38.  * - Fixed: Client-side bug moving up. (Suggesting to use sv_stepsize 17 instead of standard 18, but there aren't much blocks where you are going up more than 16 units.)
  39.  *
  40.  * + 1.3
  41.  * - Fixed: If user is lagy and in a run - client-side doubleduck block isn't working properly.
  42.  * - Fixed: If user just landed and doubleducked client-side doubleduck block isn't working all the time (depends from ping).
  43.  * - Fixed: Client-side doubleduck block not working properly in random map areas.
  44.  * - Fixed: If user just unducked and made a doubleduck - client-side doubleduck block isn't working all the time (depends from ping).
  45.  *
  46.  * + 1.2
  47.  * - Added: Client-side doubleduck block.
  48.  *
  49.  * + 1.1
  50.  * - Changed: Made 1-based array (lower CPU usage).
  51.  * - Changed: Modified check when user is pre-doubleducking - now uses only 1 variable (lower cpu usage).
  52.  *
  53.  * + 1.0
  54.  * - First release.
  55.  *
  56.  *
  57.  * Downloads:
  58.  * Amx Mod X forums: http://forums.alliedmods.net/showthread.php?p=619219
  59.  *
  60. **/
  61.  
  62. #define BLOCK_CLIENT_SIDE_DD_VIEW
  63.  
  64.  
  65.  
  66. #if defined BLOCK_CLIENT_SIDE_DD_VIEW
  67.  
  68. #define ENTITY_MDL "models/w_awp.mdl"
  69.  
  70. #define ENTITY_NAME "anti_doubleducker"
  71.  
  72.  
  73. #endif
  74.  
  75. // ========================================================================== CONFIG END ==========================================================================
  76.  
  77.  
  78. #include <amxmodx>
  79. #include <fakemeta>
  80.  
  81. #define PLUGIN_NAME "Anti DoubleDuck"
  82. #define PLUGIN_VERSION "1.7"
  83. #define PLUGIN_AUTHOR "Numb"
  84.  
  85. #if defined BLOCK_CLIENT_SIDE_DD_VIEW
  86. #define ENTITY_NAME "anti_doubleducker"
  87.  
  88. new g_iFakeEnt;
  89. #endif
  90. new bool:g_bIsUserDead[33];
  91.  
  92. public plugin_init()
  93. {
  94. register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
  95.  
  96. register_event("ResetHUD", "Event_ResetHUD", "be");
  97. register_event("Health", "Event_Health", "bd", "1=0");
  98.  
  99. register_forward(FM_PlayerPreThink, "FM_PlayerPreThink_Pre", 0);
  100.  
  101. #if defined BLOCK_CLIENT_SIDE_DD_VIEW
  102. if( (g_iFakeEnt=engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target")))>0 )
  103. {
  104. set_pev(g_iFakeEnt, pev_classname, ENTITY_NAME);
  105. set_pev(g_iFakeEnt, pev_solid, SOLID_NOT);
  106. set_pev(g_iFakeEnt, pev_movetype, MOVETYPE_NONE);
  107. set_pev(g_iFakeEnt, pev_rendermode, kRenderTransAlpha);
  108. set_pev(g_iFakeEnt, pev_renderamt, 0.0);
  109.  
  110. engfunc(EngFunc_SetModel, g_iFakeEnt, ENTITY_MDL);
  111. engfunc(EngFunc_SetSize, g_iFakeEnt, Float:{-16.0, -16.0, 53.0}, Float:{16.0, 16.0, 54.0});
  112.  
  113. register_forward(FM_AddToFullPack, "FM_AddToFullPack_Pre", 0);
  114. }
  115. #endif
  116. }
  117.  
  118. public client_connect(iPlrId)
  119. g_bIsUserDead[iPlrId] = true;
  120.  
  121. public Event_ResetHUD(iPlrId)
  122. g_bIsUserDead[iPlrId] = false;
  123.  
  124. public Event_Health(iPlrId)
  125. g_bIsUserDead[iPlrId] = true;
  126.  
  127. public FM_PlayerPreThink_Pre(iPlrId)
  128. {
  129. if( g_bIsUserDead[iPlrId] )
  130. return FMRES_IGNORED;
  131.  
  132. if( pev(iPlrId, pev_oldbuttons)&IN_DUCK && !(pev(iPlrId, pev_button)&IN_DUCK) )
  133. {
  134. static s_iFlags;
  135. s_iFlags = pev(iPlrId, pev_flags);
  136. if( !(s_iFlags&FL_DUCKING) && pev(iPlrId, pev_bInDuck) )
  137. {
  138. set_pev(iPlrId, pev_bInDuck, false);
  139. set_pev(iPlrId, pev_flags, (s_iFlags|FL_DUCKING));
  140. engfunc(EngFunc_SetSize, iPlrId, Float:{-16.0, -16.0, -25.0}, Float:{16.0, 16.0, 25.0});
  141. }
  142. }
  143.  
  144. return FMRES_IGNORED;
  145. }
  146.  
  147. #if defined BLOCK_CLIENT_SIDE_DD_VIEW
  148. public FM_AddToFullPack_Pre(iEsHandle, iE, iEnt, iPlrId, iHostFlags, iPlayer, iPSet)
  149. {
  150. if( iEnt==g_iFakeEnt )
  151. {
  152. if( g_bIsUserDead[iPlrId] )
  153. return FMRES_SUPERCEDE;
  154.  
  155. static Float:s_fFallSpeed;
  156. pev(iPlrId, pev_flFallVelocity, s_fFallSpeed);
  157. if( s_fFallSpeed>=0.0 )
  158. {
  159. static Float:s_fOrigin[3];
  160. pev(iPlrId, pev_origin, s_fOrigin);
  161.  
  162. if( pev(iPlrId, pev_flags)&FL_DUCKING )
  163. s_fOrigin[2] += s_fFallSpeed?2.0:18.0;
  164. else
  165. s_fOrigin[2] -= s_fFallSpeed?16.0:0.0;
  166.  
  167. engfunc(EngFunc_SetOrigin, iEnt, s_fOrigin);
  168.  
  169. forward_return(FMV_CELL, dllfunc(DLLFunc_AddToFullPack, iEsHandle, iE, iEnt, iPlrId, iHostFlags, iPlayer, iPSet));
  170.  
  171. set_es(iEsHandle, ES_Solid, SOLID_BBOX);
  172.  
  173. return FMRES_SUPERCEDE;
  174. }
  175. return FMRES_SUPERCEDE;
  176. }
  177.  
  178. return FMRES_IGNORED;
  179. }
  180. #endif
  181.