hlmod.hu

Magyar Half-Life Mód közösség!
Pontos idő: 2024.03.28. 21:12



Jelenlévő felhasználók

Jelenleg 201 felhasználó van jelen :: 0 regisztrált, 0 rejtett és 201 vendég

A legtöbb felhasználó (1565 fő) 2020.11.21. 11:26-kor tartózkodott itt.

Regisztrált felhasználók: nincs regisztrált felhasználó az elmúlt 5 percben aktív felhasználók alapján

Utoljára aktív
Ahhoz hogy lásd ki volt utoljára aktív, be kell jelentkezned.



Az oldal teljeskörű
használatához regisztrálj.

Regisztráció

Kereső


Új téma nyitása  Hozzászólás a témához  [ 7 hozzászólás ] 
Szerző Üzenet
 Hozzászólás témája: BombSite Lock Version 0.4 hiba
HozzászólásElküldve: 2019.12.31. 15:10 
Offline
Fanatikus

Csatlakozott: 2019.12.06. 20:00
Hozzászólások: 158
Megköszönt másnak: 13 alkalommal
Üdv,

esetleg valaki javítaná nekem a hibát ?

bombsite_lock.sma(201) : error 017: undefined symbol "get_cvarptr_num"
bombsite_lock.sma(202) : error 017: undefined symbol "get_cvarptr_num"
bombsite_lock.sma(221) : error 017: undefined symbol "get_cvarptr_string"
bombsite_lock.sma(221) : error 088: number of arguments does not match definition
bombsite_lock.sma(147) : warning 204: symbol is assigned a value that is never used: "g_pCVarAllowPlantNum"
bombsite_lock.sma(149) : warning 204: symbol is assigned a value that is never used: "g_pCVarLockSite"
bombsite_lock.sma(148) : warning 204: symbol is assigned a value that is never used: "g_pCVarLockSiteNum"

  1. /*
  2.  *    BombSite Lock
  3.  *    Version: 0.4
  4.  *    Author: Bugsy
  5.  *
  6.  *
  7.  * Description
  8.  *
  9.  *    This plugin allows you to lock bombsite(s), preventing them from being used.
  10.  *    When a bombsite is locked, the player currently holding the bomb will have a HUD message indicating which bombsite(s) are locked.
  11.  *    Bombsite locks will remain from round to round but not between map changes.
  12.  *    There are cvars to control if and how bombsites are automatically locked depending on the number of CT players on the server.
  13.  *
  14.  *
  15.  * Commands
  16.  *
  17.  *    amx_setbombsite <A|B> <0|1> - unlocks/locks the specified bombsite
  18.  *    amx_bombsitemenu - displays bomb site lock menu
  19.  *
  20.  *
  21.  * CVars
  22.  *
  23.  *    bl_allowplantctnum - Minimum number of CT players required to allow bomb planting (both sites would be locked if less).
  24.  *        Default: 0 (0=disabled or any number as # CT of players)
  25.  *    bl_locksitectnum - Minimum number of CT players required to have both bombsites open for planting. If there are less CT players, one of the bombsites (defined by cvar bl_locksite) will be locked.
  26.  *        Default: 2 (0=disabled or any number as # CT of players)
  27.  *    bl_locksite - The bombsite that will be locked if the number of CT players is less than bl_locksitectnum value.
  28.  *        Default: b (Must be a or b)
  29.  *
  30.  *
  31.  * Modules
  32.  *
  33.  *    VexdUM
  34.  *
  35.  *
  36.  * ChangeLog
  37.  *
  38.  *    0.4
  39.  *        Fixed support for all maps, but not for more than two bombsites (supports now the "info_bomb_target" entities).
  40.  *        Plugin will be unitialized if there are not two bombsites found at least.
  41.  *    0.3
  42.  *        Added support for all maps (experimental).
  43.  *        Bombsites on all of the standard CS maps with an A and B designation should all work properly according to A and B naming.
  44.  *        Maps without an A and B designation will still be treated as A and B by the plugin; A and B is chosen by
  45.  *        the plugin based on which bombsite entity is spawned first.
  46.  *        If you notice a map where A and B are handled by the plugin oppositely, let me know and I can correct it.
  47.  *        Menu will now display only the available commands for use. ie, if A is already locked, "Lock A" menu item will be disabled etc.
  48.  *        Fixed bug which affected the HUD being displayed to the user holding the bomb.
  49.  *        Added cvars to control auto-locking of bombsites. See above.
  50.  *    0.2
  51.  *        Initial release
  52.  *
  53.  */
  54.  
  55. /******************************************************************************/
  56. // If you change one of the following settings, do not forget to recompile
  57. // the plugin and to install the new .amx file on your server.
  58. // You can find the list of admin flags in the amx/examples/include/amxconst.inc file.
  59.  
  60. #define FLAG_AMX_SETBOMBSITE  ADMIN_CVAR
  61. #define FLAG_AMX_BOMBSITEMENU ADMIN_CVAR
  62.  
  63. /******************************************************************************/
  64.  
  65. #include <translator>
  66. #include <amxmod>
  67. #include <amxmisc>
  68. #include <VexdUM>
  69.  
  70. enum BombSites
  71. {
  72.     BOMBSITE_A,
  73.     BOMBSITE_B
  74. }
  75.  
  76. new g_iBombSiteEntity[ BombSites ];
  77. new bool:g_bBombSiteStatus[ BombSites ];
  78. new bool:g_bIsBombSiteInfo[ BombSites ];
  79. new Float:g_flBombSiteInfoOrigins[ BombSites ][3];
  80. new g_iPlayerWithBomb;
  81. new bool:g_bPlayerHoldingBomb;
  82.  
  83. new g_iHUDEntity;
  84.  
  85. new g_pCVarAllowPlantNum;
  86. new g_pCVarLockSiteNum;
  87. new g_pCVarLockSite;
  88.  
  89. public plugin_init( )
  90. {
  91.     load_translations( "bombsite_lock" );
  92.     register_plugin( _T( "BombSite Lock" ) , "0.4" , "Bugsy" );
  93.    
  94.     new szMap[ 11 ] , BombSites:bsBombSiteA , BombSites:bsBombSiteB;
  95.     get_mapname( szMap , charsmax( szMap ) );
  96.    
  97.     if ( equal( szMap , "de_chateau" ) || equal( szMap , "de_dust2" , 8 ) || equal( szMap , "de_train" ) )
  98.     {
  99.         bsBombSiteA = BOMBSITE_B;
  100.         bsBombSiteB = BOMBSITE_A;
  101.     }
  102.     else
  103.     {
  104.         bsBombSiteA = BOMBSITE_A;
  105.         bsBombSiteB = BOMBSITE_B;  
  106.     }
  107.    
  108.     g_iBombSiteEntity[ bsBombSiteA ] = find_entity( -1 , "func_bomb_target" );
  109.    
  110.     if ( g_iBombSiteEntity[ bsBombSiteA ] <= 0 )
  111.     {
  112.         g_iBombSiteEntity[ bsBombSiteA ] = find_entity( -1 , "info_bomb_target" );
  113.        
  114.         if ( g_iBombSiteEntity[ bsBombSiteA ] > 0 )
  115.         {
  116.             g_bIsBombSiteInfo[ bsBombSiteA ] = true;
  117.             entity_get_vector( g_iBombSiteEntity[ bsBombSiteA ] , EV_VEC_origin , g_flBombSiteInfoOrigins[ bsBombSiteA ] );
  118.         }
  119.     }
  120.    
  121.     g_iBombSiteEntity[ bsBombSiteB ] = find_entity( g_iBombSiteEntity[ bsBombSiteA ] , "func_bomb_target" );
  122.    
  123.     if ( g_iBombSiteEntity[ bsBombSiteB ] <= 0 )
  124.     {
  125.         g_iBombSiteEntity[ bsBombSiteB ] = find_entity( g_iBombSiteEntity[ bsBombSiteA ] , "info_bomb_target" );
  126.        
  127.         if ( g_iBombSiteEntity[ bsBombSiteB ] > 0 )
  128.         {
  129.             g_bIsBombSiteInfo[ bsBombSiteB ] = true;
  130.             entity_get_vector( g_iBombSiteEntity[ bsBombSiteB ] , EV_VEC_origin , g_flBombSiteInfoOrigins[ bsBombSiteB ] );
  131.         }
  132.     }
  133.    
  134.     if ( g_iBombSiteEntity[ BOMBSITE_A ] <= 0 || g_iBombSiteEntity[ BOMBSITE_B ] <= 0 )
  135.     {
  136.         server_print( _T( "* BombSite Lock: Map ^"%s^" is not supported. Plugin uninitialized." ) , szMap );
  137.         return;
  138.     }
  139.    
  140.     register_concmd( "amx_setbombsite" , "SetBombSiteConsole" , FLAG_AMX_SETBOMBSITE , _T( "<A|B> <0|1> - unlocks/locks the specified bombsite" ) );
  141.     register_concmd( "amx_bombsitemenu" , "ShowBombSiteMenu" , FLAG_AMX_BOMBSITEMENU , _T( "- displays bomb site lock menu" ) );
  142.    
  143.     g_pCVarAllowPlantNum = register_cvar( "bl_allowplantctnum" , "0" );
  144.     g_pCVarLockSiteNum = register_cvar( "bl_locksitectnum" , "2" );
  145.     g_pCVarLockSite = register_cvar( "bl_locksite" , "b" );
  146.    
  147.     register_event( "CurWeapon" , "fw_EvCurWeapon" , "b" , "1=1" );
  148.     register_event( "WeapPickup", "fw_EvWeapPickup" , "be" , "1=6" );
  149.     register_event( "BombDrop" ,  "fw_EvBombDrop" , "bc" );
  150.    
  151.     register_logevent( "fw_EvRoundStart" , 2 , "1=Round_Start" );
  152.    
  153.     register_menucmd( register_menuid( "\yBombSite Lock Menu" ) , (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<9) , "CommandBombSiteMenu" );
  154.    
  155.     g_iHUDEntity = create_entity( "info_target" );
  156.     entity_set_string( g_iHUDEntity , EV_SZ_classname , "bl_hud_entity" );
  157. }
  158.  
  159. public client_disconnect( id )
  160. {
  161.     if ( g_iPlayerWithBomb == id )
  162.     {
  163.         g_iPlayerWithBomb = 0;
  164.         g_bPlayerHoldingBomb = false;
  165.     }
  166. }
  167.  
  168. public fw_EvCurWeapon( id )
  169. {
  170.     if ( id == g_iPlayerWithBomb )
  171.     {
  172.         if ( read_data( 2 ) == CSW_C4 )
  173.         {
  174.             g_bPlayerHoldingBomb = true;
  175.             entity_set_float( g_iHUDEntity , EV_FL_nextthink , get_gametime() + 1.0 );
  176.         }
  177.         else
  178.         {
  179.             g_bPlayerHoldingBomb = false;
  180.         }
  181.     }
  182. }
  183.  
  184. public fw_EvWeapPickup( id )
  185. {
  186.     g_iPlayerWithBomb = id;
  187. }
  188.  
  189. public fw_EvBombDrop()
  190. {
  191.     g_iPlayerWithBomb = 0;
  192.     g_bPlayerHoldingBomb = false;
  193. }
  194.  
  195. public fw_EvRoundStart()
  196. {
  197.     new iAllowPlantNum = get_cvarptr_num( g_pCVarAllowPlantNum );
  198.     new iLockSiteNum = get_cvarptr_num( g_pCVarLockSiteNum );      
  199.     new iPlayers[ 32 ] , iNum , iCTCount;
  200.    
  201.     get_players( iPlayers , iNum , "h" );
  202.    
  203.     for ( new i = 0 ; i < iNum ; i++ )
  204.         if ( get_user_team( iPlayers[ i ] ) == 2 )
  205.             iCTCount++;
  206.    
  207.     if ( iCTCount < iAllowPlantNum )
  208.     {
  209.         SetBombSiteLock( BOMBSITE_A , true );
  210.         SetBombSiteLock( BOMBSITE_B , true );
  211.        
  212.         client_print( 0 , print_chat , _T( "* BombSites A & B are both locked since there are less than %d CTs." ) , iAllowPlantNum );
  213.     }
  214.     else if ( iCTCount < iLockSiteNum )
  215.     {
  216.         new szSite[ 2 ];
  217.         get_cvarptr_string( g_pCVarLockSite , szSite , charsmax( szSite ) );
  218.         szSite[ 0 ] = toupper( szSite[ 0 ] );
  219.        
  220.         if ( !( 'A' <= szSite[ 0 ] <= 'B' ) )
  221.             return;
  222.            
  223.         SetBombSiteLock( ( szSite[ 0 ] == 'A' ) ? BOMBSITE_A : BOMBSITE_B , true );    
  224.         SetBombSiteLock( ( szSite[ 0 ] == 'A' ) ? BOMBSITE_B : BOMBSITE_A , false );           
  225.        
  226.         client_print( 0 , print_chat , _T( "* BombSite %s has been locked since there are less than %d CTs." ) , szSite , iLockSiteNum );  
  227.     }
  228.     else
  229.     {
  230.         SetBombSiteLock( BOMBSITE_A , false );
  231.         SetBombSiteLock( BOMBSITE_B , false );
  232.     }
  233. }
  234.  
  235. public SetBombSiteConsole( id , AdminLevel , CommandId )
  236. {
  237.     if ( !cmd_access( id , AdminLevel , CommandId , 3 ) )
  238.     {
  239.         return PLUGIN_HANDLED;
  240.     }
  241.    
  242.     /*if ( g_iBombSiteEntity[ BOMBSITE_A ] <= 0 || g_iBombSiteEntity[ BOMBSITE_B ] <= 0 )
  243.     {
  244.         console_print( id , _T( "* BombSite Lock: Sorry, this map is not supported." ) );
  245.         return PLUGIN_HANDLED;
  246.     }*/
  247.    
  248.     new szSite[ 3 ] , szState[ 3 ] , iState , BombSites:bsSite;
  249.     read_argv( 1 , szSite , charsmax( szSite ) );
  250.     read_argv( 2 , szState , charsmax( szState ) );
  251.    
  252.     iState = str_to_num( szState );
  253.    
  254.     if ( strlen( szSite ) > 1 || !is_str_num( szState ) || !( 0 <= iState <= 1 ) )
  255.         szSite[ 0 ] = 'X';
  256.     else
  257.         szSite[ 0 ] = toupper( szSite[ 0 ] );
  258.    
  259.     switch ( szSite[ 0 ] )
  260.     {
  261.         case 'A':
  262.         {
  263.             bsSite = BOMBSITE_A;
  264.         }
  265.         case 'B':
  266.         {
  267.             bsSite = BOMBSITE_B;
  268.         }
  269.         default:
  270.         {
  271.             console_print( id , _T( "Usage: amx_setbombsite <A|B> <0|1> - unlocks/locks the specified bombsite" ) );
  272.             return PLUGIN_HANDLED;
  273.         }
  274.     }
  275.    
  276.     SetBombSiteLock( bsSite , bool:iState );
  277.    
  278.     console_print( id , _T( "* BombSite %s has been %s." ) , szSite , iState ? _T( "locked" ) : _T( "unlocked" ) );
  279.    
  280.     set_hudmessage( 255 , 165 , 000 , -1.0 , 0.65 , 0 , 3.0 , 3.0 , .channel = -1 );
  281.     show_hudmessage( 0 , _T( "BombSite %s has been %s..." ) , szSite , iState ? _T( "locked" ) : _T( "unlocked" ) );
  282.    
  283.     return PLUGIN_HANDLED;
  284. }
  285.  
  286. public ShowBombSiteMenu( id , AdminLevel )
  287. {
  288.     if ( !access( id , AdminLevel ) )
  289.     {
  290.         console_print( id , _T( "You have no access to that command." ) );
  291.         return PLUGIN_HANDLED;
  292.     }
  293.    
  294.     /*if ( g_iBombSiteEntity[ BOMBSITE_A ] <= 0 || g_iBombSiteEntity[ BOMBSITE_B ] <= 0 )
  295.     {
  296.         console_print( id , _T( "* BombSite Lock: Sorry, this map is not supported." ) );
  297.         return PLUGIN_HANDLED;
  298.     }*/
  299.    
  300.     DisplayBombSiteMenu( id );
  301.    
  302.     return PLUGIN_HANDLED;
  303. }
  304.  
  305. DisplayBombSiteMenu( id )
  306. {
  307.     new szMenu[ 256 ] , iKeys = (1<<9);
  308.     new iLen = copy( szMenu , charsmax( szMenu ) , _T( "\yBombSite Lock Menu\w" , id ) );
  309.    
  310.     if ( g_bBombSiteStatus[ BOMBSITE_A ] )
  311.         iLen += copy( szMenu[ iLen ] , charsmax( szMenu ) - iLen , _T( "^n^n\d1. Lock A" , id ) );
  312.     else
  313.     {
  314.         iLen += copy( szMenu[ iLen ] , charsmax( szMenu ) - iLen , _T( "^n^n\w1. Lock A" , id ) );
  315.         iKeys |= (1<<0);
  316.     }
  317.    
  318.     if ( g_bBombSiteStatus[ BOMBSITE_B ] )
  319.         iLen += copy( szMenu[ iLen ] , charsmax( szMenu ) - iLen , _T( "^n\d2. Lock B" , id ) );
  320.     else
  321.     {
  322.         iLen += copy( szMenu[ iLen ] , charsmax( szMenu ) - iLen , _T( "^n\w2. Lock B" , id ) );
  323.         iKeys |= (1<<1);
  324.     }
  325.    
  326.     if ( g_bBombSiteStatus[ BOMBSITE_A ] )
  327.     {
  328.         iLen += copy( szMenu[ iLen ] , charsmax( szMenu ) - iLen , _T( "^n\w3. Unlock A" , id ) );
  329.         iKeys |= (1<<2);
  330.     }
  331.     else
  332.         iLen += copy( szMenu[ iLen ] , charsmax( szMenu ) - iLen , _T( "^n\d3. Unlock A" , id ) );
  333.    
  334.     if ( g_bBombSiteStatus[ BOMBSITE_B ] )
  335.     {
  336.         iLen += copy( szMenu[ iLen ] , charsmax( szMenu ) - iLen , _T( "^n\w4. Unlock B" , id ) );
  337.         iKeys |= (1<<3);
  338.     }
  339.     else
  340.         iLen += copy( szMenu[ iLen ] , charsmax( szMenu ) - iLen , _T( "^n\d4. Unlock B" , id ) );
  341.    
  342.     if ( g_bBombSiteStatus[ BOMBSITE_A ] && g_bBombSiteStatus[ BOMBSITE_B ] )
  343.         iLen += copy( szMenu[ iLen ] , charsmax( szMenu ) - iLen , _T( "^n\d5. Lock A & B" , id ) );
  344.     else
  345.     {
  346.         iLen += copy( szMenu[ iLen ] , charsmax( szMenu ) - iLen , _T( "^n\w5. Lock A & B" , id ) );
  347.         iKeys |= (1<<4);
  348.     }
  349.    
  350.     if (g_bBombSiteStatus[ BOMBSITE_A ] || g_bBombSiteStatus[ BOMBSITE_B ] )
  351.     {
  352.         iLen += copy( szMenu[ iLen ] , charsmax( szMenu ) - iLen , _T( "^n\w6. Unlock A & B" , id ) );
  353.         iKeys |= (1<<5);
  354.     }
  355.     else
  356.         iLen += copy( szMenu[ iLen ] , charsmax( szMenu ) - iLen , _T( "^n\d6. Unlock A & B" , id ) );
  357.    
  358.     iLen += copy( szMenu[ iLen ] , charsmax( szMenu ) - iLen , _T( "^n^n\w0. Exit" , id ) );
  359.    
  360.     show_menu( id , iKeys , szMenu , _ , "\yBombSite Lock Menu" );
  361. }
  362.  
  363. public CommandBombSiteMenu( id , iKey )
  364. {
  365.     set_hudmessage( 255 , 165 , 000 , -1.0 , 0.65 , 0 , 3.0 , 3.0 , .channel = -1 );
  366.    
  367.     switch ( iKey )
  368.     {
  369.         case 0:
  370.         {
  371.             SetBombSiteLock( BOMBSITE_A , true );
  372.             show_hudmessage( 0 , _T( "BombSite A has been locked..." ) );
  373.         }
  374.         case 1:
  375.         {
  376.             SetBombSiteLock( BOMBSITE_B , true );
  377.             show_hudmessage( 0 , _T( "BombSite B has been locked..." ) );
  378.         }
  379.         case 2:
  380.         {
  381.             SetBombSiteLock( BOMBSITE_A , false );
  382.             show_hudmessage( 0 , _T( "BombSite A has been unlocked..." ) );
  383.         }
  384.         case 3:
  385.         {
  386.             SetBombSiteLock( BOMBSITE_B , false );
  387.             show_hudmessage( 0 , _T( "BombSite B has been unlocked..." ) );
  388.         }
  389.         case 4:
  390.         {
  391.             SetBombSiteLock( BOMBSITE_A , true );
  392.             SetBombSiteLock( BOMBSITE_B , true );
  393.             show_hudmessage( 0 , _T( "BombSites A & B have both been locked..." ) );
  394.         }
  395.         case 5:
  396.         {
  397.             SetBombSiteLock( BOMBSITE_A , false );
  398.             SetBombSiteLock( BOMBSITE_B , false );
  399.             show_hudmessage( 0 , _T( "BombSites A & B have both been unlocked..." ) );
  400.         }
  401.     }
  402.    
  403.     if( 0 <= iKey <= 5 )
  404.         DisplayBombSiteMenu( id );
  405. }
  406.  
  407. public entity_think( iEntity )
  408. {
  409.     if ( iEntity == g_iHUDEntity )
  410.     {
  411.         if( g_bPlayerHoldingBomb &&
  412.         ( g_bBombSiteStatus[ BOMBSITE_A ] || g_bBombSiteStatus[ BOMBSITE_B ] ) && is_user_alive( g_iPlayerWithBomb ) )
  413.         {
  414.             set_hudmessage( 255 , 165 , 000 , -1.0 , 0.87 , 0 , 1.0 , 1.0 , .channel = -1 );
  415.             show_hudmessage( g_iPlayerWithBomb , _T( "BombSite%s %s%s%s %s currently locked!" ) ,
  416.                 g_bBombSiteStatus[ BOMBSITE_A ] && g_bBombSiteStatus[ BOMBSITE_B ] ? "s" : ""  ,
  417.                 g_bBombSiteStatus[ BOMBSITE_A ] ? "A" : "" ,
  418.                 g_bBombSiteStatus[ BOMBSITE_A ] && g_bBombSiteStatus[ BOMBSITE_B ] ? " & " : "" ,
  419.                 g_bBombSiteStatus[ BOMBSITE_B ] ? "B" : "" ,
  420.                 g_bBombSiteStatus[ BOMBSITE_A ] && g_bBombSiteStatus[ BOMBSITE_B ] ? _T( "are" ) : _T( "is" ) );
  421.            
  422.             entity_set_float( g_iHUDEntity , EV_FL_nextthink , ( get_gametime() + 1.0 ) );
  423.         }
  424.     }
  425. }
  426.  
  427. SetBombSiteLock( BombSites:bsBombSite , bool:bLockState )  
  428. {
  429.     if ( g_bIsBombSiteInfo[ bsBombSite ] )
  430.     {
  431.         if( bLockState )
  432.             entity_set_origin( g_iBombSiteEntity[ bsBombSite ] , Float:{99999.0, 99999.0, 99999.0} );
  433.         else
  434.             entity_set_origin( g_iBombSiteEntity[ bsBombSite ] , g_flBombSiteInfoOrigins[ bsBombSite ] );
  435.     }
  436.     else
  437.     {
  438.         entity_set_int( g_iBombSiteEntity[ bsBombSite ] , EV_INT_solid , bLockState ? SOLID_NOT : SOLID_TRIGGER );
  439.     }
  440.    
  441.     g_bBombSiteStatus[ bsBombSite ] = bLockState;
  442.    
  443.     if ( bLockState )
  444.         entity_set_float( g_iHUDEntity , EV_FL_nextthink , ( get_gametime() + 1.0 ) );
  445. }


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: BombSite Lock Version 0.4 hiba
HozzászólásElküldve: 2019.12.31. 16:23 
Offline
Őstag
Avatar

