Yo queria obtener X partes de 1 mapa y blokear el kill como hace este plug que encontre.
PHP Code:
#include < amxmodx >
#include < engine >
#include < hamsandwich >
#define IsPlayer(%1) ( 1 <= %1 <= g_iMaxPlayers )
new const g_szClassname[ ] = "trigger_rules_watch";
enum _:RoomTypes {
JAIL,
GUNROOM,
MARIOROOM
};
enum _:CVARS {
CV_JAIL_NOKILL,
CV_JAIL_TIME,
CV_GUNROOM_NOKILL,
CV_GUNROOM_TIME,
CV_MARIOROOM_NOKILL,
CV_MARIOROOM_TIME
};
new const g_szZones[ RoomTypes ][ ] = {
"Jail",
"Gun room",
"Mario room"
};
new const Float:g_flOrigins[ ][ 3 ] = {
{ -405.0, 2900.0, 720.0 },
{ -486.0, -1000.0, -275.0 },
{ -405.0, 2949.0, 2422.0 }
};
new const Float:g_flAngles[ ][ 3 ] = {
{ 0.0, 270.0, 0.0 },
{ 0.0, 270.0, 0.0 },
{ 0.0, 270.0, 0.0 }
};
new g_iMaxPlayers;
new g_iCounter[ 33 ];
new bool:g_bNoKill[ 33 ];
new Float:g_flLastTouch[ 33 ];
new g_pCvars[ CVARS ], g_iCvars[ CVARS ];
public plugin_init( ) {
register_plugin( "-", "1.0", "-" );
register_cvar( "ss2_rules_watcher", "1.1", FCVAR_SERVER | FCVAR_SPONLY );
g_iMaxPlayers = get_maxplayers( );
g_pCvars[ CV_JAIL_NOKILL ] = register_cvar( "rw_ss2_jail_nokill", "0" );
g_pCvars[ CV_JAIL_TIME ] = register_cvar( "rw_ss2_jail_time", "0" );
g_pCvars[ CV_GUNROOM_NOKILL ] = register_cvar( "rw_ss2_gunroom_nokill", "1" );
g_pCvars[ CV_GUNROOM_TIME ] = register_cvar( "rw_ss2_gunroom_time", "0" );
g_pCvars[ CV_MARIOROOM_NOKILL ] = register_cvar( "rw_ss2_marioroom_nokill", "1" );
g_pCvars[ CV_MARIOROOM_TIME ] = register_cvar( "rw_ss2_marioroom_time", "0" );
new szMap[ 12 ];
get_mapname( szMap, 11 );
if( equali( szMap, "surf_ski_2" ) ) {
CreateTrigger( JAIL, Float:{ -579.0, 2983.0, 586.0 }, Float:{ -309.0, 3288.0, 796.0 } );
CreateTrigger( GUNROOM, Float:{ -713.0, -990.0, -157.0 }, Float:{ -295.0, -651.0, 26.0 } );
CreateTrigger( MARIOROOM, Float:{ 2735.0, 193.0, -2361.0 }, Float:{ 3654.0, 1118.0, -2083.0 } );
register_touch( g_szClassname, "player", "FwdTriggerTouch" );
RegisterHam( Ham_Spawn, "player", "FwdHamPlayerSpawn", 1 );
RegisterHam( Ham_TakeDamage, "player", "FwdHamTakeDamage" );
RegisterHam( Ham_TraceAttack, "player", "FwdHamTraceAttack" );
register_event( "HLTV", "EventNewRound", "a", "1=0", "2=0" );
CacheCvars( );
}
}
public EventNewRound( )
CacheCvars( );
public FwdHamPlayerSpawn( const id ) {
if( is_user_alive( id ) ) {
g_bNoKill[ id ] = false;
g_flLastTouch[ id ] = 0.0;
g_iCounter[ id ] = 0;
}
}
public FwdHamTraceAttack( const id, const iAttacker ) {
if( IsPlayer( iAttacker ) && g_bNoKill[ id ] && id != iAttacker ) {
if( ( g_flLastTouch[ id ] + 0.1 ) >= get_gametime( ) )
return HAM_SUPERCEDE;
else
g_bNoKill[ id ] = false;
}
return HAM_IGNORED;
}
public FwdHamTakeDamage( const id, const iInflictor, const iAttacker ) {
if( IsPlayer( iAttacker ) && g_bNoKill[ id ] && id != iAttacker ) {
if( ( g_flLastTouch[ id ] + 0.1 ) >= get_gametime( ) )
return HAM_SUPERCEDE;
else
g_bNoKill[ id ] = false;
}
return HAM_IGNORED;
}
public FwdTriggerTouch( const iEntity, const id ) {
static Float:flGametime;
flGametime = get_gametime( );
if( flGametime > ( g_flLastTouch[ id ] + 1.2 ) ) {
g_iCounter[ id ] = 0;
g_flLastTouch[ id ] = flGametime;
}
else if( g_flLastTouch[ id ] < flGametime ) {
g_iCounter[ id ]++;
static iType, bool:bNoKill, iTime;
iType = entity_get_int( iEntity, EV_INT_iuser1 );
GetCvars( iType, bNoKill, iTime );
g_bNoKill[ id ] = bNoKill;
if( iTime > 0 ) {
if( g_iCounter[ id ] >= iTime ) {
if( iTime >= 5 ) {
engclient_print( id, engprint_center, "^nSe puso mas de %i segundos en%s%s.^nUsted ha sido expulsado.", iTime, iType == MARIOROOM ? "^n" : " ", g_szZones[ iType ] );
client_cmd( id, "spk buttons/blip1" );
}
entity_set_vector( id, EV_VEC_angles, g_flAngles[ iType ] );
entity_set_int( id, EV_INT_fixangle, 1 );
entity_set_origin( id, g_flOrigins[ iType ] );
}
if( g_iCounter[ id ] < 5 ) {
if( iTime >= 5 )
engclient_print( id, engprint_center, "%sUsted esta en %s.%s^n^nUsted tiene %i segundos para salir!", bNoKill ? "" : "^n", g_szZones[ iType ], bNoKill ? "^nNo se puede matar a nadie aqui." : "", iTime );
else
engclient_print( id, engprint_center, "%sUsted esta %s.%s", bNoKill ? "" : "^n", g_szZones[ iType ], bNoKill ? "^nNo se puede matar a nadie aqui." : "" );
}
}
g_flLastTouch[ id ] = flGametime + 1.0;
}
}
GetCvars( const iType, &bool:bNoKill, &iTime ) {
static CvarNoKill, CvarTime;
switch( iType ) {
case JAIL: {
CvarNoKill = CV_JAIL_NOKILL;
CvarTime = CV_JAIL_TIME;
}
case GUNROOM: {
CvarNoKill = CV_GUNROOM_NOKILL;
CvarTime = CV_GUNROOM_TIME;
}
case MARIOROOM: {
CvarNoKill = CV_MARIOROOM_NOKILL;
CvarTime = CV_MARIOROOM_TIME;
}
}
bNoKill = bool:( g_iCvars[ CvarNoKill ] );
iTime = g_iCvars[ CvarTime ];
}
CacheCvars( ) {
g_iCvars[ CV_JAIL_NOKILL ] = get_pcvar_num( g_pCvars[ CV_JAIL_NOKILL ] );
g_iCvars[ CV_JAIL_TIME ] = get_pcvar_num( g_pCvars[ CV_JAIL_TIME ] );
g_iCvars[ CV_GUNROOM_NOKILL ] = get_pcvar_num( g_pCvars[ CV_GUNROOM_NOKILL ] );
g_iCvars[ CV_GUNROOM_TIME ] = get_pcvar_num( g_pCvars[ CV_GUNROOM_TIME ] );
g_iCvars[ CV_MARIOROOM_NOKILL ] = get_pcvar_num( g_pCvars[ CV_MARIOROOM_NOKILL ] );
g_iCvars[ CV_MARIOROOM_TIME ] = get_pcvar_num( g_pCvars[ CV_MARIOROOM_TIME ] );
}
CreateTrigger( const iType, const Float:flMins[ 3 ], const Float:flMaxs[ 3 ] ) {
new iEntity = create_entity( "info_target" );
if( !is_valid_ent( iEntity ) ) {
log_amx( "Hubo un error con la creación de ^"%s^"", g_szZones[ iType ] );
return 0;
}
entity_set_string( iEntity, EV_SZ_classname, g_szClassname );
entity_set_int( iEntity, EV_INT_iuser1, iType );
entity_set_int( iEntity, EV_INT_movetype, MOVETYPE_NONE );
entity_set_int( iEntity, EV_INT_solid, SOLID_TRIGGER );
entity_set_size( iEntity, flMins, flMaxs );
return iEntity;
}