Granada congelante
#1
Estrella 
Bueno, vi que un usuario tenía problemas con la frostnade y me acordé que hace un tiempo creé una debido a que tenía problemas parecidos. A comparación de la mayoría de los aportes, pienso que este puede llegar a ser útil por mas de que ya se haya creado, así que lo dejo acá.

Cuenta con ciertas ventajas por sobre la original obviamente:
  • Mejor performance.
  • Evita que se activen frostnades al final de la ronda ( crash ).
  • No te descongelás con comandos en consola.
  • Tiene lindos efectos.
Notas:
  • Para aquellos que no compilen con AMX 1.8.3 les va a pedir que posean el include chatcolor (de Connor) y el include dhudmessage (de Arkshine) a pesar de que no se utilicen; es un fragmento de código genérico que uso para dar soporte a AMX 1.8.2.
  • Abrir preferiblemente con Sublime Text para que se vea correctamente identado.

Actualizado: 26/05/2020.

Código PHP:
#include <amxmodx>
#include <fakemeta>
#include <engine>
#include <hamsandwich>

// AMXX 1.8.2 Compatibility

#if AMXX_VERSION_NUM < 183

    #include <chatcolor>
    #include <dhudmessage>
    
    #define print_team_default  GREY
    #define print_team_red      RED
    #define print_team_blue     BLUE
    #define print_team_grey     GREY
    
    #define Ham_CS_Player_ResetMaxSpeed Ham_Item_PreFrame
    
    #define client_disconnected(%0) client_disconnect(%0)
    
    #define MAX_PLAYERS 32

#endif

/* =================================================================================
*               [ Global ]
* ================================================================================= */

#define PLAYER_ARRAY            ( MAX_PLAYERS + 1 )

#define IsPlayer(%0)            ( 1 <= %0 <= MAX_PLAYERS )

#define GetPlayerBit(%0,%1)     ( IsPlayer(%1) && ( %0 & ( 1 << ( %1 & 31 ) ) ) )
#define SetPlayerBit(%0,%1)     ( IsPlayer(%1) && ( %0 |= ( 1 << ( %1 & 31 ) ) ) )
#define ClearPlayerBit(%0,%1)   ( IsPlayer(%1) && ( %0 &= ~( 1 << ( %1 & 31 ) ) ) )
#define SwitchPlayerBit(%0,%1)  ( IsPlayer(%1) && ( %0 ^= ( 1 << ( %1 & 31 ) ) ) )

const FROSTNADE_ID 8878;

const 
TASK_REMOVE_FREEZE 100;

enum _:Cvars
{
    
CVAR_SHOW_NOVA,
    
    
CVAR_FREEZE_SELF,
    
CVAR_FREEZE_TEAMMATES,
    
CVAR_FREEZE_DURATION
}

new const 
g_szFreezeSound[ ]    = "frostnade/freeze.wav";
new const 
g_szUnfreezeSound[ ]  = "frostnade/unfreeze.wav";
new const 
g_szExplodeSound[ ]   = "frostnade/explode.wav";

new const 
g_szBeamSprite[ ]     = "sprites/laserbeam.spr";
new const 
g_szFlareSprite[ ]    = "sprites/flare1.spr";

new const 
g_szNovaModel[ ]      = "models/frostnade/nova.mdl";

new const 
g_szInfoTarget[ ]     = "info_target";
new const 
g_szNovaClassname[ ]  = "Nova";

new 
g_iIsConnected;
new 
g_iIsAlive;
new 
g_iIsFrozen;

new 
g_iBlueflare;
new 
g_iBeam;
new 
g_iScreenFade;
new 
g_iMaxPlayers;

new 
bool:g_bEnabled;

new 
g_pCvarsCvars ];

new 
Float:g_flPlayerVelocityPLAYER_ARRAY ][ ];

/* =================================================================================
*               [ Plugin forwards ]
* ================================================================================= */

public plugin_precache( )
{
    
precache_soundg_szFreezeSound );
    
precache_soundg_szUnfreezeSound );
    
precache_soundg_szExplodeSound );
    
    
precache_modelg_szNovaModel );
    
    
g_iBeam         precache_modelg_szBeamSprite );
    
g_iBlueflare    precache_modelg_szFlareSprite );
}

public 
plugin_init( )
{
    
register_plugin"FrostNade""1.0""Manu" );
    
    
register_forwardFM_SetModel"OnSetModel_Pre"false );
    
    
RegisterHamHam_Think"grenade""OnGrenadeThink_Pre"false );
    
    
RegisterHamHam_Killed"player""OnPlayerKilled_Pre"false );
    
RegisterHamHam_Spawn"player""OnPlayerSpawn_Post"true );
    
    
register_logevent"OnRoundStart"2"1=Round_Start" );
    
register_logevent"OnRoundEnd"2"1=Round_End" );
    
    
register_logevent"OnRoundEnd"2"0=World triggered""1&Restart_Round_" );
    
register_logevent"OnRoundEnd"2"0=World triggered""1=Game_Commencing" );
    
    
g_pCvarsCVAR_SHOW_NOVA ]          = register_cvar"fn_show_nova""1" );
    
g_pCvarsCVAR_FREEZE_SELF ]        = register_cvar"fn_freeze_self""1" );
    
g_pCvarsCVAR_FREEZE_TEAMMATES ]   = register_cvar"fn_freeze_teammates""0" );
    
g_pCvarsCVAR_FREEZE_DURATION ]    = register_cvar"fn_freeze_duration""4.0" );
    
    
g_iMaxPlayers get_maxplayers( );
    
g_iScreenFade get_user_msgid"ScreenFade" );
}

/* =================================================================================
*               [ Events ]
* ================================================================================= */

public OnRoundStart( )
{
    
g_bEnabled true;
}

public 
OnRoundEnd( )
{
    
g_bEnabled false;
    
    for ( new 
iPlayer iPlayer <= g_iMaxPlayers iPlayer++ )
    {
        if ( !
GetPlayerBitg_iIsFrozeniPlayer ) )
        {
            continue;
        }
        
        
UnfreezePlayeriPlayer );
    }
}

