04/06/2023, 09:45 PM
(Última modificación: 13/06/2023, 09:54 PM por MaximoGT. Edited 2 times in total.)
Hola, necesito poder hacer lo siguiente en el mod de freeze tag de Javivi, hacer que a un terrorista cuando lo descongelan tenga inmunidad a ser congelado durante 2 o 3 segundos y ademas que no pueda descongelar a su demas compañeros de equipo en ese estado de inmunidad. La verdad que soy bastante novato en esto y no entiendo como hacerlo, si me pueden ayudar se los agradeceria mucho.
Código:
/*
********************
** Freeze Tag Mod **
********************
http://forums.alliedmods.net/showthread.php?t=136382
Made by Javivi
*/
#include < amxmodx >
#include < fun >
#include < engine >
#include < cstrike >
#include < fakemeta >
#include < hamsandwich >
// Comment/Uncomment that if you want to auto un-freeze players after an ammount of time
//#define FROZENTIMELIMIT
#define MAXPLAYERS 32
// Task IDs
#define TASKID_ROUNDEND 1338
#define TASKID_UNFREEZE 8331
/*! Consts */
const g_cWepOffset = 4;
const g_cNextPAttack = 46;
const g_cNextSAttack = 47;
// Player Team
new CsTeams:g_Team[ MAXPLAYERS + 1 ]
#if defined FROZENTIMELIMIT
// Time count
new g_Time[ MAXPLAYERS + 1 ]
#endif
// Frozen/Alive T count
new g_FrozenT, g_aliveT
// HudSync / HideWeapon msg / SayText msg
new g_HudSync, g_msgHideWeapon, g_msgSayText
// CVAR
new cvar_roundtime, cvar_hidecrosshair, cvar_pShowKnife
#if defined FROZENTIMELIMIT
, cvar_maxfrozentime, cCvar_maxfrozentime
#endif
// Remove objetives
new PrecacheSpawn
new const RemoveEntities[ ][ ] =
{
"func_hostage_rescue", "info_hostage_rescue", "func_bomb_target", "info_bomb_target",
"hostage_entity", "info_vip_start", "func_vip_safetyzone", "func_escapezone"
}
// mp_roundtime pointer
new p_roundtime
new g_maxplayers
public plugin_init( )
{
// Remove objetives
unregister_forward( FM_Spawn, PrecacheSpawn )
register_plugin( "Freeze Tag", "1.4", "Javivi" )
// Hamsandwich forwards
RegisterHam( Ham_Spawn, "player", "fw_PlayerSpawn", 1 )
RegisterHam( Ham_Killed, "player", "fw_PlayerKilled", 1 )
RegisterHam( Ham_Touch, "player", "fw_PlayerTouch" )
// Info
register_clcmd( "say /status", "status" )
// Block buy
register_message( get_user_msgid( "StatusIcon" ), "msg_statusicon" )
// Block win sound & win msg
register_message( get_user_msgid( "SendAudio" ), "msg_sendaudio" )
register_message( get_user_msgid( "TextMsg" ), "msg_textmsg" )
// Round start
register_event( "HLTV", "new_round", "a", "1=0", "2=0" );
// CVARs
cvar_roundtime = register_cvar( "ft_roundtime", "180.0" )
cvar_hidecrosshair = register_cvar( "ft_hidecrosshair", "1" )
#if defined FROZENTIMELIMIT
cvar_maxfrozentime = register_cvar( "ft_maxfrozentime", "120" )
#endif
// Hide weapon msg
g_msgHideWeapon = get_user_msgid( "HideWeapon" )
// SayText msg
g_msgSayText = get_user_msgid( "SayText" )
// Remove all weapons on the map
new Ent = -1
while ( ( Ent = find_ent_by_class( Ent, "armoury_entity" ) ) )
{
remove_entity( Ent )
}
// Gamemonitor info
register_cvar( "ft_version", "1.4 by Javivi", FCVAR_SERVER|FCVAR_SPONLY )
// Roundtime pointer
p_roundtime = get_cvar_pointer( "mp_roundtime" )
// Set no freezetime
set_cvar_num( "mp_freezetime", 0 )
g_maxplayers = get_maxplayers( )
g_HudSync = CreateHudSyncObj( )
}
public status( id )
{
client_print( id, print_chat, "Alive: %d Frozen: %d", g_aliveT, g_FrozenT )
}
// Remove objetives
public plugin_precache( ){
PrecacheSpawn = register_forward( FM_Spawn, "precache_spawn", 1 )
}
public precache_spawn( ent )
{
if( is_valid_ent( ent ) )
{
static szClass[ 33 ]
entity_get_string( ent, EV_SZ_classname, szClass, sizeof( szClass ) )
for( new i = 0; i < sizeof( RemoveEntities ); i++ )
if( equal( szClass, RemoveEntities[ i ]) )
remove_entity( ent )
}
}
public client_disconnect( id )
{
if( g_Team[ id ] == CS_TEAM_T && is_user_alive( id ) )
{
g_aliveT--
// Check if all the terrorist are frozen
CheckTerrorist( )
}
}
public fw_PlayerSpawn( id )
{
if( is_user_alive( id ) )
{
set_user_rendering( id )
strip_user_weapons( id )
if( get_pcvar_num( cvar_hidecrosshair ) )
{
message_begin( MSG_ONE, g_msgHideWeapon, _, id )
write_byte( 1<<6 )
message_end( )
}
g_Team[ id ] = cs_get_user_team( id )
if( g_Team[ id ] == CS_TEAM_T )
g_aliveT++
}
}
public fw_PlayerKilled( victim )
{
if( g_Team[ victim ] == CS_TEAM_T )
{
g_aliveT--
// Check if all the terrorist are frozen
CheckTerrorist( )
}
}
public fw_PlayerTouch( Touched, Toucher )
{
if( ( 1 <= Toucher <= g_maxplayers ) )
{
static Flags; Flags = entity_get_int( Touched, EV_INT_flags )
// Freeze an enemy
if( g_Team[ Toucher ] == CS_TEAM_CT && g_Team[ Touched ] == CS_TEAM_T ) {
// Already frozen ?
if( Flags & FL_FROZEN )
return
entity_set_int( Touched, EV_INT_flags, Flags | FL_FROZEN)
g_FrozenT++
// msg
static dName[ 33 ]; get_user_name( Touched, dName, charsmax( dName ) )
static rName[ 33 ]; get_user_name( Toucher, rName, charsmax( rName ) )
new chatcolor[ 125 ]
formatex( chatcolor, 124, "^3[ MANCHA ]^4 %s ^1ha sido tocado por ^4 %s ^1, y ahora esta congelado!", dName, rName)
client_print_c( chatcolor )
// Check if all the terrorist are frozen
CheckTerrorist( )
set_user_rendering( Touched, kRenderFxGlowShell, 0, 255, 255, kRenderNormal, 40 )
#if defined FROZENTIMELIMIT
g_Time[ Touched ] = 0
set_task( 1.0, "Countdown", Touched + TASKID_UNFREEZE, _, _, "b" )
#endif
}
// Unfreeze a teammate
if( g_Team[ Toucher ] == CS_TEAM_T && g_Team[ Touched ] == CS_TEAM_T )
{
if( Flags & FL_FROZEN )
{
#if defined FROZENTIMELIMIT
remove_task( Touched + TASKID_UNFREEZE )
#endif
// msg
static dName[ 33 ]; get_user_name( Touched, dName, charsmax( dName ) )
static rName[ 33 ]; get_user_name( Toucher, rName, charsmax( rName ) )
new chatcolor[ 125 ]
formatex( chatcolor, 124, "^3[ MANCHA ]^4 %s ^1ha sido tocado por ^4 %s ^1, y ahora esta descongelado!", dName, rName)
client_print_c( chatcolor )
entity_set_int( Touched, EV_INT_flags, Flags &~ FL_FROZEN )
g_FrozenT--
set_user_rendering( Touched )
}
}
}
}
// Round Start
public new_round( )
{
g_FrozenT = 0
g_aliveT = 0
#if defined FROZENTIMELIMIT
// Cache the maxfrozentime cvar
cCvar_maxfrozentime = get_pcvar_num( cvar_maxfrozentime )
#endif
static Float:ccvar_roundtime; ccvar_roundtime = get_pcvar_float( cvar_roundtime )
set_pcvar_float( p_roundtime, ccvar_roundtime / 60 )
// mmm
remove_task( TASKID_ROUNDEND )
set_task( ccvar_roundtime, "Roundend", TASKID_ROUNDEND )
}
public Roundend( task )
{
set_hudmessage( 255, 0, 0, -1.0, 0.40, 1, 6.0, 5.0 )
ShowSyncHudMsg( 0, g_HudSync, "Terrorist Win !" )
client_cmd( 0, "spk radio/terwin.wav" )
g_aliveT = 0
for ( new id = 1; id <= g_maxplayers; id++ )
{
if( !is_user_connected( id ) )
continue
Unfreeze( id )
switch( g_Team [ id ] )
{
case CS_TEAM_CT: user_silentkill( id )
case CS_TEAM_T: set_user_frags( id, get_user_frags( id ) + 1 )
}
}
}
#if defined FROZENTIMELIMIT
public CountDown( task )
{
static id; id = task - TASKID_UNFREEZE
g_Time[ id ]++
if( g_Time[ id ] >= cCvar_maxfrozentime )
{
Unfreeze( id )
remove_task( task )
return
}
set_hudmessage( 255, 255, 255, -1.0, -1.0, 0, 6.0, 1.0 )
ShowSyncHudMsg( 0, g_HudSync, "You will be auto un-frozen in : %d", cCvar_maxfrozentime - g_Time[ id ] )
}
#endif
public Unfreeze( id )
{
// Unfreeze player if it's frozen
static Flags; Flags = entity_get_int( id, EV_INT_flags )
if( Flags & FL_FROZEN )
entity_set_int( id, EV_INT_flags, Flags &~ FL_FROZEN )
}
// Buyzone
public msg_statusicon( msgid, dest, id )
{
static icon[ 5 ]
get_msg_arg_string( 2, icon, charsmax( icon ) )
if( icon[ 0 ] == 'b' && icon[ 2 ] == 'y' && icon[ 3 ] == 'z' )
{
// Block buy
set_pdata_int( id, 235, get_pdata_int( id, 235 ) &~ ( 1<<0 ) )
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
// Block win msg
public msg_textmsg( msg_id, msg_dest, msg_entity )
{
static message[ 3 ]
get_msg_arg_string( 2, message, charsmax( message ) )
switch( message[1] )
{
case 'C', 'T':
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
// Block win sound
public msg_sendaudio( msg_id, msg_dest, msg_entity )
{
static message[10]
get_msg_arg_string( 2, message, charsmax( message ) )
switch( message[7] )
{
case 'c', 't' :
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
// Check if all the terrorist are frozen
CheckTerrorist( )
{
if( g_aliveT == g_FrozenT )
{
remove_task( TASKID_ROUNDEND )
g_aliveT = 0
set_hudmessage( 0, 0, 255, -1.0, 0.40, 1, 6.0, 5.0 )
ShowSyncHudMsg( 0, g_HudSync, "Counter-Terrorist Win !" )
client_cmd( 0, "blockmaker/boing.wav" )
// Swap teams
for ( new id = 1; id <= g_maxplayers; id++ )
{
if( !is_user_connected( id ) )
continue
Unfreeze( id )
switch( g_Team[ id ] )
{
case CS_TEAM_T:
{
user_silentkill( id )
//cs_set_user_team( id , CS_TEAM_CT )
}
case CS_TEAM_CT:
{
set_user_frags( id, get_user_frags( id ) + 1 )
//cs_set_user_team( id, CS_TEAM_T )
}
}
set_task( 1.0, "DelayedChangeTeam", id ) // little bugfix
}
}
}
public DelayedChangeTeam( id )
{
if( is_user_connected( id ) )
{
switch( g_Team[ id ] )
{
case CS_TEAM_T:
{
cs_set_user_team( id , CS_TEAM_CT )
}
case CS_TEAM_CT:
{
cs_set_user_team( id, CS_TEAM_T )
}
}
}
}
// Chat color stock
client_print_c(const fmt[], any:...)
{
new szString[128]
szString[0] = 4
vformat(szString, sizeof( szString ) - 2, fmt, 2)
message_begin(MSG_BROADCAST, g_msgSayText)
write_byte(1)
write_string(szString)
message_end()
}