View Single Post
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 02-16-2011 , 13:35   Re: New Semiclip Method
Reply With Quote #86

Here's my improved version of ConnorMcLeod's version. It fixes the bugs with 2 players and entities! Also fixed bug when player could be left as SOLID_NOT and not being reset back. Please test it, and tell me if anything goes well!

Code:
#include < amxmodx > #include < engine > #include < fakemeta > #include < hamsandwich > #define IsPlayer(%1) ( 1 <= %1 <= g_iMaxPlayers ) new const g_szAliveFlags[ ] = "a"; new g_iPlayers[ 32 ], g_iNum, g_iPlayer, g_iMaxPlayers, i; public plugin_init( ) {     register_plugin( "Semiclip", "1.0", "ConnorMcLeod / xPaw" );         register_forward( FM_ShouldCollide, "FwdShouldCollide" );     register_forward( FM_AddToFullPack, "FwdAddToFullPack", true );         RegisterHam( Ham_Player_PreThink, "player", "FwdHamPlayerPreThink", true );     RegisterHam( Ham_Killed,          "player", "FwdHamPlayerKilled",   true );         g_iMaxPlayers = get_maxplayers( ); } public FwdAddToFullPack( es, e, iEnt, id, hostflags, player, pSet ) {     if( player && id != iEnt && get_orig_retval( ) )     {         set_es( es, ES_Solid, SOLID_NOT );                 static Float:flDistance;         flDistance = entity_range( id, iEnt );                 if( flDistance < 512.0 )         {             set_es( es, ES_RenderMode, kRenderTransAlpha )             set_es( es, ES_RenderAmt, floatround( flDistance ) / 2 );         }     } } public FwdShouldCollide( const iTouched, const iOther ) {     if( IsPlayer( iTouched ) && IsPlayer( iOther ) )     {         forward_return( FMV_CELL, 0 );         return FMRES_SUPERCEDE;     }         return FMRES_IGNORED; } public FwdHamPlayerKilled( ) {     get_players( g_iPlayers, g_iNum, g_szAliveFlags );         for( i = 0; i < g_iNum; i++ )     {         entity_set_int( g_iPlayers[ i ], EV_INT_solid, SOLID_SLIDEBOX );     } } public FwdHamPlayerPreThink( const id )     Semiclip( id, SOLID_NOT ); public client_PostThink( id )     Semiclip( id, SOLID_SLIDEBOX ); Semiclip( const id, const iSolid ) {     if( !is_user_alive( id ) )         return;         get_players( g_iPlayers, g_iNum, g_szAliveFlags );         for( i = 0; i < g_iNum; i++ )     {         g_iPlayer = g_iPlayers[ i ];                 if( id != g_iPlayer )             entity_set_int( g_iPlayer, EV_INT_solid, iSolid );     } }
__________________
xPaw is offline