/* =================================================================================
*               [ Grenade section ]
* ================================================================================= */

public OnSetModel_Pre( const iEnt, const szModel[ ] )
{
    if ( !
g_bEnabled )
    {
        return 
FMRES_IGNORED;
    }
    
    if ( ( 
strlenszModel ) != 25 ) || ( ( szModel] != 'w' ) || ( szModel] != '_' ) || ( szModel] != 's' ) ) )
    {
        return 
FMRES_IGNORED;
    }
    
    if ( 
entity_get_floatiEntEV_FL_dmgtime ) == 0.0 )
    {
        return 
FMRES_IGNORED;
    }
    
    
entity_set_intiEntEV_INT_flTimeStepSoundFROSTNADE_ID );
    
    
message_beginMSG_BROADCASTSVC_TEMPENTITY );
    
write_byteTE_BEAMFOLLOW );
    
write_shortiEnt );
    
write_shortg_iBeam );
    
write_byte25 );
    
write_byte);
    
write_byte);
    
write_byte50 );
    
write_byte250 );
    
write_byte200 );
    
message_end( );
    
    
set_renderingiEntkRenderFxGlowShell050250kRenderNormal16 );
    
    return 
FMRES_IGNORED;
}

public 
OnGrenadeThink_Pre( const iEnt )
{
    if ( !
g_bEnabled )
    {
        return 
HAM_IGNORED;
    }
    
    if ( 
entity_get_intiEntEV_INT_flTimeStepSound ) != FROSTNADE_ID )
    {
        return 
HAM_IGNORED;
    }
    
    if ( 
entity_get_floatiEntEV_FL_dmgtime ) > get_gametime( ) )
    {
        return 
HAM_IGNORED;
    }
    
    
FrostExplodeiEnt );
    
    return 
HAM_SUPERCEDE;
}

/* =================================================================================
*               [ Player events ]
* ================================================================================= */

public OnPlayerSpawn_Post( const iId )
{
    if ( !
is_user_aliveiId ) )
    {
        return 
HAM_IGNORED;
    }
    
    
SetPlayerBitg_iIsAliveiId );
    
    return 
HAM_IGNORED;
}

public 
OnPlayerKilled_Pre( const iVictim, const iAttacker, const iShouldgib )
{
    
ClearPlayerBitg_iIsAliveiVictim );
    
    if ( !
GetPlayerBitg_iIsFrozeniVictim ) )
    {
        return 
HAM_IGNORED;
    }
    
    
UnfreezePlayeriVictim );
    
    if ( 
task_existsiVictim TASK_REMOVE_FREEZE ) )
    {
        
remove_taskiVictim TASK_REMOVE_FREEZE );
    }
    
    return 
HAM_IGNORED;
}

public 
OnTaskRemoveFreeze( const iTask )
{
    new 
iId = ( iTask TASK_REMOVE_FREEZE );
    
    if ( !
GetPlayerBitg_iIsFrozeniId ) )
    {
        return;
    }
    
    
UnfreezePlayeriId );
}

/* =================================================================================
*               [ Client Connection ]
* ================================================================================= */

public client_putinserveriId )
{
    
SetPlayerBitg_iIsConnectediId );
}

public 
client_disconnectediId )
{
    
ClearPlayerBitg_iIsConnectediId );
    
ClearPlayerBitg_iIsAliveiId );
    
ClearPlayerBitg_iIsFrozeniId );
    
    
RemoveEntityByOwneriIdg_szNovaClassname );
    
    if ( 
task_existsiId TASK_REMOVE_FREEZE ) )
    {
        
remove_taskiId TASK_REMOVE_FREEZE );
    }
}

/* =================================================================================
*               [ Freeze Modules ]
* ================================================================================= */

FreezePlayer( const iId )
{
    
SetPlayerBitg_iIsFrozeniId );
    
    
entity_get_vectoriIdEV_VEC_velocityg_flPlayerVelocityiId ] );
    
    
entity_set_vectoriIdEV_VEC_velocityFloat:{ 0.00.00.0 } );
    
entity_set_intiIdEV_INT_flagsentity_get_intiIdEV_INT_flags ) | FL_FROZEN );
    
    
emit_soundiIdCHAN_BODYg_szFreezeSoundVOL_NORMATTN_NORM0PITCH_NORM );
    
    
set_renderingiIdkRenderFxGlowShell060240kRenderNormal80 );
    
    
SendScreenFadeiId, { 060240 }, 400x000040 );
}

UnfreezePlayer( const iId )
{
    
ClearPlayerBitg_iIsFrozeniId );
    
    
entity_set_intiIdEV_INT_flagsentity_get_intiIdEV_INT_flags ) & ~FL_FROZEN );
    
entity_set_vectoriIdEV_VEC_velocityg_flPlayerVelocityiId ] );
    
    
emit_soundiIdCHAN_BODYg_szUnfreezeSoundVOL_NORMATTN_NORM0PITCH_NORM );
    
    
set_renderingiId );
    
    
RemoveEntityByOwneriIdg_szNovaClassname );
}

/* =================================================================================
*               [ Explosion Modules ]
* ================================================================================= */

FrostExplode( const iEnt )
{
    new 
iOwner entity_get_edictiEntEV_ENT_owner );

    if ( !
GetPlayerBitg_iIsConnectediOwner ) )
    {
        return;
    }
    
    new 
Float:flOrigin];
    
    
entity_get_vectoriEntEV_VEC_originflOrigin );

    
CreateFrostEffectflOrigin );

    
emit_soundiEntCHAN_BODYg_szExplodeSoundVOL_NORMATTN_NORM0PITCH_NORM );
    
    new 
iTeam get_pdata_intiOwner114 );
    
    new 
bool:bShowNova = ( get_pcvar_numg_pCvarsCVAR_SHOW_NOVA ] ) > );
    new 
bool:bFreezeSelf = ( get_pcvar_numg_pCvarsCVAR_FREEZE_SELF ] ) > );
    new 
