Advertisement
iXdoctor

Spawn Protection

Jun 9th, 2014
635
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.95 KB | None | 0 0
  1. /* Plugin generated by AMXX-Studio */
  2.  
  3. /*
  4.  
  5. Verison 1.0 : Plugin Builted
  6. Verison 1.1 : Added map check
  7. Verison 1.2 : Fixed some bugs
  8. Verison 1.3 : Fixed more bugs
  9. Verison 1.4 : All bugs have been fixed
  10.  
  11. */
  12.  
  13. #include < amxmodx >
  14. #include < cstrike >
  15. #include < hamsandwich >
  16. #include < fakemeta >
  17.  
  18.  
  19. enum _: iCvars
  20. {
  21.     szPrefix,
  22.     protectTime
  23. }
  24.  
  25. new pCvar[ iCvars ];
  26.  
  27. new szTimer, szProtect[ 33 ], iActive;
  28.  
  29. public plugin_init()
  30. {
  31.     register_plugin( "Spawn Protection ", "1.4", "Xdoctor" );
  32.    
  33.     RegisterHam( Ham_Spawn, "player", "HamClientSpawn" );
  34.    
  35.     RegisterHam( Ham_TakeDamage, "player", "HamTakeDamage" );
  36.    
  37.     pCvar[ szPrefix ] =         register_cvar( "spawn_prefix", "Spawn Protection" );
  38.  
  39.     pCvar[ protectTime ] =      register_cvar( "spawn_time", "10" );
  40.  
  41.     new map[ 32 ];
  42.    
  43.     get_mapname( map, 31 );
  44.    
  45.     if( contain( map, "surf_" ) != -1 )
  46.         iActive = true;
  47.        
  48.     else
  49.         iActive = false;
  50.        
  51. }
  52.  
  53. public client_disconnect( client )
  54.     return szProtect[ client ] = false;
  55.    
  56. public HamClientSpawn( client )
  57. {
  58.     if( is_user_connected( client ) && iActive )
  59.     {
  60.         szProtect[ client ] = true;
  61.            
  62.         szTimer = get_pcvar_num( pCvar[ protectTime ] );
  63.    
  64.         set_task( 1.0, "CmdTask", client, _,_, "b" );
  65.        
  66.         ColorChat( client, "^4%s^1 Your spawn ^4protection^1 has been started : ( ^4%i Seconds left^1 )^3 !", GetUserName( client ), szTimer );
  67.        
  68.     }
  69.    
  70.     return 1;
  71. }
  72.  
  73. public CmdTask( client )
  74. {
  75.     if( szTimer >= 1 )
  76.     {
  77.         set_hudmessage( 0, 85, 255, 0.28, 0.33, 0, 6.0, 1.0 )
  78.    
  79.         show_hudmessage( client, "You'r spawn protection will be expeird  in more : %i seconds !", szTimer );
  80.    
  81.         szTimer -= 1;
  82.     }
  83.    
  84.     else if( szTimer <= 0 )
  85.     {
  86.         szProtect[ client ] = false;
  87.        
  88.         remove_task( client );
  89.     }
  90. }
  91.  
  92.  
  93. public HamTakeDamage( client, inflictor, attacker, Float:damage, damagebits )
  94. {
  95.     if( !iActive )
  96.         return 1;
  97.        
  98.     if( szProtect[ client ] )
  99.     {
  100.         if( damagebits || DMG_FALL && szProtect[ client ] )
  101.             return HAM_SUPERCEDE;
  102.        
  103.     }
  104.    
  105.     return HAM_IGNORED;
  106. }
  107.    
  108. stock GetUserName( const Index )
  109. {
  110.     new szName[ 32 ];
  111.    
  112.     get_user_name( Index, szName, charsmax( szName ) );
  113.    
  114.     return szName;
  115. }
  116.  
  117. stock ColorChat(const id, const string[], {Float, Sql, Resul,_}:...)
  118.  {
  119.         new msg[ 191 ], players[ 32 ], count = 1, Prefix[ 32 ]
  120.         get_pcvar_string( pCvar[ szPrefix ], Prefix, charsmax( Prefix ) )
  121.        
  122.         static len
  123.         len = formatex(msg, charsmax(msg), "^1[ ^4%s^1 ] ", Prefix )
  124.         vformat(msg[len], charsmax(msg) - len, string, 3)
  125.        
  126.         if(id)    players[0] = id
  127.         else    get_players(players,count,"ch")
  128.        
  129.         for (new i = 0; i < count; i++)
  130.         {
  131.                 if(is_user_connected(players[i]))
  132.                 {
  133.                         message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"),_, players[i])
  134.                         write_byte(players[i])
  135.                         write_string(msg)
  136.                         message_end()
  137.                 }
  138.         }
  139. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement