Raised This Month: $51 Target: $400
 12% 

[REQ] Case every 5 rounds


Post New Thread Reply   
 
Thread Tools Display Modes
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 05-10-2020 , 07:34   Re: [REQ] Case every 5 rounds
Reply With Quote #11

Nothing special. MAX_PLAYERS is defined in versions newer than 1.8.2, so there's no need to redefine it.
__________________

Last edited by OciXCrom; 05-10-2020 at 07:35.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-10-2020 , 11:12   Re: [REQ] Case every 5 rounds
Reply With Quote #12

Using #define, as long as the value matches what is defined in 1.9, you will get no warnings or errors from the compiler by re-defining it. So to make your plugin compatible with all versions of AMX-X, there is no harm always including #define MAX_PLAYERS 32, at least until the majority of people have changed over.
__________________
Bugsy is offline
alferd
Veteran Member
Join Date: Dec 2019
Location: Iran is Always Eternal
Old 06-02-2020 , 15:52   Re: [REQ] Case every 5 rounds
Reply With Quote #13

Quote:
Originally Posted by Bugsy View Post
PHP Code:

#include <amxmodx>
#include <cstrike>
#include <fun>

new const Version[] = "0.1";

new 
g_RoundCountMAX_PLAYERS ];
new 
g_BoughtDeagle g_BoughtAK47;
new 
g_pResetRounds;

public 
plugin_init() 
{
    
register_plugin"Free Weapons" Version "bugsy" );
    
    
register_concmd"say /freewpn" "ShowMenu" );
    
    
register_event"HLTV" "NewRound" "a" "1=0" "2=0" );
    
    
g_pResetRounds register_cvar"freeweapon_rounds" "5" );
}

public 
client_connectid )
{
    
g_RoundCountid ] = 0;
    
g_BoughtDeagle &= ~( << ( id 31 ) );
    
g_BoughtAK47 &= ~( << ( id 31 ) );
}

public 
NewRound()
{
    new 
iPlayers32 ] , iNum iPlayer;
    new 
iResetRounds get_pcvar_numg_pResetRounds );
    
    
g_BoughtDeagle 0;
    
    
get_playersiPlayers iNum "ch" );
    
    for ( new 
iNum i++ )
    {
        
iPlayer iPlayers];
        
        
g_RoundCountiPlayer ]++;
        
        if ( !( 
g_RoundCountiPlayer ] % iResetRounds ) )
            
g_BoughtAK47 &= ~( << ( iPlayer 31 ) );
    }
}

public 
ShowMenuid )
{
    new 
iMenu menu_create"Free Weapon" "MenuHandler" );  
    new 
iCallBack menu_makecallback"MenuCallBack" );
    new 
szAKMenu40 ] , szRoundsLeft10 ];
    new 
iResetRounds get_pcvar_numg_pResetRounds );
    
    if ( 
g_BoughtAK47 & ( << ( id 31 ) ) )
        
formatexszRoundsLeft charsmaxszRoundsLeft ) , " - %d left" iResetRounds - ( g_RoundCountid ] % iResetRounds ) );
        
    
formatexszAKMenu charsmaxszAKMenu ) , "AK47 [ 1 every %d round%s ]%s" iResetRounds , ( iResetRounds == ) ? "" "s" szRoundsLeft );
    
menu_additemiMenu "Deagle [ 1 every round ]" , .callback iCallBack );
    
menu_additemiMenu szAKMenu , .callback iCallBack );
    
menu_setpropiMenuMPROP_EXITMEXIT_ALL ); 
    
    
menu_displayid iMenu ); 
    
    return 
PLUGIN_HANDLED;
}

public 
MenuCallBackid iMenu iItem )
{    
    new 
iRetVal;
    
    switch ( 
iItem )
    {
        case 
0iRetVal = ( user_has_weaponid CSW_DEAGLE ) || ( g_BoughtDeagle & ( << ( id 31 ) ) ) ) ? ITEM_DISABLED ITEM_ENABLED
        case 
1iRetVal = ( user_has_weaponid CSW_AK47 ) || ( g_BoughtAK47 & ( << ( id 31 ) ) ) ) ? ITEM_DISABLED ITEM_ENABLED
    }    
    
    return 
iRetVal;
}

public 
MenuHandlerid menu item )
{
    if ( 
item == MENU_EXIT 
    { 
        
menu_destroymenu );
        return 
PLUGIN_HANDLED
    } 
    
    if ( !
is_user_aliveid ) )
        return 
PLUGIN_HANDLED;
    
    
strip_user_weaponsid );
    
give_itemid "weapon_knife" );

    switch( 
item 
    {
        case 
0
        {
            
give_itemid "weapon_deagle" );
            
cs_set_user_bpammoid CSW_DEAGLE 30 );
            
            
g_BoughtDeagle |= ( << ( id 31 ) );
        }
        case 
1
        {
            
give_itemid "weapon_ak47" );
            
cs_set_user_bpammoid CSW_AK47 90 );
            
            
g_BoughtAK47 |= ( << ( id 31 ) );
        }
    }
    
    return 
PLUGIN_CONTINUE;

I want to be able to use the following plugin only once every 5 rounds

Code:
#include <amxmodx> #include <amxmisc> #include <cash> public plugin_init() {     register_clcmd("say /getcash", "getcash") //Every 5 rounds once } public getcash(id) {     set_user_cash(id, get_user_cash(id) + 100)         client_print(id, print_chat," Get User 100 Cash") }