bool:bFreezeTeammates = ( get_pcvar_numg_pCvarsCVAR_FREEZE_TEAMMATES ] ) > );
    
    new 
Float:flDuration floatmax0.25get_pcvar_floatg_pCvarsCVAR_FREEZE_DURATION ] ) );
    
    new 
iVictim;
    
    while ( ( 
iVictim find_ent_in_sphereiVictimflOrigin250.0 ) ) > )
    {
        if ( !
GetPlayerBitg_iIsAliveiVictim ) || GetPlayerBitg_iIsFrozeniVictim ) )
        {
            continue;
        }
        
        if ( 
iVictim != iOwner )
        {
            if ( !
bFreezeTeammates && ( iTeam == get_pdata_intiVictim114 ) ) )
            {
                continue;
            }
        }
        else if ( !
bFreezeSelf )
        {
            continue;
        }
        
        
FreezePlayeriVictim );
        
        if ( 
bShowNova )
        {
            
CreateNovaiVictim );
        }
        
        
set_taskflDuration"OnTaskRemoveFreeze", ( iVictim TASK_REMOVE_FREEZE ) );
    }
    
    
remove_entityiEnt );
}

CreateFrostEffect( const Float:flOrigin] )
{
    new 
iOrigin];
    
    
FVecIVecflOriginiOrigin );
    
    for ( new 
i++ )
    {
        
message_beginMSG_BROADCASTSVC_TEMPENTITY );
        
write_byteTE_BEAMCYLINDER );
        
write_coordiOrigin] );
        
write_coordiOrigin] );
        
write_coordiOrigin] );
        
write_coordiOrigin] );
        
write_coordiOrigin] );
        
write_coordiOrigin] + ( 111 ) );
        
write_shortg_iBeam );
        
write_byte);
        
write_byte);
        
write_byte);
        
write_byte100 );
        
write_byte);
        
write_byte);
        
write_byte50 );
        
write_byte250 );
        
write_byte200 );
        
write_byte);
        
message_end( );
    }
    
    
message_beginMSG_BROADCASTSVC_TEMPENTITY );
    
write_byteTE_SPRITETRAIL );
    
write_coordiOrigin] );
    
write_coordiOrigin] );
    
write_coordiOrigin] );
    
write_coordiOrigin] );
    
write_coordiOrigin] );
    
write_coordiOrigin] );
    
write_shortg_iBlueflare );
    
write_byte100 );
    
write_byte);
    
write_byte);
    
write_byte50 );
    
write_byte50 );
    
message_end( );
    
    
message_beginMSG_BROADCASTSVC_TEMPENTITY );
    
write_byteTE_DLIGHT );
    
write_coordiOrigin] );
    
write_coordiOrigin] );
    
write_coordiOrigin] );
    
write_byte48 );
    
write_byte);
    
write_byte50 );
    
write_byte255 );
    
write_byte10 );
    
write_byte50 );
    
message_end( );
}

/* =================================================================================
*               [ Nova Creation ]
* ================================================================================= */

CreateNova( const iId )
{
    new 
iEnt create_entityg_szInfoTarget ); 

    if ( !
is_valid_entiEnt ) )
    {
        return -
1;
    }
    
    new 
Float:flOrigin];

    
entity_get_vectoriIdEV_VEC_originflOrigin );
    
    ( 
entity_get_intiIdEV_INT_flags ) & FL_DUCKING ) ?
        ( 
flOrigin] -= 18.0 ) : ( flOrigin] -= 36.0 ); 

    
entity_set_stringiEntEV_SZ_classnameg_szNovaClassname );

    
entity_set_sizeiEntFloat:{ -1.0, -1.0, -1.0 }, Float:{ 1.01.01.0 } );
    
entity_set_modeliEntg_szNovaModel );
    
    
entity_set_vectoriEntEV_VEC_originflOrigin );

    
entity_set_intiEntEV_INT_solidSOLID_NOT );
    
entity_set_intiEntEV_INT_movetypeMOVETYPE_FLY );

    
entity_set_edictiEntEV_ENT_owneriId );

    return 
iEnt;
}

/* =================================================================================
*               [ Remove Entities ]
* ================================================================================= */

RemoveEntityByOwner( const iOwner, const szClassname[ ] )
{
    new 
iEnt = -1;
    
    while ( ( 
iEnt find_ent_by_owneriEntszClassnameiOwner ) ) > )
    {
        
remove_entityiEnt );
    }
}

/* =================================================================================
*               [ Screenfade ]
* ================================================================================= */

SendScreenFade( const iPlayer, const iRGB], const iDuration, const iHoldTime, const iFlag, const iAlpha )
{
    
message_beginMSG_ONE_UNRELIABLEg_iScreenFade, .player iPlayer );
    
write_short( ( 1<<12 ) * iDuration );
    
write_short( ( 1<<12 ) * iHoldTime );
    
write_shortiFlag );
    
write_byteiRGB] );
    
write_byteiRGB] );
    
write_byteiRGB] );
    
write_byteiAlpha );
    
message_end( );



Archivos adjuntos
.zip   Recursos.zip (Tamaño: 73.97 KB / Descargas: 99)
No hago trabajos privados. Si necesitás ayuda, abrí un nuevo tema.
¿Buscás un ejemplo o algún modo de juego? Podés echarle un vistazo a mis aportes
.
Responder
#2
A quque te refieres con que no te descongelas con comandos en consola?
(17/04/2015, 03:36 PM)Neeeeeeeeeel.- escribió: No se va a volver a conectar a internet en toda su puta vida... nadie sube porno a mi foro y vive para contarlo.
Responder
#3
cuando pones record en consola te descongelas, xq la frost original usa resethud para el inicio de ronda, y en ese evento descongela a todos...
Responder
#4
muy bueno, solo tengo un problema adapte la parte del loop q haces con TE_BEAMCYLINDER en la bomba hielo del zp 5.0 pero cuando la tiro no aparece nada, es decir uno lo tira y no saca efectos solo desaparece la entidad..

