Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Plugin generated by AMXX-Studio */
- /*
- Verison 1.0 : Plugin Builted
- Verison 1.1 : Added map check
- Verison 1.2 : Fixed some bugs
- Verison 1.3 : Fixed more bugs
- Verison 1.4 : All bugs have been fixed
- */
- #include < amxmodx >
- #include < cstrike >
- #include < hamsandwich >
- #include < fakemeta >
- enum _: iCvars
- {
- szPrefix,
- protectTime
- }
- new pCvar[ iCvars ];
- new szTimer, szProtect[ 33 ], iActive;
- public plugin_init()
- {
- register_plugin( "Spawn Protection ", "1.4", "Xdoctor" );
- RegisterHam( Ham_Spawn, "player", "HamClientSpawn" );
- RegisterHam( Ham_TakeDamage, "player", "HamTakeDamage" );
- pCvar[ szPrefix ] = register_cvar( "spawn_prefix", "Spawn Protection" );
- pCvar[ protectTime ] = register_cvar( "spawn_time", "10" );
- new map[ 32 ];
- get_mapname( map, 31 );
- if( contain( map, "surf_" ) != -1 )
- iActive = true;
- else
- iActive = false;
- }
- public client_disconnect( client )
- return szProtect[ client ] = false;
- public HamClientSpawn( client )
- {
- if( is_user_connected( client ) && iActive )
- {
- szProtect[ client ] = true;
- szTimer = get_pcvar_num( pCvar[ protectTime ] );
- set_task( 1.0, "CmdTask", client, _,_, "b" );
- ColorChat( client, "^4%s^1 Your spawn ^4protection^1 has been started : ( ^4%i Seconds left^1 )^3 !", GetUserName( client ), szTimer );
- }
- return 1;
- }
- public CmdTask( client )
- {
- if( szTimer >= 1 )
- {
- set_hudmessage( 0, 85, 255, 0.28, 0.33, 0, 6.0, 1.0 )
- show_hudmessage( client, "You'r spawn protection will be expeird in more : %i seconds !", szTimer );
- szTimer -= 1;
- }
- else if( szTimer <= 0 )
- {
- szProtect[ client ] = false;
- remove_task( client );
- }
- }
- public HamTakeDamage( client, inflictor, attacker, Float:damage, damagebits )
- {
- if( !iActive )
- return 1;
- if( szProtect[ client ] )
- {
- if( damagebits || DMG_FALL && szProtect[ client ] )
- return HAM_SUPERCEDE;
- }
- return HAM_IGNORED;
- }
- stock GetUserName( const Index )
- {
- new szName[ 32 ];
- get_user_name( Index, szName, charsmax( szName ) );
- return szName;
- }
- stock ColorChat(const id, const string[], {Float, Sql, Resul,_}:...)
- {
- new msg[ 191 ], players[ 32 ], count = 1, Prefix[ 32 ]
- get_pcvar_string( pCvar[ szPrefix ], Prefix, charsmax( Prefix ) )
- static len
- len = formatex(msg, charsmax(msg), "^1[ ^4%s^1 ] ", Prefix )
- vformat(msg[len], charsmax(msg) - len, string, 3)
- if(id) players[0] = id
- else get_players(players,count,"ch")
- for (new i = 0; i < count; i++)
- {
- if(is_user_connected(players[i]))
- {
- message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"),_, players[i])
- write_byte(players[i])
- write_string(msg)
- message_end()
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement