AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   [REQ] No Kill Zone but with different way.. (https://forums.alliedmods.net/showthread.php?t=231328)

ImPossibLe 12-12-2013 09:10

[REQ] No Kill Zone but with different way..
 
Hi guys.
I want to protect some places at surf maps.
Like surf_green 's buy..

I can make it with ss2 ruleswatcher.
But if i make with this way, a player at protected area, can't kill by other places.
I don't want this, if player in protected area, must can't kill by in same place. He must be able to attack by other players..

I think it's possible, but how ...

Anyone can edit here or rewrite another code?
Thanks a lot.. :)

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_szZonesRoomTypes ][ ] = {
    
"Jail",
    
"Gun room",
    
"Mario room"
};

new const 
Float:g_flOrigins[ ][ ] = {
    { -
405.02900.0720.0 },
    { -
486.0, -1000.0, -275.0 },
    { -
405.02949.02422.0 }
};

new const 
Float:g_flAngles[ ][ ] = {
    { 
0.0270.00.0 },
    { 
0.0270.00.0 },
    { 
0.0270.00.0 }
};

new 
g_iMaxPlayers;
new 
g_iCounter33 ];
new 
bool:g_bNoKill33 ];
new 
Float:g_flLastTouch33 ];
new 
g_pCvarsCVARS ], g_iCvarsCVARS ];

public 
plugin_init( ) {
    
register_plugin"surf_ski_2: Rules Watcher""1.1""xPaw" );
    
    
register_cvar"ss2_rules_watcher""1.1"FCVAR_SERVER FCVAR_SPONLY );
    
    
g_iMaxPlayers get_maxplayers( );
    
    
g_pCvarsCV_JAIL_NOKILL ]      = register_cvar"rw_ss2_jail_nokill",      "0" );
    
g_pCvarsCV_JAIL_TIME ]        = register_cvar"rw_ss2_jail_time",        "1" );
    
    
g_pCvarsCV_GUNROOM_NOKILL ]   = register_cvar"rw_ss2_gunroom_nokill",   "1" );
    
g_pCvarsCV_GUNROOM_TIME ]     = register_cvar"rw_ss2_gunroom_time",     "15" );
    
    
g_pCvarsCV_MARIOROOM_NOKILL ] = register_cvar"rw_ss2_marioroom_nokill""1" );
    
g_pCvarsCV_MARIOROOM_TIME ]   = register_cvar"rw_ss2_marioroom_time",   "30" );
    
    new 
szMap12 ];
    
get_mapnameszMap11 );
    
    if( 
equaliszMap"surf_ski_2" ) ) {
        
CreateTriggerJAILFloat:{ -579.02983.0586.0 }, Float:{ -309.03288.0796.0 } );
        
CreateTriggerGUNROOMFloat:{ -713.0, -990.0, -157.0 }, Float:{ -295.0, -651.026.0 } );
        
CreateTriggerMARIOROOMFloat:{ 2735.0193.0, -2361.0 }, Float:{ 3654.01118.0, -2083.0 } );
        
        
register_touchg_szClassname"player""FwdTriggerTouch" );
        
RegisterHamHam_Spawn,        "player""FwdHamPlayerSpawn");
        
RegisterHamHam_TakeDamage,   "player""FwdHamTakeDamage" );
        
RegisterHamHam_TraceAttack,  "player""FwdHamTraceAttack" );
        
        
register_event"HLTV""EventNewRound""a""1=0""2=0" );
        
        
CacheCvars( );
    }
}

public 
EventNewRound( )
    
CacheCvars( );

public 
FwdHamPlayerSpawn( const id ) {
    if( 
is_user_aliveid ) ) {
        
g_bNoKillid ]     = false;
        
g_flLastTouchid ] = 0.0;
        
g_iCounterid ]    = 0;
    }
}

public 
FwdHamTraceAttack( const id, const iAttacker ) {
    if( 
IsPlayeriAttacker ) && g_bNoKillid ] && id != iAttacker ) {
        if( ( 
g_flLastTouchid ] + 0.1 ) >= get_gametime( ) )
            return 
HAM_SUPERCEDE;
        else
            
g_bNoKillid ] = false;
    }
    
    return 
HAM_IGNORED;
}