P.S: no se si pasara lo mismo con tu codigo no lo puedo testear ahora, solo digo por si acaso..
Responder
#5
(22/03/2015, 03:10 PM)wicho escribió: muy bueno, solo tengo un problema adapte la parte del loop q haces con TE_BEAMCYLINDER en la bomba hielo del zp 5.0 pero cuando la tiro no aparece nada, es decir uno lo tira y no saca efectos solo desaparece la entidad..

P.S: no se si pasara lo mismo con tu codigo no lo puedo testear ahora, solo digo por si acaso..

Cuando lo pruebes contame Roflmao Yo la creé principalmente para HnS, aunque se puede usar en cualquier mod supongo jaja
No hago trabajos privados. Si necesitás ayuda, abrí un nuevo tema.
¿Buscás un ejemplo o algún modo de juego? Podés echarle un vistazo a mis aportes
.
Responder
#6
Treki, cuando tiras la sg hay veces que se cae el servidor, no deja logs.
Responder
#7
(23/03/2015, 02:26 PM)Kisuke escribió: Treki, cuando tiras la sg hay veces que se cae el servidor, no deja logs.

Un tiempo atrás anduve usando esta frostnade y nunca se me cayó el server, capaz cuando la retoqué un poco hice cagada, en un rato me fijo y edito.
No hago trabajos privados. Si necesitás ayuda, abrí un nuevo tema.
¿Buscás un ejemplo o algún modo de juego? Podés echarle un vistazo a mis aportes
.
Responder
#8
(24/03/2015, 12:55 AM)Treki escribió:
(23/03/2015, 02:26 PM)Kisuke escribió: Treki, cuando tiras la sg hay veces que se cae el servidor, no deja logs.

Un tiempo atrás anduve usando esta frostnade y nunca se me cayó el server, capaz cuando la retoqué un poco hice cagada, en un rato me fijo y edito.

Fijate que se cae con "Server shutting down".
Responder
#9
Gracias por el aporteWhatever
Responder
#10
No sabia que te podias descongelar con comandos en consola.
Gracias por aportar
NUEVO ZOMBIE PLAGUE + LVLS!! UNETE A LA COMUNIDAD
[Imagen: b_350_20_ffad41_e98100_000000_591f11.png]


Responder
#11
(24/03/2015, 12:55 AM)Treki escribió:
(23/03/2015, 02:26 PM)Kisuke escribió: Treki, cuando tiras la sg hay veces que se cae el servidor, no deja logs.

Un tiempo atrás anduve usando esta frostnade y nunca se me cayó el server, capaz cuando la retoqué un poco hice cagada, en un rato me fijo y edito.

Arreglalo treki, ese edit quedo olvidado, tengo un amigo que queria el plugin pero no lo arreglastes nunca mas :p y ya que supuestamente tiene ciertos bugs solucionados. Yao ming
Responder
#12
Es posible que el servidor se cayera si pasaban ciertas cosas, así que arreglé todas las causas posibles de crash y retoqué un poco algunas partes de código. Ahora debería de funcionar perfectamente Sonrisa
No hago trabajos privados. Si necesitás ayuda, abrí un nuevo tema.
¿Buscás un ejemplo o algún modo de juego? Podés echarle un vistazo a mis aportes
.
Responder
#13
Recuerdo que cuando la testie, me paso lo mismo que a Kisuke.

"Server shutting down"

Y me olvide de reportarlo.

La habia testeado congelando un BOT. No con jugadores normales.

Cuando no tenga paja la testeo. Más alla de todo, buen aporte.
Responder
#14
Testeado y funcionando perfecto.
Responder
#15
Hay que pulir en muchas partes ese código, despues me animo
Responder
#16
(26/11/2015, 09:53 PM)hud escribió: Testeado y funcionando perfecto.

Thanks buddy.

(26/11/2015, 11:17 PM)meTaLiCroSS escribió: Hay que pulir en muchas partes ese código, despues me animo

Bienvenidas sean esas partes pulidas Crab
No hago trabajos privados. Si necesitás ayuda, abrí un nuevo tema.
¿Buscás un ejemplo o algún modo de juego? Podés echarle un vistazo a mis aportes
.
Responder
#17
¿Como quito los trozos de hielo en los pies del jugador? no me gustan
Responder
#18
(21/09/2016, 06:32 PM)Ballers escribió: ¿Como quito los trozos de hielo en los pies del jugador? no me gustan

Código PHP:
#include <amxmodx>
#include <fakemeta>
#include <engine>
#include <hamsandwich>

#define SetPlayerBit(%1,%2) ( %1 |= ( 1 << ( %2 & 31 ) ) )
#define ClearPlayerBit(%1,%2) ( %1 &= ~( 1 << ( %2 & 31 ) ) )
#define GetPlayerBit(%1,%2) ( %1 & ( 1 << ( %2 & 31 ) ) )

#define isPlayerValid(%0) ( 1 <= %0 <= 32 )
#define hasRoundStarted() ( g_fLastRoundEnd + 5.0 < get_gametime( ) )
#define isEnemy(%0,%1) ( get_user_team( %0 ) != get_user_team( %1 ) )
#define SetFrostNade(%1) entity_set_int( %1,EV_INT_flTimeStepSound,FROSTNADE )
#define IsPlayerCrouching(%1) ( entity_get_int( %1,EV_INT_button ) & IN_DUCK )
#define isFrostnade(%0) ( entity_get_int( %0, EV_INT_flTimeStepSound ) == FROSTNADE )
#define RemoveCrouch(%1) entity_set_int( %1,EV_INT_button,entity_get_int( %1,EV_INT_button ) & ~IN_DUCK )

/* ===============================================================
*           [ Initiation/Global variables ]
*  =============================================================== */

new g_iFrozeng_iAliveg_iBlueflareg_iBeamg_iScreenfadeg_iMaxplayersFloat:g_fLastRoundEnd;

new const 
g_szUnfreezesound[ ] = "frostnade/impalelaunch1.wav";
new const 
g_szFreezesound[ ] = "frostnade/impalehit.wav";
new const 
g_szFrostnova[ ] = "frostnade/frostnova.wav";

const 
FROSTNADE 1234;