Csatlakozott: 2015.07.27. 22:56
Hozzászólások: 1367
Megköszönt másnak: 28 alkalommal
Megköszönték neki: 351 alkalommal
Kód:
#include <amxmod>



Ez még nem AMXX, csak AMX.


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: BombSite Lock Version 0.4 hiba
HozzászólásElküldve: 2019.12.31. 16:55 
Offline
Fanatikus

Csatlakozott: 2019.12.06. 20:00
Hozzászólások: 158
Megköszönt másnak: 13 alkalommal
regener írta:
Kód:
#include <amxmod>



Ez még nem AMXX, csak AMX.



bombsite_lock.sma(201) : error 017: undefined symbol "get_cvarptr_num"
bombsite_lock.sma(202) : error 017: undefined symbol "get_cvarptr_num"
bombsite_lock.sma(221) : error 017: undefined symbol "get_cvarptr_string"
bombsite_lock.sma(221) : error 088: number of arguments does not match definition
bombsite_lock.sma(147) : warning 204: symbol is assigned a value that is never used: "g_pCVarAllowPlantNum"
bombsite_lock.sma(149) : warning 204: symbol is assigned a value that is never used: "g_pCVarLockSite"
bombsite_lock.sma(148) : warning 204: symbol is assigned a value that is never used: "g_pCVarLockSiteNum"

  1. /*
  2.  *    BombSite Lock
  3.  *    Version: 0.4
  4.  *    Author: Bugsy
  5.  *
  6.  *
  7.  * Description
  8.  *
  9.  *    This plugin allows you to lock bombsite(s), preventing them from being used.
  10.  *    When a bombsite is locked, the player currently holding the bomb will have a HUD message indicating which bombsite(s) are locked.
  11.  *    Bombsite locks will remain from round to round but not between map changes.
  12.  *    There are cvars to control if and how bombsites are automatically locked depending on the number of CT players on the server.
  13.  *
  14.  *
  15.  * Commands
  16.  *
  17.  *    amx_setbombsite <A|B> <0|1> - unlocks/locks the specified bombsite
  18.  *    amx_bombsitemenu - displays bomb site lock menu
  19.  *
  20.  *
  21.  * CVars
  22.  *
  23.  *    bl_allowplantctnum - Minimum number of CT players required to allow bomb planting (both sites would be locked if less).
  24.  *        Default: 0 (0=disabled or any number as # CT of players)
  25.  *    bl_locksitectnum - Minimum number of CT players required to have both bombsites open for planting. If there are less CT players, one of the bombsites (defined by cvar bl_locksite) will be locked.
  26.  *        Default: 2 (0=disabled or any number as # CT of players)
  27.  *    bl_locksite - The bombsite that will be locked if the number of CT players is less than bl_locksitectnum value.
  28.  *        Default: b (Must be a or b)
  29.  *
  30.  *
  31.  * Modules
  32.  *
  33.  *    VexdUM
  34.  *
  35.  *
  36.  * ChangeLog
  37.  *
  38.  *    0.4
  39.  *        Fixed support for all maps, but not for more than two bombsites (supports now the "info_bomb_target" entities).
  40.  *        Plugin will be unitialized if there are not two bombsites found at least.
  41.  *    0.3
  42.  *        Added support for all maps (experimental).
  43.  *        Bombsites on all of the standard CS maps with an A and B designation should all work properly according to A and B naming.
  44.  *        Maps without an A and B designation will still be treated as A and B by the plugin; A and B is chosen by
  45.  *        the plugin based on which bombsite entity is spawned first.
  46.  *        If you notice a map where A and B are handled by the plugin oppositely, let me know and I can correct it.
  47.  *        Menu will now display only the available commands for use. ie, if A is already locked, "Lock A" menu item will be disabled etc.
  48.  *        Fixed bug which affected the HUD being displayed to the user holding the bomb.
  49.  *        Added cvars to control auto-locking of bombsites. See above.
  50.  *    0.2
  51.  *        Initial release
  52.  *
  53.  */
  54.  
  55. /******************************************************************************/
  56. // If you change one of the following settings, do not forget to recompile
  57. // the plugin and to install the new .amx file on your server.
  58. // You can find the list of admin flags in the amx/examples/include/amxconst.inc file.
  59.  
  60. #define FLAG_AMX_SETBOMBSITE  ADMIN_CVAR
  61. #define FLAG_AMX_BOMBSITEMENU ADMIN_CVAR
  62.  
  63. /******************************************************************************/
  64.  
  65. #include <translator>
  66. #include <amxmodx>
  67. #include <amxmisc>
  68. #include <VexdUM>
  69.  
  70. enum BombSites
  71. {
  72.     BOMBSITE_A,
  73.     BOMBSITE_B
  74. }
  75.  
  76. new g_iBombSiteEntity[ BombSites ];
  77. new bool:g_bBombSiteStatus[ BombSites ];
  78. new bool:g_bIsBombSiteInfo[ BombSites ];
  79. new Float:g_flBombSiteInfoOrigins[ BombSites ][3];
  80. new g_iPlayerWithBomb;
  81. new bool:g_bPlayerHoldingBomb;
  82.  
  83. new g_iHUDEntity;
  84.  
  85. new g_pCVarAllowPlantNum;
  86. new g_pCVarLockSiteNum;
  87. new g_pCVarLockSite;
  88.  
  89. public plugin_init( )
  90. {
  91.     load_translations( "bombsite_lock" );
  92.     register_plugin( _T( "BombSite Lock" ) , "0.4" , "Bugsy" );
  93.    
  94.     new szMap[ 11 ] , BombSites:bsBombSiteA , BombSites:bsBombSiteB;
  95.     get_mapname( szMap , charsmax( szMap ) );
  96.    
  97.     if ( equal( szMap , "de_chateau" ) || equal( szMap , "de_dust2" , 8 ) || equal( szMap , "de_train" ) )
  98.     {
  99.         bsBombSiteA = BOMBSITE_B;
  100.         bsBombSiteB = BOMBSITE_A;
  101.     }
  102.     else
  103.     {
  104.         bsBombSiteA = BOMBSITE_A;
  105.         bsBombSiteB = BOMBSITE_B;  
  106.     }
  107.    
  108.     g_iBombSiteEntity[ bsBombSiteA ] = find_entity( -1 , "func_bomb_target" );
  109.    
  110.     if ( g_iBombSiteEntity[ bsBombSiteA ] <= 0 )
  111.     {
  112.         g_iBombSiteEntity[ bsBombSiteA ] = find_entity( -1 , "info_bomb_target" );
  113.        
  114.         if ( g_iBombSiteEntity[ bsBombSiteA ] > 0 )
  115.         {
  116.             g_bIsBombSiteInfo[ bsBombSiteA ] = true;
  117.             entity_get_vector( g_iBombSiteEntity[ bsBombSiteA ] , EV_VEC_origin , g_flBombSiteInfoOrigins[ bsBombSiteA ] );
  118.         }
  119.     }
  120.    
  121.     g_iBombSiteEntity[ bsBombSiteB ] = find_entity( g_iBombSiteEntity[ bsBombSiteA ] , "func_bomb_target" );
  122.    
  123.     if ( g_iBombSiteEntity[ bsBombSiteB ] <= 0 )
  124.     {
  125.         g_iBombSiteEntity[ bsBombSiteB ] = find_entity( g_iBombSiteEntity[ bsBombSiteA ] , "info_bomb_target" );
  126.        
  127.         if ( g_iBombSiteEntity[ bsBombSiteB ] > 0 )
  128.         {
  129.             g_bIsBombSiteInfo[ bsBombSiteB ] = true;
  130.             entity_get_vector( g_iBombSiteEntity[ bsBombSiteB ] , EV_VEC_origin , g_flBombSiteInfoOrigins[ bsBombSiteB ] );
  131.         }
  132.     }
  133.    
  134.     if ( g_iBombSiteEntity[ BOMBSITE_A ] <= 0 || g_iBombSiteEntity[ BOMBSITE_B ] <= 0 )
  135.     {
  136.         server_print( _T( "* BombSite Lock: Map ^"%s^" is not supported. Plugin uninitialized." ) , szMap );
  137.         return;
  138.     }
  139.    
  140.     register_concmd( "amx_setbombsite" , "SetBombSiteConsole" , FLAG_AMX_SETBOMBSITE , _T( "<A|B> <0|1> - unlocks/locks the specified bombsite" ) );
  141.     register_concmd( "amx_bombsitemenu" , "ShowBombSiteMenu" , FLAG_AMX_BOMBSITEMENU , _T( "- displays bomb site lock menu" ) );
  142.    
  143.     g_pCVarAllowPlantNum = register_cvar( "bl_allowplantctnum" , "0" );
  144.     g_pCVarLockSiteNum = register_cvar( "bl_locksitectnum" , "2" );
  145.     g_pCVarLockSite = register_cvar( "bl_locksite" , "b" );
  146.    
  147.     register_event( "CurWeapon" , "fw_EvCurWeapon" , "b" , "1=1" );
  148.     register_event( "WeapPickup", "fw_EvWeapPickup" , "be" , "1=6" );
  149.     register_event( "BombDrop" ,  "fw_EvBombDrop" , "bc" );
  150.    
  151.     register_logevent( "fw_EvRoundStart" , 2 , "1=Round_Start" );
  152.    
  153.     register_menucmd( register_menuid( "\yBombSite Lock Menu" ) , (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<9) , "CommandBombSiteMenu" );
  154.    
  155.     g_iHUDEntity = create_entity( "info_target" );
  156.     entity_set_string( g_iHUDEntity , EV_SZ_classname , "bl_hud_entity" );
  157. }
  158.  
  159. public client_disconnect( id )
  160. {
  161.     if ( g_iPlayerWithBomb == id )
  162.     {
  163.         g_iPlayerWithBomb = 0;
  164.         g_bPlayerHoldingBomb = false;
  165.     }
  166. }
  167.  
  168. public fw_EvCurWeapon( id )
  169. {
  170.     if ( id == g_iPlayerWithBomb )
  171.     {
  172.         if ( read_data( 2 ) == CSW_C4 )
  173.         {
  174.             g_bPlayerHoldingBomb = true;
  175.             entity_set_float( g_iHUDEntity , EV_FL_nextthink , get_gametime() + 1.0 );
  176.         }
  177.         else
  178.         {
  179.             g_bPlayerHoldingBomb = false;
  180.         }
  181.     }
  182. }
  183.  
  184. public fw_EvWeapPickup( id )
  185. {
  186.     g_iPlayerWithBomb = id;
  187. }
  188.  
  189. public fw_EvBombDrop()
  190. {
  191.     g_iPlayerWithBomb = 0;
  192.     g_bPlayerHoldingBomb = false;
  193. }
  194.  
  195. public fw_EvRoundStart()
  196. {
  197.     new iAllowPlantNum = get_cvarptr_num( g_pCVarAllowPlantNum );
  198.     new iLockSiteNum = get_cvarptr_num( g_pCVarLockSiteNum );      
  199.     new iPlayers[ 32 ] , iNum , iCTCount;
  200.    
  201.     get_players( iPlayers , iNum , "h" );
  202.    
  203.     for ( new i = 0 ; i < iNum ; i++ )
  204.         if ( get_user_team( iPlayers[ i ] ) == 2 )
  205.             iCTCount++;
  206.    
  207.     if ( iCTCount < iAllowPlantNum )
  208.     {
  209.         SetBombSiteLock( BOMBSITE_A , true );
  210.         SetBombSiteLock( BOMBSITE_B , true );
  211.        
  212.         client_print( 0 , print_chat , _T( "* BombSites A & B are both locked since there are less than %d CTs." ) , iAllowPlantNum );
  213.     }
  214.     else if ( iCTCount < iLockSiteNum )
  215.     {
  216.         new szSite[ 2 ];
  217.         get_cvarptr_string( g_pCVarLockSite , szSite , charsmax( szSite ) );
  218.         szSite[ 0 ] = toupper( szSite[ 0 ] );
  219.        
  220.         if ( !( 'A' <= szSite[ 0 ] <= 'B' ) )
  221.             return;
  222.            
  223.         SetBombSiteLock( ( szSite[ 0 ] == 'A' ) ? BOMBSITE_A : BOMBSITE_B , true );    
  224.         SetBombSiteLock( ( szSite[ 0 ] == 'A' ) ? BOMBSITE_B : BOMBSITE_A , false );           
  225.        
  226.         client_print( 0 , print_chat , _T( "* BombSite %s has been locked since there are less than %d CTs." ) , szSite , iLockSiteNum );  
  227.     }
  228.     else
  229.     {
  230.         SetBombSiteLock( BOMBSITE_A , false );
  231.         SetBombSiteLock( BOMBSITE_B , false );
  232.     }
  233. }
  234.  
  235. public SetBombSiteConsole( id , AdminLevel , CommandId )
  236. {
  237.     if ( !cmd_access( id , AdminLevel , CommandId , 3 ) )
  238.     {
  239.         return PLUGIN_HANDLED;
  240.     }
  241.    
  242.     /*if ( g_iBombSiteEntity[ BOMBSITE_A ] <= 0 || g_iBombSiteEntity[ BOMBSITE_B ] <= 0 )
  243.     {
  244.         console_print( id , _T( "* BombSite Lock: Sorry, this map is not supported." ) );
  245.         return PLUGIN_HANDLED;
  246.     }*/
  247.    
  248.     new szSite[ 3 ] , szState[ 3 ] , iState , BombSites:bsSite;
  249.     read_argv( 1 , szSite , charsmax( szSite ) );
  250.     read_argv( 2 , szState , charsmax( szState ) );
  251.    
  252.     iState = str_to_num( szState );
  253.    
  254.     if ( strlen( szSite ) > 1 || !is_str_num( szState ) || !( 0 <= iState <= 1 ) )
  255.         szSite[ 0 ] = 'X';
  256.     else
  257.         szSite[ 0 ] = toupper( szSite[ 0 ] );
  258.    
  259.     switch ( szSite[ 0 ] )
  260.     {
  261.         case 'A':
  262.         {
  263.             bsSite = BOMBSITE_A;
  264.         }
  265.         case 'B':
  266.         {
  267.             bsSite = BOMBSITE_B;
  268.         }
  269.         default:
  270.         {
  271.             console_print( id , _T( "Usage: amx_setbombsite <A|B> <0|1> - unlocks/locks the specified bombsite" ) );
  272.             return PLUGIN_HANDLED;
  273.         }
  274.     }
  275.    
  276.     SetBombSiteLock( bsSite , bool:iState );
  277.    
  278.     console_print( id , _T( "* BombSite %s has been %s." ) , szSite , iState ? _T( "locked" ) : _T( "unlocked" ) );
  279.    
  280.     set_hudmessage( 255 , 165 , 000 , -1.0 , 0.65 , 0 , 3.0 , 3.0 , .channel = -1 );
  281.     show_hudmessage( 0 , _T( "BombSite %s has been %s..." ) , szSite , iState ? _T( "locked" ) : _T( "unlocked" ) );
  282.    
  283.     return PLUGIN_HANDLED;
  284. }
  285.  
  286. public ShowBombSiteMenu( id , AdminLevel )
  287. {
  288.     if ( !access( id , AdminLevel ) )
  289.     {
  290.         console_print( id , _T( "You have no access to that command." ) );
  291.         return PLUGIN_HANDLED;
  292.     }
  293.    
  294.     /*if ( g_iBombSiteEntity[ BOMBSITE_A ] <= 0 || g_iBombSiteEntity[ BOMBSITE_B ] <= 0 )
  295.     {
  296.         console_print( id , _T( "* BombSite Lock: Sorry, this map is not supported." ) );
  297.         return PLUGIN_HANDLED;
  298.     }*/
  299.    
  300.     DisplayBombSiteMenu( id );
  301.    
  302.     return PLUGIN_HANDLED;
  303. }
  304.  
  305. DisplayBombSiteMenu( id )
  306. {
  307.     new szMenu[ 256 ] , iKeys = (1<<9);
  308.     new iLen = copy( szMenu , charsmax( szMenu ) , _T( "\yBombSite Lock Menu\w" , id ) );
  309.    
  310.     if ( g_bBombSiteStatus[ BOMBSITE_A ] )
  311.         iLen += copy( szMenu[ iLen ] , charsmax( szMenu ) - iLen , _T( "^n^n\d1. Lock A" , id ) );
  312.     else
  313.     {
  314.         iLen += copy( szMenu[ iLen ] , charsmax( szMenu ) - iLen , _T( "^n^n\w1. Lock A" , id ) );
  315.         iKeys |= (1<<0);
  316.     }
  317.    
  318.     if ( g_bBombSiteStatus[ BOMBSITE_B ] )
  319.         iLen += copy( szMenu[ iLen ] , charsmax( szMenu ) - iLen , _T( "^n\d2. Lock B" , id ) );
  320.     else
  321.     {
  322.         iLen += copy( szMenu[ iLen ] , charsmax( szMenu ) - iLen , _T( "^n\w2. Lock B" , id ) );
  323.         iKeys |= (1<<1);
  324.     }
  325.    
  326.     if ( g_bBombSiteStatus[ BOMBSITE_A ] )
  327.     {
  328.         iLen += copy( szMenu[ iLen ] , charsmax( szMenu ) - iLen , _T( "^n\w3. Unlock A" , id ) );
  329.         iKeys |= (1<<2);
  330.     }
  331.     else
  332.         iLen += copy( szMenu[ iLen ] , charsmax( szMenu ) - iLen , _T( "^n\d3. Unlock A" , id ) );
  333.    
  334.     if ( g_bBombSiteStatus[ BOMBSITE_B ] )
  335.     {
  336.         iLen += copy( szMenu[ iLen ] , charsmax( szMenu ) - iLen , _T( "^n\w4. Unlock B" , id ) );
  337.         iKeys |= (1<<3);
  338.     }
  339.     else
  340.         iLen += copy( szMenu[ iLen ] , charsmax( szMenu ) - iLen , _T( "^n\d4. Unlock B" , id ) );
  341.    
  342.     if ( g_bBombSiteStatus[ BOMBSITE_A ] && g_bBombSiteStatus[ BOMBSITE_B ] )
  343.         iLen += copy( szMenu[ iLen ] , charsmax( szMenu ) - iLen , _T( "^n\d5. Lock A & B" , id ) );
  344.     else
  345.     {
  346.         iLen += copy( szMenu[ iLen ] , charsmax( szMenu ) - iLen , _T( "^n\w5. Lock A & B" , id ) );
  347.         iKeys |= (1<<4);
  348.     }
  349.    
  350.     if (g_bBombSiteStatus[ BOMBSITE_A ] || g_bBombSiteStatus[ BOMBSITE_B ] )
  351.     {
  352.         iLen += copy( szMenu[ iLen ] , charsmax( szMenu ) - iLen , _T( "^n\w6. Unlock A & B" , id ) );
  353.         iKeys |= (1<<5);
  354.     }
  355.     else
  356.         iLen += copy( szMenu[ iLen ] , charsmax( szMenu ) - iLen , _T( "^n\d6. Unlock A & B" , id ) );
  357.    
  358.     iLen += copy( szMenu[ iLen ] , charsmax( szMenu ) - iLen , _T( "^n^n\w0. Exit" , id ) );
  359.    
  360.     show_menu( id , iKeys , szMenu , _ , "\yBombSite Lock Menu" );
  361. }
  362.  
  363. public CommandBombSiteMenu( id , iKey )
  364. {
  365.     set_hudmessage( 255 , 165 , 000 , -1.0 , 0.65 , 0 , 3.0 , 3.0 , .channel = -1 );
  366.    
  367.     switch ( iKey )
  368.     {
  369.         case 0:
  370.         {
  371.             SetBombSiteLock( BOMBSITE_A , true );
  372.             show_hudmessage( 0 , _T( "BombSite A has been locked..." ) );
  373.         }
  374.         case 1:
  375.         {
  376.             SetBombSiteLock( BOMBSITE_B , true );
  377.             show_hudmessage( 0 , _T( "BombSite B has been locked..." ) );
  378.         }
  379.         case 2:
  380.         {
  381.             SetBombSiteLock( BOMBSITE_A , false );
  382.             show_hudmessage( 0 , _T( "BombSite A has been unlocked..." ) );
  383.         }
  384.         case 3:
  385.         {
  386.             SetBombSiteLock( BOMBSITE_B , false );
  387.             show_hudmessage( 0 , _T( "BombSite B has been unlocked..." ) );
  388.         }
  389.         case 4:
  390.         {
  391.             SetBombSiteLock( BOMBSITE_A , true );
  392.             SetBombSiteLock( BOMBSITE_B , true );
  393.             show_hudmessage( 0 , _T( "BombSites A & B have both been locked..." ) );
  394.         }
  395.         case 5:
  396.         {
  397.             SetBombSiteLock( BOMBSITE_A , false );
  398.             SetBombSiteLock( BOMBSITE_B , false );
  399.             show_hudmessage( 0 , _T( "BombSites A & B have both been unlocked..." ) );
  400.         }
  401.     }
  402.    
  403.     if( 0 <= iKey <= 5 )
  404.         DisplayBombSiteMenu( id );
  405. }
  406.  
  407. public entity_think( iEntity )
  408. {
  409.     if ( iEntity == g_iHUDEntity )
  410.     {
  411.         if( g_bPlayerHoldingBomb &&
  412.         ( g_bBombSiteStatus[ BOMBSITE_A ] || g_bBombSiteStatus[ BOMBSITE_B ] ) && is_user_alive( g_iPlayerWithBomb ) )
  413.         {
  414.             set_hudmessage( 255 , 165 , 000 , -1.0 , 0.87 , 0 , 1.0 , 1.0 , .channel = -1 );
  415.             show_hudmessage( g_iPlayerWithBomb , _T( "BombSite%s %s%s%s %s currently locked!" ) ,
  416.                 g_bBombSiteStatus[ BOMBSITE_A ] && g_bBombSiteStatus[ BOMBSITE_B ] ? "s" : ""  ,
  417.                 g_bBombSiteStatus[ BOMBSITE_A ] ? "A" : "" ,
  418.                 g_bBombSiteStatus[ BOMBSITE_A ] && g_bBombSiteStatus[ BOMBSITE_B ] ? " & " : "" ,
  419.                 g_bBombSiteStatus[ BOMBSITE_B ] ? "B" : "" ,
  420.                 g_bBombSiteStatus[ BOMBSITE_A ] && g_bBombSiteStatus[ BOMBSITE_B ] ? _T( "are" ) : _T( "is" ) );
  421.            
  422.             entity_set_float( g_iHUDEntity , EV_FL_nextthink , ( get_gametime() + 1.0 ) );
  423.         }
  424.     }
  425. }
  426.  
  427. SetBombSiteLock( BombSites:bsBombSite , bool:bLockState )  
  428. {
  429.     if ( g_bIsBombSiteInfo[ bsBombSite ] )
  430.     {
  431.         if( bLockState )
  432.             entity_set_origin( g_iBombSiteEntity[ bsBombSite ] , Float:{99999.0, 99999.0, 99999.0} );
  433.         else
  434.             entity_set_origin( g_iBombSiteEntity[ bsBombSite ] , g_flBombSiteInfoOrigins[ bsBombSite ] );
  435.     }
  436.     else
  437.     {
  438.         entity_set_int( g_iBombSiteEntity[ bsBombSite ] , EV_INT_solid , bLockState ? SOLID_NOT : SOLID_TRIGGER );
  439.     }
  440.    
  441.     g_bBombSiteStatus[ bsBombSite ] = bLockState;
  442.    
  443.     if ( bLockState )
  444.         entity_set_float( g_iHUDEntity , EV_FL_nextthink , ( get_gametime() + 1.0 ) );
  445. }


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: BombSite Lock Version 0.4 hiba
HozzászólásElküldve: 2019.12.31. 17:13 
Offline
Őstag
Avatar

