P1xeL

Box & C4

Jul 3rd, 2012
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.72 KB | None | 0 0
  1. #include < amxmodx >
  2. #include < amxmisc >
  3. #include < fakemeta >
  4. #include < hamsandwich >
  5.  
  6. #pragma semicolon 1
  7.  
  8. #define fm_create_entity(%1) engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, %1))
  9. #define fm_find_ent_by_class(%1,%2) engfunc(EngFunc_FindEntityByString, %1, "classname", %2)
  10.  
  11. enum _:Teams
  12. {
  13.     FM_TEAM_UNASSIGNED,
  14.     FM_TEAM_T,
  15.     FM_TEAM_CT,
  16.     FM_TEAM_SPECTATOR
  17. };
  18.  
  19. new const c4cmds[][] =
  20. {
  21.     "c4",
  22.     "buyc4",
  23.     "buy_c4",
  24.     "bomb"
  25. };
  26.  
  27. public plugin_init() {
  28.     register_plugin( "Deluxe JailBreak - Addons", "0.0.1", "CreePs" );
  29.    
  30.     for( new i; i < sizeof c4cmds; i++ )
  31.         register_saycmd( c4cmds[ i ], "cmdC4", 0, "- give c4 for alive ct's" );
  32.    
  33.     register_saycmd( "box", "cmdBox", 0, "- starting box" );
  34. }
  35.  
  36.  
  37.  
  38. public cmdC4( client )
  39. {
  40.     if( ! is_user_can( client ) )
  41.         return;
  42.        
  43.     if( user_has_weapon( client, CSW_C4 ) )
  44.     {
  45.         ColorChat( client, "You already have c4!" );
  46.         return;
  47.     }
  48.    
  49.     fm_give_item( client, "weapon_c4" );
  50.    
  51.     return;
  52. }
  53.  
  54. public cmdBox( client )
  55. {
  56.     if( ! is_user_can( client ) )
  57.         return;
  58.        
  59.     new name[ 32 ];
  60.     new ff = get_cvar_num( "mp_friendlyfire" );
  61.    
  62.     get_user_name( client, name, sizeof( name ) - 1 );
  63.        
  64.     set_cvar_num( "mp_friendlyfire", !ff );
  65.    
  66.     if( ! ff )
  67.         for( new i = 1; i <= get_maxplayers(); i++ )
  68.             if( is_user_alive( i ) )
  69.                 if( get_user_team( i ) == 1 )
  70.                     fm_set_user_health( i, 100 );
  71.                    
  72.     ColorChat( 0, "Guard:^4 %s^1 has turn^3 %s^1 the frendlyfire.", name, ff ? "Off" : "On" );
  73.    
  74.     return;
  75. }
  76.  
  77. bool:is_user_can( client )
  78. {
  79.     if( fm_get_user_team( client ) != FM_TEAM_CT )
  80.     {
  81.         ColorChat( client, "This command is only for ct's!" );
  82.         return false;
  83.     }
  84.    
  85.     if( ! is_user_alive( client ) )
  86.     {
  87.         ColorChat( client, "You need to be alive!" );
  88.         return false;
  89.     }
  90.    
  91.     return true;
  92. }
  93.        
  94. register_saycmd( saycommand[], function[], flags, info[] )
  95. {
  96.     new temp[ 64 ];
  97.     format( temp, 63, "say /%s", saycommand );
  98.     register_clcmd( temp, function, flags, info );
  99.     format( temp, 63, "say .%s", saycommand );
  100.     register_clcmd( temp, function, flags, info );
  101.     format( temp, 63, "say_team /%s", saycommand );
  102.     register_clcmd( temp, function, flags, info );
  103.     format( temp, 63, "say_team .%s", saycommand );
  104.     register_clcmd( temp, function, flags, info );
  105. }
  106.  
  107. stock fm_set_user_health(index, health) {
  108.     health > 0 ? set_pev(index, pev_health, float(health)) : dllfunc(DLLFunc_ClientKill, index);
  109.  
  110.     return 1;
  111. }
  112.  
  113. stock fm_give_item( client, const item[] )
  114. {
  115.     if ( !equal( item, "weapon_", 7 ) && !equal( item, "ammo_", 5 )
  116.     && !equal( item, "item_", 5 ) && !equal( item, "tf_weapon_", 10 ) )
  117.         return 0;
  118.  
  119.     new ent = fm_create_entity( item );
  120.    
  121.     if ( !pev_valid( ent ) )
  122.         return 0;
  123.  
  124.     new Float:origin[3];
  125.    
  126.     pev( client, pev_origin, origin );
  127.    
  128.     set_pev( ent, pev_origin, origin );
  129.     set_pev( ent, pev_spawnflags, pev( ent, pev_spawnflags ) | SF_NORESPAWN );
  130.    
  131.     dllfunc( DLLFunc_Spawn, ent );
  132.  
  133.     new save = pev( ent, pev_solid );
  134.    
  135.     dllfunc( DLLFunc_Touch, ent, client );
  136.    
  137.     if ( pev( ent, pev_solid ) != save )
  138.         return ent;
  139.  
  140.     engfunc( EngFunc_RemoveEntity, ent );
  141.  
  142.     return -1;
  143. }
  144.  
  145. stock fm_get_user_team( client )
  146. {
  147.     return get_pdata_int( client, 114 );
  148. }
  149.  
  150. stock ColorChat(const id, const string[], {Float, Sql, Resul,_}:...) {
  151.     new msg[191], players[32], count = 1;
  152.    
  153.     static len;
  154.     len = formatex(msg, charsmax(msg), "^x01[^x04 Deluxe JailBreak^x01 ] ");
  155.     vformat(msg[len], charsmax(msg) - len, string, 3);
  156.    
  157.     if(id)
  158.         players[0] = id;
  159.     else
  160.         get_players(players,count,"ch");
  161.    
  162.     for (new i = 0; i < count; i++)
  163.     {
  164.         if(is_user_connected(players[i]))
  165.         {
  166.             message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"),_, players[i]);
  167.             write_byte(players[i]);
  168.             write_string(msg);
  169.             message_end();
  170.         }
  171.     }
  172. }
Advertisement
Add Comment
Please, Sign In to add comment