public 
plugin_precache( )
{
    
precache_soundg_szUnfreezesound );
    
precache_soundg_szFreezesound );
    
precache_soundg_szFrostnova );
    
    
g_iBeam precache_model"sprites/frostnade/beam.spr" );
    
g_iBlueflare precache_model"sprites/frostnade/blueflare.spr" );
}

public 
plugin_init( )
{
    
register_plugin"Frostnade""1.0""Manu" );
    
    
register_logevent"ev_RoundEnd"2"1=Round_End" );
    
    
register_forwardFM_SetModel"fw_SetModel_Pre"false );
    
    
RegisterHamHam_Think"grenade""fw_GrenadeThink_Pre"false );
    
RegisterHamHam_Killed"player""fw_PlayerKilled_Pre"false );
    
RegisterHamHam_Spawn"player""fw_PlayerSpawn_Post"true );
    
    
g_iMaxplayers get_maxplayers( );
    
g_iScreenfade get_user_msgid"ScreenFade" );
}

/* ===============================================================
*                 [ Events ]
*  =============================================================== */

public ev_RoundEnd( )
{
    new 
iEnt;
    
    while( ( 
iEnt find_ent_by_classiEnt,"grenade" ) ) > )
        
remove_entityiEnt );
    
    for( new 
iPlayer 1iPlayer <= g_iMaxplayersiPlayer++ )
    {
        if( 
GetPlayerBitg_iFrozeniPlayer ) )
            
RemovePlayerFrostiPlayer );
    }
    
    
g_fLastRoundEnd get_gametime( );
}

/* ===============================================================
*                 [ Thinks / Hamsandwich ]
*  ===============================================================​​ */

public fw_GrenadeThink_PreiEnt )
{
    if( !
is_valid_entiEnt ) || ( entity_get_floatiEntEV_FL_dmgtime ) > get_gametime( ) ) || !isFrostnadeiEnt ) || !hasRoundStarted( ) )
        return 
HAM_IGNORED;
    
    
CreateFrostEffectiEnt );
    
    return 
HAM_SUPERCEDE;
}

public 
fw_NovaThinkiEnt )
{
    if( 
is_valid_entiEnt ) )
        
remove_entityiEnt );
}

public 
fw_PlayerKilled_PreiVictimiAttackerbShouldgib )
{
    
ClearPlayerBitg_iAliveiVictim );
    
    if( 
GetPlayerBitg_iFrozeniVictim ) )
    {
        
RemovePlayerFrostiVictim );
        
remove_taskiVictim );
    }
}

public 
fw_PlayerSpawn_PostiId )
{
    if( 
is_user_aliveiId ) )
        
SetPlayerBitg_iAliveiId );
}

/* ===========================================================================​
*                 [ Fakemeta forwards ]
*  ===========================================================================​​​ */

public fw_SetModel_PreiEntszModel[ ] )
{
    if( ( 
strlenszModel ) < ) || !( szModel] == 'w' && szModel] == '_' ) || !hasRoundStarted( ) )
        return 
FMRES_IGNORED;
    
    if( ( 
entity_get_floatiEntEV_FL_dmgtime ) > 0.0 ) && ( szModel] == 's' ) )
    {
        
SetFrostNadeiEnt );
        
        
message_beginMSG_BROADCASTSVC_TEMPENTITY );
        
write_byteTE_BEAMFOLLOW );
        
write_shortiEnt );
        
write_shortg_iBeam );
        
write_byte25 );
        
write_byte);
        
write_byte);
        
write_byte50 );
        
write_byte250 );
        
write_byte200 );
        
message_end( );
        
        
set_renderingiEntkRenderFxGlowShell050250kRenderNormal16 );
    }
    
    return 
FMRES_IGNORED;
}

/* ===========================================================================​​​
*                 [ Functions ]
*  ===========================================================================​​​ */

CreateFrostEffectiEnt )
{
    if( !
is_valid_entiEnt ) )
        return 
0;

    static 
iOwnerFloat:fOrigin];

    
iOwner entity_get_edictiEntEV_ENT_owner );
    
entity_get_vectoriEntEV_VEC_originfOrigin );

    
FrostZonefOrigin );

    
emit_soundiEntCHAN_BODYg_szFrostnovaVOL_NORMATTN_NORM0PITCH_NORM );

    if( 
isPlayerValidiOwner ) && is_user_connectediOwner ) )
    {
        new 
iVictim;
        
        while( ( 
iVictim find_ent_in_sphereiVictimfOrigin250.0 ) ) > )
        {
            if( 
isPlayerValidiVictim ) && GetPlayerBitg_iAliveiVictim ) && !GetPlayerBitg_iFrozeniVictim ) && ( isEnemyiVictimiOwner ) || ( iVictim == iOwner ) ) )
            {
                
SetPlayerBitg_iFrozeniVictim );
                
SendPlayerScreenfadeiVictim );
                
                
entity_set_vectoriVictimEV_VEC_velocityFloat:{ 0.0,0.0,0.0 } );
                
entity_set_intiVictimEV_INT_flagsentity_get_intiVictimEV_INT_flags ) | FL_FROZEN );
                
                
emit_soundiVictimCHAN_BODYg_szFreezesoundVOL_NORMATTN_NORM0PITCH_NORM );
                
set_renderingiVictimkRenderFxGlowShell060240kRenderNormal80 );
                
                
set_task4.0"RemovePlayerFrost"iVictim );
            }
        }
    }

    
remove_entityiEnt );

    return 
1;
}

public 
RemovePlayerFrostiId )
{
    
ClearPlayerBitg_iFrozeniId );
    
    
emit_soundiIdCHAN_BODYg_szUnfreezesoundVOL_NORMATTN_NORM0PITCH_NORM );
    
entity_set_intiIdEV_INT_flagsentity_get_intiIdEV_INT_flags ) & ~FL_FROZEN );
    
    
set_renderingiId );
}

public 
client_disconnectiId )
{
    
remove_taskiId );
    
    
ClearPlayerBitg_iAlive,iId );
    
ClearPlayerBitg_iFrozen,iId );
}