Csatlakozott: 2015.07.27. 22:56
Hozzászólások: 1367
Megköszönt másnak: 28 alkalommal
Megköszönték neki: 351 alkalommal
viewtopic.php?f=101&t=12175


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: BombSite Lock Version 0.4 hiba
HozzászólásElküldve: 2020.01.04. 15:50 
Offline
Fanatikus

Csatlakozott: 2019.12.06. 20:00
Hozzászólások: 158
Megköszönt másnak: 13 alkalommal
regener írta:
viewtopic.php?f=101&t=12175



bombsite_lock.sma(201) : error 017: undefined symbol "get_cvarptr_num"
bombsite_lock.sma(202) : error 017: undefined symbol "get_cvarptr_num"
bombsite_lock.sma(221) : error 017: undefined symbol "get_cvarptr_string"
bombsite_lock.sma(221) : error 088: number of arguments does not match definition
bombsite_lock.sma(147) : warning 204: symbol is assigned a value that is never used: "g_pCVarAllowPlantNum"
bombsite_lock.sma(149) : warning 204: symbol is assigned a value that is never used: "g_pCVarLockSite"
bombsite_lock.sma(148) : warning 204: symbol is assigned a value that is never used: "g_pCVarLockSiteNum"

javítható?

  1. /*
  2.      *    BombSite Lock
  3.      *    Version: 0.4
  4.      *    Author: Bugsy
  5.      *
  6.      *
  7.      * Description
  8.      *
  9.      *    This plugin allows you to lock bombsite(s), preventing them from being used.
  10.      *    When a bombsite is locked, the player currently holding the bomb will have a HUD message indicating which bombsite(s) are locked.
  11.      *    Bombsite locks will remain from round to round but not between map changes.
  12.      *    There are cvars to control if and how bombsites are automatically locked depending on the number of CT players on the server.
  13.      *
  14.      *
  15.      * Commands
  16.      *
  17.      *    amx_setbombsite <A|B> <0|1> - unlocks/locks the specified bombsite
  18.      *    amx_bombsitemenu - displays bomb site lock menu
  19.      *
  20.      *
  21.      * CVars
  22.      *
  23.      *    bl_allowplantctnum - Minimum number of CT players required to allow bomb planting (both sites would be locked if less).
  24.      *        Default: 0 (0=disabled or any number as # CT of players)
  25.      *    bl_locksitectnum - Minimum number of CT players required to have both bombsites open for planting. If there are less CT players, one of the bombsites (defined by cvar bl_locksite) will be locked.
  26.      *        Default: 2 (0=disabled or any number as # CT of players)
  27.      *    bl_locksite - The bombsite that will be locked if the number of CT players is less than bl_locksitectnum value.
  28.      *        Default: b (Must be a or b)
  29.      *
  30.      *
  31.      * Modules
  32.      *
  33.      *    VexdUM
  34.      *
  35.      *
  36.      * ChangeLog
  37.      *
  38.      *    0.4
  39.      *        Fixed support for all maps, but not for more than two bombsites (supports now the "info_bomb_target" entities).
  40.      *        Plugin will be unitialized if there are not two bombsites found at least.
  41.      *    0.3
  42.      *        Added support for all maps (experimental).
  43.      *        Bombsites on all of the standard CS maps with an A and B designation should all work properly according to A and B naming.
  44.      *        Maps without an A and B designation will still be treated as A and B by the plugin; A and B is chosen by
  45.      *        the plugin based on which bombsite entity is spawned first.
  46.      *        If you notice a map where A and B are handled by the plugin oppositely, let me know and I can correct it.
  47.      *        Menu will now display only the available commands for use. ie, if A is already locked, "Lock A" menu item will be disabled etc.
  48.      *        Fixed bug which affected the HUD being displayed to the user holding the bomb.
  49.      *        Added cvars to control auto-locking of bombsites. See above.
  50.      *    0.2
  51.      *        Initial release
  52.      *
  53.      */
  54.      
  55.     /******************************************************************************/
  56.     // If you change one of the following settings, do not forget to recompile
  57.     // the plugin and to install the new .amx file on your server.
  58.     // You can find the list of admin flags in the amx/examples/include/amxconst.inc file.
  59.      
  60.     #define FLAG_AMX_SETBOMBSITE  ADMIN_CVAR
  61.     #define FLAG_AMX_BOMBSITEMENU ADMIN_CVAR
  62.      
  63.     /******************************************************************************/
  64.      
  65.     #include <translator>
  66.     #include <amxmod>
  67.     #include <amxmisc>
  68.     #include <VexdUM>
  69.      
  70.     enum BombSites
  71.     {
  72.         BOMBSITE_A,
  73.         BOMBSITE_B
  74.     }
  75.      
  76.     new g_iBombSiteEntity[ BombSites ];
  77.     new bool:g_bBombSiteStatus[ BombSites ];
  78.     new bool:g_bIsBombSiteInfo[ BombSites ];
  79.     new Float:g_flBombSiteInfoOrigins[ BombSites ][3];
  80.     new g_iPlayerWithBomb;
  81.     new bool:g_bPlayerHoldingBomb;
  82.      
  83.     new g_iHUDEntity;
  84.      
  85.     new g_pCVarAllowPlantNum;
  86.     new g_pCVarLockSiteNum;
  87.     new g_pCVarLockSite;
  88.      
  89.     public plugin_init( )
  90.     {
  91.         load_translations( "bombsite_lock" );
  92.         register_plugin( _T( "BombSite Lock" ) , "0.4" , "Bugsy" );
  93.        
  94.         new szMap[ 11 ] , BombSites:bsBombSiteA , BombSites:bsBombSiteB;
  95.         get_mapname( szMap , charsmax( szMap ) );
  96.        
  97.         if ( equal( szMap , "de_chateau" ) || equal( szMap , "de_dust2" , 8 ) || equal( szMap , "de_train" ) )
  98.         {
  99.             bsBombSiteA = BOMBSITE_B;
  100.             bsBombSiteB = BOMBSITE_A;
  101.         }
  102.         else
  103.         {
  104.             bsBombSiteA = BOMBSITE_A;
  105.             bsBombSiteB = BOMBSITE_B;  
  106.         }
  107.        
  108.         g_iBombSiteEntity[ bsBombSiteA ] = find_entity( -1 , "func_bomb_target" );
  109.        
  110.         if ( g_iBombSiteEntity[ bsBombSiteA ] <= 0 )
  111.         {
  112.             g_iBombSiteEntity[ bsBombSiteA ] = find_entity( -1 , "info_bomb_target" );
  113.            
  114.             if ( g_iBombSiteEntity[ bsBombSiteA ] > 0 )
  115.             {
  116.                 g_bIsBombSiteInfo[ bsBombSiteA ] = true;
  117.                 entity_get_vector( g_iBombSiteEntity[ bsBombSiteA ] , EV_VEC_origin , g_flBombSiteInfoOrigins[ bsBombSiteA ] );
  118.             }
  119.         }
  120.        
  121.         g_iBombSiteEntity[ bsBombSiteB ] = find_entity( g_iBombSiteEntity[ bsBombSiteA ] , "func_bomb_target" );
  122.        
  123.         if ( g_iBombSiteEntity[ bsBombSiteB ] <= 0 )
  124.         {
  125.             g_iBombSiteEntity[ bsBombSiteB ] = find_entity( g_iBombSiteEntity[ bsBombSiteA ] , "info_bomb_target" );
  126.            
  127.             if ( g_iBombSiteEntity[ bsBombSiteB ] > 0 )
  128.             {
  129.                 g_bIsBombSiteInfo[ bsBombSiteB ] = true;
  130.                 entity_get_vector( g_iBombSiteEntity[ bsBombSiteB ] , EV_VEC_origin , g_flBombSiteInfoOrigins[ bsBombSiteB ] );
  131.             }
  132.         }
  133.        
  134.         if ( g_iBombSiteEntity[ BOMBSITE_A ] <= 0 || g_iBombSiteEntity[ BOMBSITE_B ] <= 0 )
  135.         {
  136.             server_print( _T( "* BombSite Lock: Map ^"%s^" is not supported. Plugin uninitialized." ) , szMap );
  137.             return;
  138.         }
  139.        
  140.         register_concmd( "amx_setbombsite" , "SetBombSiteConsole" , FLAG_AMX_SETBOMBSITE , _T( "<A|B> <0|1> - unlocks/locks the specified bombsite" ) );
  141.         register_concmd( "amx_bombsitemenu" , "ShowBombSiteMenu" , FLAG_AMX_BOMBSITEMENU , _T( "- displays bomb site lock menu" ) );
  142.        
  143.         g_pCVarAllowPlantNum = register_cvar( "bl_allowplantctnum" , "0" );
  144.         g_pCVarLockSiteNum = register_cvar( "bl_locksitectnum" , "2" );
  145.         g_pCVarLockSite = register_cvar( "bl_locksite" , "b" );
  146.        
  147.         register_event( "CurWeapon" , "fw_EvCurWeapon" , "b" , "1=1" );
  148.         register_event( "WeapPickup", "fw_EvWeapPickup" , "be" , "1=6" );
  149.         register_event( "BombDrop" ,  "fw_EvBombDrop" , "bc" );
  150.        
  151.         register_logevent( "fw_EvRoundStart" , 2 , "1=Round_Start" );
  152.        
  153.         register_menucmd( register_menuid( "\yBombSite Lock Menu" ) , (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<9) , "CommandBombSiteMenu" );
  154.        
  155.         g_iHUDEntity = create_entity( "info_target" );
  156.         entity_set_string( g_iHUDEntity , EV_SZ_classname , "bl_hud_entity" );
  157.     }
  158.      
  159.     public client_disconnect( id )
  160.     {
  161.         if ( g_iPlayerWithBomb == id )
  162.         {
  163.             g_iPlayerWithBomb = 0;
  164.             g_bPlayerHoldingBomb = false;
  165.         }
  166.     }
  167.      
  168.     public fw_EvCurWeapon( id )
  169.     {
  170.         if ( id == g_iPlayerWithBomb )
  171.         {
  172.             if ( read_data( 2 ) == CSW_C4 )
  173.             {
  174.                 g_bPlayerHoldingBomb = true;
  175.                 entity_set_float( g_iHUDEntity , EV_FL_nextthink , get_gametime() + 1.0 );
  176.             }
  177.             else
  178.             {
  179.                 g_bPlayerHoldingBomb = false;
  180.             }
  181.         }
  182.     }
  183.      
  184.     public fw_EvWeapPickup( id )
  185.     {
  186.         g_iPlayerWithBomb = id;
  187.     }
  188.      
  189.     public fw_EvBombDrop()
  190.     {
  191.         g_iPlayerWithBomb = 0;
  192.         g_bPlayerHoldingBomb = false;
  193.     }
  194.      
  195.     public fw_EvRoundStart()
  196.     {
  197.         new iAllowPlantNum = get_cvarptr_num( g_pCVarAllowPlantNum );
  198.         new iLockSiteNum = get_cvarptr_num( g_pCVarLockSiteNum );      
  199.         new iPlayers[ 32 ] , iNum , iCTCount;
  200.        
  201.         get_players( iPlayers , iNum , "h" );
  202.        
  203.         for ( new i = 0 ; i < iNum ; i++ )
  204.             if ( get_user_team( iPlayers[ i ] ) == 2 )
  205.                 iCTCount++;
  206.        
  207.         if ( iCTCount < iAllowPlantNum )
  208.         {
  209.             SetBombSiteLock( BOMBSITE_A , true );
  210.             SetBombSiteLock( BOMBSITE_B , true );
  211.            
  212.             client_print( 0 , print_chat , _T( "* BombSites A & B are both locked since there are less than %d CTs." ) , iAllowPlantNum );
  213.         }
  214.         else if ( iCTCount < iLockSiteNum )
  215.         {
  216.             new szSite[ 2 ];
  217.             get_cvarptr_string( g_pCVarLockSite , szSite , charsmax( szSite ) );
  218.             szSite[ 0 ] = toupper( szSite[ 0 ] );
  219.            
  220.             if ( !( 'A' <= szSite[ 0 ] <= 'B' ) )
  221.                 return;
  222.                
  223.             SetBombSiteLock( ( szSite[ 0 ] == 'A' ) ? BOMBSITE_A : BOMBSITE_B , true );    
  224.             SetBombSiteLock( ( szSite[ 0 ] == 'A' ) ? BOMBSITE_B : BOMBSITE_A , false );          
  225.            
  226.             client_print( 0 , print_chat , _T( "* BombSite %s has been locked since there are less than %d CTs." ) , szSite , iLockSiteNum );  
  227.         }
  228.         else
  229.         {
  230.             SetBombSiteLock( BOMBSITE_A , false );
  231.             SetBombSiteLock( BOMBSITE_B , false );
  232.         }
  233.     }
  234.      
  235.     public SetBombSiteConsole( id , AdminLevel , CommandId )
  236.     {
  237.         if ( !cmd_access( id , AdminLevel , CommandId , 3 ) )
  238.         {
  239.             return PLUGIN_HANDLED;
  240.         }
  241.        
  242.         /*if ( g_iBombSiteEntity[ BOMBSITE_A ] <= 0 || g_iBombSiteEntity[ BOMBSITE_B ] <= 0 )
  243.         {
  244.             console_print( id , _T( "* BombSite Lock: Sorry, this map is not supported." ) );
  245.             return PLUGIN_HANDLED;
  246.         }*/
  247.        
  248.         new szSite[ 3 ] , szState[ 3 ] , iState , BombSites:bsSite;
  249.         read_argv( 1 , szSite , charsmax( szSite ) );
  250.         read_argv( 2 , szState , charsmax( szState ) );
  251.        
  252.         iState = str_to_num( szState );
  253.        
  254.         if ( strlen( szSite ) > 1 || !is_str_num( szState ) || !( 0 <= iState <= 1 ) )
  255.             szSite[ 0 ] = 'X';
  256.         else
  257.             szSite[ 0 ] = toupper( szSite[ 0 ] );
  258.        
  259.         switch ( szSite[ 0 ] )
  260.         {
  261.             case 'A':
  262.             {
  263.                 bsSite = BOMBSITE_A;
  264.             }
  265.             case 'B':
  266.             {
  267.                 bsSite = BOMBSITE_B;
  268.             }
  269.             default:
  270.             {
  271.                 console_print( id , _T( "Usage: amx_setbombsite <A|B> <0|1> - unlocks/locks the specified bombsite" ) );
  272.                 return PLUGIN_HANDLED;
  273.             }
  274.         }
  275.        
  276.         SetBombSiteLock( bsSite , bool:iState );
  277.        
  278.         console_print( id , _T( "* BombSite %s has been %s." ) , szSite , iState ? _T( "locked" ) : _T( "unlocked" ) );
  279.        
  280.         set_hudmessage( 255 , 165 , 000 , -1.0 , 0.65 , 0 , 3.0 , 3.0 , .channel = -1 );
  281.         show_hudmessage( 0 , _T( "BombSite %s has been %s..." ) , szSite , iState ? _T( "locked" ) : _T( "unlocked" ) );
  282.        
  283.         return PLUGIN_HANDLED;
  284.     }
  285.      
  286.     public ShowBombSiteMenu( id , AdminLevel )
  287.     {
  288.         if ( !access( id , AdminLevel ) )
  289.         {
  290.             console_print( id , _T( "You have no access to that command." ) );
  291.             return PLUGIN_HANDLED;
  292.         }
  293.        
  294.         /*if ( g_iBombSiteEntity[ BOMBSITE_A ] <= 0 || g_iBombSiteEntity[ BOMBSITE_B ] <= 0 )
  295.         {
  296.             console_print( id , _T( "* BombSite Lock: Sorry, this map is not supported." ) );
  297.             return PLUGIN_HANDLED;
  298.         }*/
  299.        
  300.         DisplayBombSiteMenu( id );
  301.        
  302.         return PLUGIN_HANDLED;
  303.     }
  304.      
  305.     DisplayBombSiteMenu( id )
  306.     {
  307.         new szMenu[ 256 ] , iKeys = (1<<9);
  308.         new iLen = copy( szMenu , charsmax( szMenu ) , _T( "\yBombSite Lock Menu\w" , id ) );
  309.        
  310.         if ( g_bBombSiteStatus[ BOMBSITE_A ] )
  311.             iLen += copy( szMenu[ iLen ] , charsmax( szMenu ) - iLen , _T( "^n^n\d1. Lock A" , id ) );
  312.         else
  313.         {
  314.             iLen += copy( szMenu[ iLen ] , charsmax( szMenu ) - iLen , _T( "^n^n\w1. Lock A" , id ) );
  315.             iKeys |= (1<<0);
  316.         }
  317.        
  318.         if ( g_bBombSiteStatus[ BOMBSITE_B ] )
  319.             iLen += copy( szMenu[ iLen ] , charsmax( szMenu ) - iLen , _T( "^n\d2. Lock B" , id ) );
  320.         else
  321.         {
  322.             iLen += copy( szMenu[ iLen ] , charsmax( szMenu ) - iLen , _T( "^n\w2. Lock B" , id ) );
  323.             iKeys |= (1<<1);
  324.         }
  325.        
  326.         if ( g_bBombSiteStatus[ BOMBSITE_A ] )
  327.         {
  328.             iLen += copy( szMenu[ iLen ] , charsmax( szMenu ) - iLen , _T( "^n\w3. Unlock A" , id ) );
  329.             iKeys |= (1<<2);
  330.         }
  331.         else
  332.             iLen += copy( szMenu[ iLen ] , charsmax( szMenu ) - iLen , _T( "^n\d3. Unlock A" , id ) );
  333.        
  334.         if ( g_bBombSiteStatus[ BOMBSITE_B ] )
  335.         {
  336.             iLen += copy( szMenu[ iLen ] , charsmax( szMenu ) - iLen , _T( "^n\w4. Unlock B" , id ) );
  337.             iKeys |= (1<<3);
  338.         }
  339.         else
  340.             iLen += copy( szMenu[ iLen ] , charsmax( szMenu ) - iLen , _T( "^n\d4. Unlock B" , id ) );
  341.        
  342.         if ( g_bBombSiteStatus[ BOMBSITE_A ] && g_bBombSiteStatus[ BOMBSITE_B ] )
  343.             iLen += copy( szMenu[ iLen ] , charsmax( szMenu ) - iLen , _T( "^n\d5. Lock A & B" , id ) );
  344.         else
  345.         {
  346.             iLen += copy( szMenu[ iLen ] , charsmax( szMenu ) - iLen , _T( "^n\w5. Lock A & B" , id ) );
  347.             iKeys |= (1<<4);
  348.         }
  349.        
  350.         if (g_bBombSiteStatus[ BOMBSITE_A ] || g_bBombSiteStatus[ BOMBSITE_B ] )
  351.         {
  352.             iLen += copy( szMenu[ iLen ] , charsmax( szMenu ) - iLen , _T( "^n\w6. Unlock A & B" , id ) );
  353.             iKeys |= (1<<5);
  354.         }
  355.         else
  356.             iLen += copy( szMenu[ iLen ] , charsmax( szMenu ) - iLen , _T( "^n\d6. Unlock A & B" , id ) );
  357.        
  358.         iLen += copy( szMenu[ iLen ] , charsmax( szMenu ) - iLen , _T( "^n^n\w0. Exit" , id ) );
  359.        
  360.         show_menu( id , iKeys , szMenu , _ , "\yBombSite Lock Menu" );
  361.     }
  362.      
  363.     public CommandBombSiteMenu( id , iKey )
  364.     {
  365.         set_hudmessage( 255 , 165 , 000 , -1.0 , 0.65 , 0 , 3.0 , 3.0 , .channel = -1 );
  366.        
  367.         switch ( iKey )
  368.         {
  369.             case 0:
  370.             {
  371.                 SetBombSiteLock( BOMBSITE_A , true );
  372.                 show_hudmessage( 0 , _T( "BombSite A has been locked..." ) );
  373.             }
  374.             case 1:
  375.             {
  376.                 SetBombSiteLock( BOMBSITE_B , true );
  377.                 show_hudmessage( 0 , _T( "BombSite B has been locked..." ) );
  378.             }
  379.             case 2:
  380.             {
  381.                 SetBombSiteLock( BOMBSITE_A , false );
  382.                 show_hudmessage( 0 , _T( "BombSite A has been unlocked..." ) );
  383.             }
  384.             case 3:
  385.             {
  386.                 SetBombSiteLock( BOMBSITE_B , false );
  387.                 show_hudmessage( 0 , _T( "BombSite B has been unlocked..." ) );
  388.             }
  389.             case 4:
  390.             {
  391.                 SetBombSiteLock( BOMBSITE_A , true );
  392.                 SetBombSiteLock( BOMBSITE_B , true );
  393.                 show_hudmessage( 0 , _T( "BombSites A & B have both been locked..." ) );
  394.             }
  395.             case 5:
  396.             {
  397.                 SetBombSiteLock( BOMBSITE_A , false );
  398.                 SetBombSiteLock( BOMBSITE_B , false );
  399.                 show_hudmessage( 0 , _T( "BombSites A & B have both been unlocked..." ) );
  400.             }
  401.         }
  402.        
  403.         if( 0 <= iKey <= 5 )
  404.             DisplayBombSiteMenu( id );
  405.     }
  406.      
  407.     public entity_think( iEntity )
  408.     {
  409.         if ( iEntity == g_iHUDEntity )
  410.         {
  411.             if( g_bPlayerHoldingBomb &&
  412.             ( g_bBombSiteStatus[ BOMBSITE_A ] || g_bBombSiteStatus[ BOMBSITE_B ] ) && is_user_alive( g_iPlayerWithBomb ) )
  413.             {
  414.                 set_hudmessage( 255 , 165 , 000 , -1.0 , 0.87 , 0 , 1.0 , 1.0 , .channel = -1 );
  415.                 show_hudmessage( g_iPlayerWithBomb , _T( "BombSite%s %s%s%s %s currently locked!" ) ,
  416.                     g_bBombSiteStatus[ BOMBSITE_A ] && g_bBombSiteStatus[ BOMBSITE_B ] ? "s" : ""  ,
  417.                     g_bBombSiteStatus[ BOMBSITE_A ] ? "A" : "" ,
  418.                     g_bBombSiteStatus[ BOMBSITE_A ] && g_bBombSiteStatus[ BOMBSITE_B ] ? " & " : "" ,
  419.                     g_bBombSiteStatus[ BOMBSITE_B ] ? "B" : "" ,
  420.                     g_bBombSiteStatus[ BOMBSITE_A ] && g_bBombSiteStatus[ BOMBSITE_B ] ? _T( "are" ) : _T( "is" ) );
  421.                
  422.                 entity_set_float( g_iHUDEntity , EV_FL_nextthink , ( get_gametime() + 1.0 ) );
  423.             }
  424.         }
  425.     }
  426.      
  427.     SetBombSiteLock( BombSites:bsBombSite , bool:bLockState )  
  428.     {
  429.         if ( g_bIsBombSiteInfo[ bsBombSite ] )
  430.         {
  431.             if( bLockState )
  432.                 entity_set_origin( g_iBombSiteEntity[ bsBombSite ] , Float:{99999.0, 99999.0, 99999.0} );
  433.             else
  434.                 entity_set_origin( g_iBombSiteEntity[ bsBombSite ] , g_flBombSiteInfoOrigins[ bsBombSite ] );
  435.         }
  436.         else
  437.         {
  438.             entity_set_int( g_iBombSiteEntity[ bsBombSite ] , EV_INT_solid , bLockState ? SOLID_NOT : SOLID_TRIGGER );
  439.         }
  440.        
  441.         g_bBombSiteStatus[ bsBombSite ] = bLockState;
  442.        
  443.         if ( bLockState )
  444.             entity_set_float( g_iHUDEntity , EV_FL_nextthink , ( get_gametime() + 1.0 ) );
  445.     }
  446.  
  447. GeSHi © Codebox Plus


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: BombSite Lock Version 0.4 hiba
HozzászólásElküldve: 2020.01.04. 18:28 
Offline
Őskövület
Avatar