public 
FwdHamTakeDamage( const id, const iInflictor, const iAttacker ) {
    if( 
IsPlayeriAttacker ) && g_bNoKillid ] && id != iAttacker ) {
        if( ( 
g_flLastTouchid ] + 0.1 ) >= get_gametime( ) )
            return 
HAM_SUPERCEDE;
        else
            
g_bNoKillid ] = false;
    }
    
    return 
HAM_IGNORED;
}

public 
FwdTriggerTouch( const iEntity, const id ) {
    static 
Float:flGametime;
    
flGametime get_gametime( );
    
    if( 
flGametime > ( g_flLastTouchid ] + 1.2 ) ) {
        
g_iCounterid ] = 0;
        
g_flLastTouchid ] = flGametime;
    }
    else if( 
g_flLastTouchid ] < flGametime ) {
        
g_iCounterid ]++;
        
        static 
iTypebool:bNoKilliTime;
        
iType entity_get_intiEntityEV_INT_iuser1 );
        
        
GetCvarsiTypebNoKilliTime );
        
        
g_bNoKillid ] = bNoKill;
        
        if( 
iTime ) {
            if( 
g_iCounterid ] >= iTime ) {
                if( 
iTime >= ) {
                    
engclient_printidengprint_center"^nYou stood more than %i seconds in%s%s.^nYou have been thrown out."iTimeiType == MARIOROOM "^n" " "g_szZonesiType ] );
                    
                    
client_cmdid"spk buttons/blip1" );
                }
                
                
entity_set_vectoridEV_VEC_anglesg_flAnglesiType ] );
                
entity_set_intidEV_INT_fixangle);
                
entity_set_originidg_flOriginsiType ] );
            }
            
            if( 
g_iCounterid ] < ) {
                if( 
iTime >= )
                    
engclient_printidengprint_center"%sYou are in %s.%s^n^nYou have %i seconds to leave it!"bNoKill "" "^n"g_szZonesiType ], bNoKill "^nYou can't kill anyone here." ""iTime );
                else
                    
engclient_printidengprint_center"%sYou are in %s.%s"bNoKill "" "^n"g_szZonesiType ], bNoKill "^nYou can't kill anyone here." "" );
            }
        }
        
        
g_flLastTouchid ] = flGametime 1.0;
    }
}

GetCvars( const iType, &bool:bNoKill, &iTime ) {
    static 
CvarNoKillCvarTime;
    
    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_iCvarsCvarNoKill ] );
    
iTime g_iCvarsCvarTime ];
}

CacheCvars( ) {
    
g_iCvarsCV_JAIL_NOKILL ]      = get_pcvar_numg_pCvarsCV_JAIL_NOKILL ] );
    
g_iCvarsCV_JAIL_TIME ]        = get_pcvar_numg_pCvarsCV_JAIL_TIME ] );
    
    
g_iCvarsCV_GUNROOM_NOKILL ]   = get_pcvar_numg_pCvarsCV_GUNROOM_NOKILL ] );
    
g_iCvarsCV_GUNROOM_TIME ]     = get_pcvar_numg_pCvarsCV_GUNROOM_TIME ] );
    
    
g_iCvarsCV_MARIOROOM_NOKILL ] = get_pcvar_numg_pCvarsCV_MARIOROOM_NOKILL ] );
    
g_iCvarsCV_MARIOROOM_TIME ]   = get_pcvar_numg_pCvarsCV_MARIOROOM_TIME ] );
}

CreateTrigger( const iType, const Float:flMins], const Float:flMaxs] ) {
    new 
iEntity create_entity"info_target" );
    
    if( !
is_valid_entiEntity ) ) {
        
log_amx"There was an error with creating ^"%s^""g_szZonesiType ] );
        
        return 
0;
    }
    
    
entity_set_stringiEntityEV_SZ_classnameg_szClassname );
    
entity_set_intiEntityEV_INT_iuser1iType );
    
entity_set_intiEntityEV_INT_movetypeMOVETYPE_NONE );
    
entity_set_intiEntityEV_INT_solidSOLID_TRIGGER );
    
entity_set_sizeiEntityflMinsflMaxs );
    
    return 
iEntity;




All times are GMT -4. The time now is 20:37.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.