/* ===========================================================================​​​
*                 [ Stocks ]
*  ===========================================================================​​​ */

FrostZone( const Float:fOrigin] )
{
    static 
iiOrigin]; FVecIVecfOrigin,iOrigin );
    
    for( 
14i++ )
    {
        
message_beginMSG_BROADCASTSVC_TEMPENTITY );
        
write_byteTE_BEAMCYLINDER );
        
write_coordiOrigin] );
        
write_coordiOrigin] );
        
write_coordiOrigin] );
        
write_coordiOrigin] );
        
write_coordiOrigin] );
        
write_coordiOrigin] + (111) );
        
write_shortg_iBeam );
        
write_byte);
        
write_byte);
        
write_byte);
        
write_byte100 );
        
write_byte);
        
write_byte);
        
write_byte50 );
        
write_byte250 );
        
write_byte200 );
        
write_byte);
        
message_end( );
    }
    
    
message_beginMSG_BROADCAST,SVC_TEMPENTITY );
    
write_byteTE_SPRITETRAIL );
    
write_coordiOrigin] );
    
write_coordiOrigin] );
    
write_coordiOrigin] );
    
write_coordiOrigin] );
    
write_coordiOrigin] );
    
write_coordiOrigin] );
    
write_shortg_iBlueflare );
    
write_byte100 );
    
write_byte);
    
write_byte);
    
write_byte50 );
    
write_byte50 );
    
message_end( );
    
    
message_beginMSG_BROADCAST,SVC_TEMPENTITY );
    
write_byteTE_DLIGHT );
    
write_coordiOrigin] );
    
write_coordiOrigin] );
    
write_coordiOrigin] );
    
write_byte48 );
    
write_byte);
    
write_byte50 );
    
write_byte255 );
    
write_byte10 );
    
write_byte50 );
    
message_end( );
}

SendPlayerScreenfade( const iId )
{
    
message_beginMSG_ONE_UNRELIABLEg_iScreenfade, { 00}, iId );
    
write_short1<<12 );
    
write_short( (1<<12)*);
    
write_short0x0000 );
    
write_byte);
    
write_byte50 );
    
write_byte250 );
    
write_byte150 );
    
message_end( );
    
    return 
1;

No hago trabajos privados. Si necesitás ayuda, abrí un nuevo tema.
¿Buscás un ejemplo o algún modo de juego? Podés echarle un vistazo a mis aportes
.
Responder
#19
(26/11/2015, 11:17 PM)meTaLiCroSS escribió: Hay que pulir en muchas partes ese código, despues me animo

Se le rompió la pulidora parece Roflmao



Se ve bueno este aporte, hay porciones de código interesantes Thinking
Believe, be yourself and don't hold on to just one dream ❤

https://github.com/FEDERICOMB96
Responder
#20
Que granada remplaza?
Help a anonymous.
SOMOS LEGION..
¡NO OLVIDAMOS!
Esperamos...

MI STEAM pacman
Responder
#21
(29/05/2017, 10:46 PM)Anonymous. escribió: Que granada remplaza?

Prueba nmms
Reviviste esto
Responder
#22
Buen plugin mejor que el de avalanche..
Responder
#23
Como quito los efectos de la nieve? pacman sorry
Responder
#24
(21/10/2017, 01:39 AM)Luqqas M escribió: Como quito los efectos de la nieve? pacman sorry

Código PHP:
message_beginMSG_BROADCAST,SVC_TEMPENTITY );
    
write_byteTE_SPRITETRAIL );
    
write_coordiOrigin] );
    
write_coordiOrigin] );
    
write_coordiOrigin] );
    
write_coordiOrigin] );
    
write_coordiOrigin] );
    
write_coordiOrigin] );
    
write_shortg_iBlueflare );
    
write_byte100 );
    
write_byte);
    
write_byte);
    
write_byte50 );
    
write_byte50 );
    
message_end( ); 

Esa parte es la de la "nieve" que sale. Y para que no salga los bloquesitos congelados en los pies tenés que comentar esta linea "CreateNova( iVictim );" en CreateFrostEffect.
No hago trabajos privados. Si necesitás ayuda, abrí un nuevo tema.
¿Buscás un ejemplo o algún modo de juego? Podés echarle un vistazo a mis aportes
.
Responder
#25
Treki me dijo que publique este código acá, lo actualizó y arreglo unos problemas

Código PHP:
#include <amxmodx>
#include <fakemeta>
#include <engine>
#include <hamsandwich>

/* =================================================================================
*               [ Global ]
* ================================================================================= */

#define PLAYER_ARRAY            33

#define IsPlayer(%0)            ( 1 <= %0 <= 32 )

#define GetPlayerBit(%0,%1)     ( IsPlayer(%1) && ( %0 & ( 1 << ( %1 & 31 ) ) ) )
#define SetPlayerBit(%0,%1)     ( IsPlayer(%1) && ( %0 |= ( 1 << ( %1 & 31 ) ) ) )
#define ClearPlayerBit(%0,%1)   ( IsPlayer(%1) && ( %0 &= ~( 1 << ( %1 & 31 ) ) ) )

#define HasRoundStarted()       ( g_flLastRoundEnd + 5.0 < get_gametime( ) )

#define IsEnemy(%0,%1)          ( get_user_team( %0 ) != get_user_team( %1 ) )
#define IsPlayerCrouching(%0)     ( entity_get_int( %0, EV_INT_flags ) & FL_DUCKING )

const FROSTNADE_ID 8878;

const 
TASK_REMOVE_FREEZE 4096;

new const 
g_szUnfreezeSound[ ]      = "frostnade/impalelaunch1.wav";
new const 
g_szFreezeSound[ ]        = "frostnade/impalehit.wav";
new const 
g_szFrostNovaSound[ ]     = "frostnade/frostnova.wav";

new const 
g_szNovaModel[ ]          = "models/frostnade/nova.mdl";

new const 
g_szInfoTarget[ ]         = "info_target";
new const 
g_szNovaClassname[ ]      = "Nova";

new 
g_iIsConnected;
new 
g_iIsAlive;
new 
g_iIsFrozen;