Can you help me?
alferd is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-03-2020 , 22:52   Re: [REQ] Case every 5 rounds
Reply With Quote #14

I also fixed the logic being used for AK. It would previously allow a player to buy an AK on round 4, and then again on round 5 when the round counter was reset. It will now ensure 5 rounds between each get AK and cash.

Untested
PHP Code:

#include <amxmodx>
#include <cstrike>
#include <fun>
#include <cash>

new const Version[] = "0.2";

new 
g_RoundCountAKMAX_PLAYERS ];
new 
g_RoundCountCashMAX_PLAYERS ];
new 
g_BoughtDeagle g_BoughtAK47 g_GotCash;
new 
g_pResetRounds;

public 
plugin_init() 
{
    
register_plugin"Free Weapons" Version "bugsy" );
    
    
register_concmd"say /freewpn" "ShowMenu" );
    
register_clcmd"say /getcash" "GetCash" );
    
    
register_event"HLTV" "NewRound" "a" "1=0" "2=0" );
    
    
g_pResetRounds register_cvar"freeweapon_rounds" "5" );
}

public 
client_connectid )
{
    
g_RoundCountAKid ] = 0;
    
g_RoundCountCashid ] = 0;
    
    
g_BoughtDeagle &= ~( << ( id 31 ) );
    
g_BoughtAK47 &= ~( << ( id 31 ) );
    
g_GotCash &= ~( << ( id 31 ) );
}

public 
NewRound()
{
    new 
iPlayers32 ] , iNum iPlayer;
    new 
iResetRounds get_pcvar_numg_pResetRounds );
    
    
g_BoughtDeagle 0;
    
    
get_playersiPlayers iNum "ch" );
    
    for ( new 
iNum i++ )
    {
        
iPlayer iPlayers];
        
        if ( ++
g_RoundCountAKiPlayer ] >= iResetRounds )
            
g_BoughtAK47 &= ~( << ( iPlayer 31 ) );
            
        if ( ++
g_RoundCountCashiPlayer ] >= iResetRounds )    
            
g_GotCash &= ~( << ( iPlayer 31 ) );
    }
}

public 
GetCashid )
{
    if ( !( 
g_GotCash & ( << ( id 31 ) ) ) )
    {
        
set_user_cashid get_user_cashid ) + 100 );
        
client_printid print_chat " Get User 100 Cash" );
        
g_GotCash |= ( << ( id 31 ) );
        
g_RoundCountCashid ] = 0;
    }
    else
    {
        
client_printid print_chat " This command can only be used every 5 rounds." );
    }

    return 
PLUGIN_HANDLED;
}

public 
ShowMenuid )
{
    new 
iMenu menu_create"Free Weapon" "MenuHandler" );  
    new 
iCallBack menu_makecallback"MenuCallBack" );
    new 
szAKMenu40 ] , szRoundsLeft10 ];
    new 
iResetRounds get_pcvar_numg_pResetRounds );
    
    if ( 
g_BoughtAK47 & ( << ( id 31 ) ) )
        
formatexszRoundsLeft charsmaxszRoundsLeft ) , " - %d left" iResetRounds g_RoundCountAKid ] );
        
    
formatexszAKMenu charsmaxszAKMenu ) , "AK47 [ 1 every %d round%s ]%s" iResetRounds , ( iResetRounds == ) ? "" "s" szRoundsLeft );
    
menu_additemiMenu "Deagle [ 1 every round ]" , .callback iCallBack );
    
menu_additemiMenu szAKMenu , .callback iCallBack );
    
menu_setpropiMenuMPROP_EXITMEXIT_ALL ); 
    
    
menu_displayid iMenu ); 
    
    return 
PLUGIN_HANDLED;
}

public 
MenuCallBackid iMenu iItem )
{    
    new 
iRetVal;
    
    switch ( 
iItem )
    {
        case 
0iRetVal = ( user_has_weaponid CSW_DEAGLE ) || ( g_BoughtDeagle & ( << ( id 31 ) ) ) ) ? ITEM_DISABLED ITEM_ENABLED
        case 
1iRetVal = ( user_has_weaponid CSW_AK47 ) || ( g_BoughtAK47 & ( << ( id 31 ) ) ) ) ? ITEM_DISABLED ITEM_ENABLED
    }    
    
    return 
iRetVal;
}

public 
MenuHandlerid menu item )
{
    if ( 
item == MENU_EXIT 
    { 
        
menu_destroymenu );
        return 
PLUGIN_HANDLED
    } 
    
    if ( !
is_user_aliveid ) )
        return 
PLUGIN_HANDLED;
    
    
strip_user_weaponsid );
    
give_itemid "weapon_knife" );

    switch( 
item 
    {
        case 
0
        {
            
give_itemid "weapon_deagle" );
            
cs_set_user_bpammoid CSW_DEAGLE 30 );
            
            
g_BoughtDeagle |= ( << ( id 31 ) );
        }
        case 
1
        {
            
give_itemid "weapon_ak47" );
            
cs_set_user_bpammoid CSW_AK47 90 );
            
            
g_BoughtAK47 |= ( << ( id 31 ) );
            
g_RoundCountAKid ] = 0;
        }
    }
    
    return 
PLUGIN_CONTINUE;

__________________

Last edited by Bugsy; 06-03-2020 at 23:01.
Bugsy is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:35.


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