Csatlakozott: 2012.03.22. 18:22
Hozzászólások: 2978
Megköszönt másnak: 115 alkalommal
Megköszönték neki: 368 alkalommal
Tökéletes a plugin. Nem kell semmit sem javítani.
Ez amx plugin,miért akarod átrakni amxx-re,ha már van egy ugyan olyan?
Azért mert az amx verzió 0.4en van és az amxx 0.3-on nem jelenti azt hogy többet tud.

_________________
Blasenkampfwagen

https://discord.gg/uBYnNnZP
GTA:PURSUIT MTA


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: BombSite Lock Version 0.4 hiba
HozzászólásElküldve: 2020.01.04. 19:10 
Offline
Fanatikus

Csatlakozott: 2019.12.06. 20:00
Hozzászólások: 158
Megköszönt másnak: 13 alkalommal
ultraibolya írta:
Tökéletes a plugin. Nem kell semmit sem javítani.
Ez amx plugin,miért akarod átrakni amxx-re,ha már van egy ugyan olyan?
Azért mert az amx verzió 0.4en van és az amxx 0.3-on nem jelenti azt hogy többet tud.



sajnos ebben sok a bug. pl:eldobod a fegyvert eltünik meg lebegnek :(

  1. /*
  2.        Ford�totta: BBk - Death of Legend
  3.     */
  4.      
  5.     #include <amxmodx>
  6.     #include <engine>
  7.      
  8.     new const Version[] = "0.3";
  9.      
  10.     enum BombSites
  11.     {
  12.         BOMBSITE_A,
  13.         BOMBSITE_B
  14.     }
  15.      
  16.     new g_iBombSiteEntity[ BombSites ];
  17.     new bool:g_bBombSiteStatus[ BombSites ];
  18.     new g_iPlayerWithBomb;
  19.     new bool:g_bPlayerHoldingBomb;
  20.      
  21.     new g_iHUDEntity;
  22.      
  23.     new g_pCVarAllowPlantNum;
  24.     new g_pCVarLockSiteNum;
  25.     new g_pCVarLockSite;
  26.      
  27.     public plugin_init( )
  28.     {
  29.         register_plugin( "BombSite Lock" , Version , "bugsy" );
  30.      
  31.         register_concmd( "bl_setbombsite" , "SetBombSiteConsole" , ADMIN_KICK );
  32.         register_concmd( "bl_bombsitemenu" , "ShowBombSiteMenu" , ADMIN_KICK );
  33.      
  34.         register_event( "CurWeapon" , "fw_EvCurWeapon" , "b" , "1=1" );
  35.         register_event( "WeapPickup", "fw_EvWeapPickup" , "be" , "1=6" );
  36.         register_event( "BombDrop" ,  "fw_EvBombDrop" , "bc" );
  37.      
  38.         register_logevent( "fw_EvRoundStart" , 2 , "1=Round_Start" );  
  39.      
  40.         g_pCVarAllowPlantNum = register_cvar( "bl_allowplantctnum" , "0" );
  41.         g_pCVarLockSiteNum = register_cvar( "bl_locksitectnum" , "2" );
  42.         g_pCVarLockSite = register_cvar( "bl_locksite" , "b" );
  43.      
  44.         g_iHUDEntity = create_entity( "info_target" );
  45.         entity_set_string( g_iHUDEntity , EV_SZ_classname , "bl_hud_entity" );
  46.         register_think( "bl_hud_entity" , "fw_HUDEntThink" );
  47.      
  48.         new szMap[ 11 ] , BombSites:bsBombSiteA , BombSites:bsBombSiteB;
  49.         get_mapname( szMap , charsmax( szMap ) );
  50.      
  51.         if ( equal( szMap , "de_chateau" ) || equal( szMap , "de_dust2" ) || equal( szMap , "de_train" ) )
  52.         {
  53.             bsBombSiteA = BOMBSITE_B;
  54.             bsBombSiteB = BOMBSITE_A;
  55.         }
  56.         else
  57.         {
  58.             bsBombSiteA = BOMBSITE_A;
  59.             bsBombSiteB = BOMBSITE_B;  
  60.         }
  61.      
  62.         g_iBombSiteEntity[ bsBombSiteA ] = find_ent_by_class( -1 , "func_bomb_target" );
  63.         g_iBombSiteEntity[ bsBombSiteB ] = find_ent_by_class( g_iBombSiteEntity[ bsBombSiteA ] , "func_bomb_target" );
  64.     }
  65.      
  66.     public client_disconnect( id )
  67.     {
  68.         if ( g_iPlayerWithBomb == id )
  69.         {
  70.             g_iPlayerWithBomb = 0;
  71.             g_bPlayerHoldingBomb = false;
  72.         }
  73.     }
  74.      
  75.     public fw_EvCurWeapon( id )
  76.     {
  77.         if ( id == g_iPlayerWithBomb )
  78.         {
  79.             if ( read_data( 2 ) == CSW_C4 )
  80.             {
  81.                 g_bPlayerHoldingBomb = true;
  82.                 entity_set_float( g_iHUDEntity , EV_FL_nextthink , ( get_gametime() + 1.0 ) );
  83.             }
  84.             else
  85.             {
  86.                 g_bPlayerHoldingBomb = false;
  87.             }
  88.         }
  89.     }
  90.      
  91.     public fw_EvWeapPickup( id )
  92.     {
  93.         g_iPlayerWithBomb = id;
  94.     }
  95.      
  96.     public fw_EvBombDrop()
  97.     {
  98.         g_iPlayerWithBomb = 0;
  99.         g_bPlayerHoldingBomb = false;
  100.     }
  101.      
  102.     public fw_EvRoundStart()
  103.     {
  104.         new iAllowPlantNum = get_pcvar_num( g_pCVarAllowPlantNum );
  105.         new iLockSiteNum = get_pcvar_num( g_pCVarLockSiteNum );    
  106.         new iPlayers[ 32 ] , iNum , iCTCount;
  107.      
  108.         get_players( iPlayers , iNum , "h" );
  109.      
  110.         for ( new i = 0 ; i < iNum ; i++ )
  111.             if ( get_user_team( iPlayers[ i ] ) == 2 )
  112.                 iCTCount++;
  113.      
  114.         if ( iCTCount < iAllowPlantNum )
  115.         {
  116.             SetBombSiteLock( BOMBSITE_A , true );
  117.             SetBombSiteLock( BOMBSITE_B , true );
  118.      
  119.             client_print( 0 , print_chat , "* Bombalerako (A & B) lezarva, ameddig %d CT nem lesz." , iAllowPlantNum );
  120.         }
  121.         else if ( iCTCount < iLockSiteNum )
  122.         {
  123.             new szSite[ 2 ];
  124.             get_pcvar_string( g_pCVarLockSite , szSite , charsmax( szSite ) );
  125.             szSite[ 0 ] = toupper( szSite[ 0 ] );
  126.      
  127.             if ( !( 'A' <= szSite[ 0 ] <= 'B' ) )
  128.                 return PLUGIN_CONTINUE;
  129.      
  130.             SetBombSiteLock( ( szSite[ 0 ] == 'A' ) ? BOMBSITE_A : BOMBSITE_B , true );    
  131.             SetBombSiteLock( ( szSite[ 0 ] == 'A' ) ? BOMBSITE_B : BOMBSITE_A , false );           
  132.      
  133.             client_print( 0 , print_chat , "* Bombalerako (%s) lezarva, ameddig %d CT nem lesz." , szSite , iLockSiteNum );
  134.         }
  135.         else
  136.         {
  137.             SetBombSiteLock( BOMBSITE_A , false );
  138.             SetBombSiteLock( BOMBSITE_B , false );
  139.         }
  140.      
  141.         return PLUGIN_CONTINUE;
  142.     }
  143.      
  144.     public SetBombSiteConsole( id , AdminLevel )
  145.     {
  146.         if ( !( get_user_flags( id ) & AdminLevel ) )
  147.         {
  148.             console_print( id , "* Nincs engedelyed ehhez a parancshoz." );
  149.             return PLUGIN_HANDLED;
  150.         }
  151.      
  152.         if ( !g_iBombSiteEntity[ BOMBSITE_A ] || !g_iBombSiteEntity[ BOMBSITE_B ] )
  153.         {
  154.             console_print( id , "* Bombalerako Lezaras: Ezen a palyan nem engedelyezett!" );
  155.             return PLUGIN_HANDLED;
  156.         }
  157.      
  158.         new szSite[ 3 ] , szState[ 3 ] , iState , BombSites:bsSite;
  159.         read_argv( 1 , szSite , charsmax( szSite ) );
  160.         read_argv( 2 , szState , charsmax( szState ) );
  161.      
  162.         iState = str_to_num( szState );
  163.      
  164.         if ( ( strlen( szSite ) > 1 ) || !is_str_num( szState ) || !( 0 <= iState <= 1 ) )
  165.             szSite[ 0 ] = 'X';
  166.         else
  167.             szSite[ 0 ] = toupper( szSite[ 0 ] );
  168.      
  169.         switch ( szSite[ 0 ] )
  170.         {
  171.             case 'A':
  172.             {
  173.                 bsSite = BOMBSITE_A;
  174.             }
  175.             case 'B':
  176.             {
  177.                 bsSite = BOMBSITE_B;
  178.             }
  179.             default:
  180.             {
  181.                 console_print( id , "* Bombalerako lezarasa: Ismeretlen argumentum! Megfelelo: 'fb_setbombsite a\b 0\1'" );
  182.                 return PLUGIN_HANDLED;
  183.             }
  184.         }
  185.      
  186.         SetBombSiteLock( bsSite , bool:iState );
  187.      
  188.         console_print( id , "* Bombalerako (%s) jelenleg %s" , szSite , iState ? "szabad" : "zart" );
  189.      
  190.         set_hudmessage( 255 , 255 , 255 , -1.0 , 0.65 , 0 , 3.0 , 3.0 , .channel = -1 );
  191.         show_hudmessage( 0 , "Bombalerako (%s) jelenleg %s" , szSite , iState ? "szabad" : "zart" );
  192.      
  193.         return PLUGIN_HANDLED;
  194.     }
  195.      
  196.     public ShowBombSiteMenu( id , AdminLevel )
  197.     {
  198.         if ( !( get_user_flags( id ) & AdminLevel ) )
  199.         {
  200.             console_print( id , "* Nincs engedelyed ehhez a parancshoz." );
  201.             return PLUGIN_HANDLED;
  202.         }
  203.      
  204.         if ( !g_iBombSiteEntity[ BOMBSITE_A ] || !g_iBombSiteEntity[ BOMBSITE_B ] )
  205.         {
  206.             console_print( id , "* Bombalerako Lezaras: Ezen a palyan nem engedelyezett!" );
  207.             return PLUGIN_HANDLED;
  208.         }
  209.      
  210.         new iMenu = menu_create( "Bombalerako zarolas menu" , "MenuHandler" );
  211.         new iCallBack = menu_makecallback( "MenuCallBack" );
  212.      
  213.         menu_additem( iMenu , "A zarolasa" , .callback = iCallBack );
  214.         menu_additem( iMenu , "B zarolasa" , .callback = iCallBack );
  215.         menu_additem( iMenu , "A feloldasa" , .callback = iCallBack );
  216.         menu_additem( iMenu , "B feloldasa" , .callback = iCallBack );
  217.         menu_additem( iMenu , "A & B zarolasa" , .callback = iCallBack );
  218.         menu_additem( iMenu , "A & B feloldasa" , .callback = iCallBack );
  219.      
  220.         menu_display( id , iMenu );
  221.      
  222.         return PLUGIN_HANDLED;
  223.     }
  224.      
  225.     public MenuCallBack( id , iMenu, iItem )
  226.     {  
  227.         new iRetVal;
  228.      
  229.         switch ( iItem )
  230.         {
  231.             case 0: iRetVal = g_bBombSiteStatus[ BOMBSITE_A ] ? ITEM_DISABLED : ITEM_ENABLED;
  232.             case 1: iRetVal = g_bBombSiteStatus[ BOMBSITE_B ] ? ITEM_DISABLED : ITEM_ENABLED;
  233.             case 2: iRetVal = g_bBombSiteStatus[ BOMBSITE_A ] ? ITEM_ENABLED : ITEM_DISABLED;
  234.             case 3: iRetVal = g_bBombSiteStatus[ BOMBSITE_B ] ? ITEM_ENABLED : ITEM_DISABLED;
  235.             case 4: iRetVal = g_bBombSiteStatus[ BOMBSITE_A ] && g_bBombSiteStatus[ BOMBSITE_B ] ? ITEM_DISABLED : ITEM_ENABLED;
  236.             case 5: iRetVal = g_bBombSiteStatus[ BOMBSITE_A ] || g_bBombSiteStatus[ BOMBSITE_B ] ? ITEM_ENABLED : ITEM_DISABLED;
  237.         }  
  238.      
  239.         return iRetVal;
  240.     }
  241.      
  242.     public MenuHandler( id , iMenu , iItem )
  243.     {
  244.         if( iItem == MENU_EXIT )
  245.         {
  246.             menu_destroy( iMenu );
  247.             return PLUGIN_HANDLED;
  248.         }
  249.      
  250.         set_hudmessage( 255 , 255 , 255 , -1.0 , 0.65 , 0 , 3.0 , 3.0 , .channel = -1 );
  251.      
  252.         switch ( iItem )
  253.         {
  254.             case 0:
  255.             {
  256.                 SetBombSiteLock( BOMBSITE_A , true );
  257.                 show_hudmessage( 0 , "Bombalerako (A) lezarva" );
  258.             }
  259.             case 1:
  260.             {
  261.                 SetBombSiteLock( BOMBSITE_B , true );
  262.                 show_hudmessage( 0 , "Bombalerako (B) lezarva" );
  263.             }
  264.             case 2:
  265.             {
  266.                 SetBombSiteLock( BOMBSITE_A , false );
  267.                 show_hudmessage( 0 , "Bombalerako (A) feloldva" );
  268.             }
  269.             case 3:
  270.             {
  271.                 SetBombSiteLock( BOMBSITE_B , false );
  272.                 show_hudmessage( 0 , "Bombalerako (B) feloldva" );
  273.             }
  274.             case 4:
  275.             {
  276.                 SetBombSiteLock( BOMBSITE_A , true );
  277.                 SetBombSiteLock( BOMBSITE_B , true );
  278.                 show_hudmessage( 0 , "Bombalerako (A & B) lezarva" );
  279.             }
  280.             case 5:
  281.             {
  282.                 SetBombSiteLock( BOMBSITE_A , false );
  283.                 SetBombSiteLock( BOMBSITE_B , false );
  284.                 show_hudmessage( 0 , "Bombalerako (A & B) feloldva" );
  285.             }
  286.         }
  287.      
  288.         menu_destroy( iMenu );
  289.      
  290.         return PLUGIN_HANDLED;
  291.     }
  292.      
  293.     public fw_HUDEntThink( iEntity )
  294.     {
  295.         if( g_bPlayerHoldingBomb && ( g_bBombSiteStatus[ BOMBSITE_A ] || g_bBombSiteStatus[ BOMBSITE_B ] ) && ( iEntity == g_iHUDEntity ) && is_user_alive( g_iPlayerWithBomb ) )
  296.         {
  297.             set_hudmessage( 255 , 255 , 255 , -1.0 , 0.87 , 0 , 1.0 , 1.0 , .channel = -1 );
  298.             show_hudmessage( g_iPlayerWithBomb , "Bombalerako%s %s%s%s %s jelenleg lezarva!" ,  g_bBombSiteStatus[ BOMBSITE_A ] && g_bBombSiteStatus[ BOMBSITE_B ] ? "s" : ""  ,
  299.                                                     g_bBombSiteStatus[ BOMBSITE_A ] ? "A" : "" ,
  300.                                                     g_bBombSiteStatus[ BOMBSITE_A ] && g_bBombSiteStatus[ BOMBSITE_B ] ? " & " : "" ,
  301.                                                     g_bBombSiteStatus[ BOMBSITE_B ] ? "B" : "" ,
  302.                                                     g_bBombSiteStatus[ BOMBSITE_A ] && g_bBombSiteStatus[ BOMBSITE_B ] ? "are" : "is" );
  303.      
  304.             entity_set_float( g_iHUDEntity , EV_FL_nextthink , ( get_gametime() + 1.0 ) );
  305.         }
  306.     }
  307.      
  308.     SetBombSiteLock( BombSites:bsBombSite , bool:bLockState )  
  309.     {
  310.         entity_set_int( g_iBombSiteEntity[ bsBombSite ] , EV_INT_solid , bLockState ? SOLID_NOT : SOLID_TRIGGER );
  311.         g_bBombSiteStatus[ bsBombSite ] = bLockState;
  312.      
  313.         if ( bLockState )
  314.             entity_set_float( g_iHUDEntity , EV_FL_nextthink , ( get_gametime() + 1.0 ) );
  315.     }


Hozzászólás jelentése
Vissza a tetejére
   
Hozzászólások megjelenítése:  Rendezés  
Új téma nyitása  Hozzászólás a témához  [ 7 hozzászólás ] 


Ki van itt

Jelenlévő fórumozók: nincs regisztrált felhasználó valamint 4 vendég


Nyithatsz új témákat ebben a fórumban.
Válaszolhatsz egy témára ebben a fórumban.
Nem szerkesztheted a hozzászólásaidat ebben a fórumban.
Nem törölheted a hozzászólásaidat ebben a fórumban.
Nem küldhetsz csatolmányokat ebben a fórumban.

Keresés:
Ugrás:  
Powered by phpBB® Forum Software © phpBB Limited
Magyar fordítás © Magyar phpBB Közösség
Portal: Kiss Portal Extension © Michael O'Toole