new 
g_iBlueflare;
new 
g_iBeam;
new 
g_iScreenFade;
new 
g_iMaxPlayers;

new 
Float:g_flPlayerVelocityPLAYER_ARRAY ][ ];

new 
Float:g_flLastRoundEnd;

/* =================================================================================
*               [ Plugin forwards ]
* ================================================================================= */

public plugin_precache( )
{
    
precache_soundg_szUnfreezeSound );
    
precache_soundg_szFreezeSound );
    
precache_soundg_szFrostNovaSound );
    
    
precache_modelg_szNovaModel );
    
    
g_iBeam         precache_model"sprites/frostnade/beam.spr" );
    
g_iBlueflare     precache_model"sprites/frostnade/blueflare.spr" );
}

public 
plugin_init( )
{
    
register_plugin"FrostNade""1.0""Manu" );
    
    
register_forwardFM_SetModel"OnSetModel_Pre"false );
    
    
RegisterHamHam_Think"grenade""OnGrenadeThink_Pre"false );
    
    
RegisterHamHam_Killed"player""OnPlayerKilled_Pre"false );
    
RegisterHamHam_Spawn"player""OnPlayerSpawn_Post"true );
    
    
register_logevent"OnRoundEnd"2"1=Round_End" );
    
    
g_iMaxPlayers get_maxplayers( );
    
g_iScreenFade get_user_msgid"ScreenFade" );
}

/* =================================================================================
*               [ Events ]
* ================================================================================= */

public OnRoundEnd( )
{
    for ( new 
iPlayer iPlayer <= g_iMaxPlayers iPlayer++ )
    {
        if ( !
GetPlayerBitg_iIsFrozeniPlayer ) )
        {
            continue;
        }
        
        
UnfreezePlayeriPlayer );
    }
    
    
g_flLastRoundEnd get_gametime( );
    
    
RemoveEntityByClassnameg_szNovaClassname );
}

/* =================================================================================
*               [ Grenade section ]
* ================================================================================= */

public OnSetModel_PreiEntszModel[ ] )
{
    if ( !
HasRoundStarted( ) || ( strlenszModel ) < ) )
    {
        return 
FMRES_IGNORED;
    }
    
    if ( ( 
szModel] != 'w' ) || ( szModel] != '_' ) || ( szModel] != 's' ) )
    {
        return 
FMRES_IGNORED;
    }
    
    if ( 
entity_get_floatiEntEV_FL_dmgtime ) == 0.0 )
    {
        return 
FMRES_IGNORED;
    }
    
    
entity_set_intiEntEV_INT_flTimeStepSoundFROSTNADE_ID );
    
    
message_beginMSG_BROADCASTSVC_TEMPENTITY );
    
write_byteTE_BEAMFOLLOW );
    
write_shortiEnt );
    
write_shortg_iBeam );
    
write_byte25 );
    
write_byte);
    
write_byte);
    
write_byte50 );
    
write_byte250 );
    
write_byte200 );
    
message_end( );
    
    
set_renderingiEntkRenderFxGlowShell050250kRenderNormal16 );
    
    return 
FMRES_IGNORED;
}

public 
OnGrenadeThink_PreiEnt )
{
    if ( !
HasRoundStarted( ) )
    {
        return 
HAM_IGNORED;
    }
    
    if ( 
entity_get_floatiEntEV_FL_dmgtime ) > get_gametime( ) )
    {
        return 
HAM_IGNORED;
    }
    
    if ( 
entity_get_intiEntEV_INT_flTimeStepSound ) != FROSTNADE_ID )
    {
        return 
HAM_IGNORED;
    }
    
    
FrostExplodeiEnt );
    
    return 
HAM_SUPERCEDE;
}

/* =================================================================================
*               [ Player events ]
* ================================================================================= */

public OnPlayerSpawn_PostiId )
{
    if ( !
is_user_aliveiId ) )
    {
        return 
HAM_IGNORED;
    }
    
    
SetPlayerBitg_iIsAliveiId );
    
    return 
HAM_IGNORED;
}

public 
OnPlayerKilled_PreiVictimiAttackeriShouldgib )
{
    
ClearPlayerBitg_iIsAliveiVictim );
    
    if ( !
GetPlayerBitg_iIsFrozeniVictim ) )
    {
        return 
HAM_IGNORED;
    }
    
    
UnfreezePlayeriVictim );
    
    
RemoveEntityByOwneriVictimg_szNovaClassname );
    
    
remove_taskiVictim TASK_REMOVE_FREEZE );
    
    return 
HAM_IGNORED;
}

public 
OnTaskRemoveFreezeiTask )
{
    new 
iId = ( iTask TASK_REMOVE_FREEZE );
    
    if ( 
GetPlayerBitg_iIsFrozeniId ) )
    {
        
UnfreezePlayeriId );
    }
}

/* =================================================================================
*               [ Client connection ]
* ================================================================================= */

public client_putinserveriId )
{
    
SetPlayerBitg_iIsConnectediId );
}

public 
client_disconnectiId )
{
    if ( 
task_existsiId TASK_REMOVE_FREEZE ) )
    {
        
remove_taskiId TASK_REMOVE_FREEZE );
    }
    
    
ClearPlayerBitg_iIsConnectediId );
    
ClearPlayerBitg_iIsAliveiId );
    
ClearPlayerBitg_iIsFrozeniId );
}

/* =================================================================================
*               [ Frostnade modules ]
* ================================================================================= */

FrostExplode( const iEnt )
{
    new 
iOwner entity_get_edictiEntEV_ENT_owner );

    if ( !
GetPlayerBitg_iIsConnectediOwner ) )
    {
        return;
    }
    
    new 
Float:flOrigin];
    
    
entity_get_vectoriEntEV_VEC_originflOrigin );

    
CreateFrostEffectflOrigin );

    
emit_soundiEntCHAN_BODYg_szFrostNovaSoundVOL_NORMATTN_NORM0PITCH_NORM );
    
    new 
iVictim;
    
    while ( ( 
iVictim find_ent_in_sphereiVictimflOrigin250.0 ) ) > )
    {
        if ( 
iVictim == iOwner )
        {
            continue;
        }
        
        if ( !
GetPlayerBitg_iIsAliveiVictim ) || GetPlayerBitg_iIsFrozeniVictim ) )
        {
            continue;
        }
        
        
FreezePlayeriVictim );
        
        
set_task4.0"OnTaskRemoveFreeze"iVictim TASK_REMOVE_FREEZE );
    }

    
remove_entityiEnt );
}

FreezePlayer( const iId )
{
    
SetPlayerBitg_iIsFrozeniId );
    
    
entity_get_vectoriIdEV_VEC_velocityg_flPlayerVelocityiId ] );
    
    
entity_set_vectoriIdEV_VEC_velocityFloat:{ 0.00.00.0 } );
    
entity_set_intiIdEV_INT_flagsentity_get_intiIdEV_INT_flags ) | FL_FROZEN );
    
    
emit_soundiIdCHAN_BODYg_szFreezeSoundVOL_NORMATTN_NORM0PITCH_NORM );
    
    
set_renderingiIdkRenderFxGlowShell060240kRenderNormal80 );
    
    
SendScreenFadeiId, { 160240 }, 410x000040 );
    
    
CreateNovaiId );
}

UnfreezePlayer( const iId )
{
    
ClearPlayerBitg_iIsFrozeniId );
    
    
entity_set_intiIdEV_INT_flagsentity_get_intiIdEV_INT_flags ) & ~FL_FROZEN );
    
entity_set_vectoriIdEV_VEC_velocityg_flPlayerVelocityiId ] );
    
    
emit_soundiIdCHAN_BODYg_szUnfreezeSoundVOL_NORMATTN_NORM0PITCH_NORM );
    
    
set_renderingiId );
}

CreateFrostEffect( const Float:flOrigin] )
{
    new 
iOrigin];
    
    
FVecIVecflOriginiOrigin );
    
    for ( new 
i++ )
    {
        
message_beginMSG_BROADCASTSVC_TEMPENTITY );
        
write_byteTE_BEAMCYLINDER );
        
write_coordiOrigin] );
        
write_coordiOrigin] );
        
write_coordiOrigin] );
        
write_coordiOrigin] );
        
write_coordiOrigin] );
        
write_coordiOrigin] + ( 111 ) );
        
write_shortg_iBeam );
        
write_byte);
        
write_byte);
        
write_byte);
        
write_byte100 );
        
write_byte);
        
write_byte);
        
write_byte50 );
        
write_byte250 );
        
write_byte200 );
        
write_byte);
        
message_end( );
    }
    
    
message_beginMSG_BROADCASTSVC_TEMPENTITY );
    
write_byteTE_SPRITETRAIL );
    
write_coordiOrigin] );
    
write_coordiOrigin] );
    
write_coordiOrigin] );
    
write_coordiOrigin] );
    
write_coordiOrigin] );
    
write_coordiOrigin] );
    
write_shortg_iBlueflare );
    
write_byte100 );
    
write_byte);
    
write_byte);
    
write_byte50 );
    
write_byte50 );
    
message_end( );
    
    
message_beginMSG_BROADCASTSVC_TEMPENTITY );
    
write_byteTE_DLIGHT );
    
write_coordiOrigin] );
    
write_coordiOrigin] );
    
write_coordiOrigin] );
    
write_byte48 );
    
write_byte);
    
write_byte50 );
    
write_byte255 );
    
write_byte10 );
    
write_byte50 );
    
message_end( );
}

CreateNova( const iId )
{
    new 
iEnt create_entityg_szInfoTarget ); 

    if ( !
is_valid_entiEnt ) )
    {
        return 
0;
    }
    
    new 
Float:flOrigin];

    
entity_set_stringiEntEV_SZ_classnameg_szNovaClassname );

    
entity_set_sizeiEntFloat:{ -4.0, -4.0, -4.0 }, Float:{ 4.04.04.0 } );
    
entity_set_modeliEntg_szNovaModel );

    
entity_set_intiEntEV_INT_solidSOLID_NOT );
    
entity_set_intiEntEV_INT_movetypeMOVETYPE_FLY );

    
entity_get_vectoriIdEV_VEC_originflOrigin );
    
    
IsPlayerCrouchingiId ) ?
        ( 
flOrigin] -= 18.0 ) :
        ( 
flOrigin] -= 36.0 ); 
    
    
entity_set_vectoriEntEV_VEC_originflOrigin );

    
entity_set_edictiEntEV_ENT_owneriId );
    
    
entity_set_intiEntEV_INT_flagsentity_get_intiEntEV_INT_flags ) | FL_KILLME );
    
    
entity_set_floatiEntEV_FL_takedamageDAMAGE_NO );
    
entity_set_floatiEntEV_FL_nextthinkget_gametime( ) + 4.0 );

    return 
1;
}

/* =================================================================================
*               [ Common modules ]
* ================================================================================= */

RemoveEntityByClassname( const szClassname[ ] )
{
    new 
iEnt = -1;
    
    while ( ( 
iEnt find_ent_by_classiEntszClassname ) ) > )
    {
        
remove_entityiEnt );
    }
}

RemoveEntityByOwner( const iOwner, const szClassname[ ] )
{
    new 
iEnt = -1;
    
    while ( ( 
iEnt find_ent_by_owneriEntszClassnameiOwner ) ) > )
    {
        
remove_entityiEnt );
    }
}

SendScreenFade( const iPlayer, const iRGB], const iDuration, const iHoldTime, const iFlag, const iAlpha )
{
    
message_beginMSG_ONE_UNRELIABLEg_iScreenFade_iPlayer );
    
write_short( ( 1<<12 ) * iDuration );
    
write_short( ( 1<<12 ) * iHoldTime );
    
write_shortiFlag );
    
write_byteiRGB] );
    
write_byteiRGB] );
    
write_byteiRGB] );
    
write_byteiAlpha );
    
message_end( );

Responder


Salto de foro:


Usuarios navegando en este tema: 1 invitado(s)