Raised This Month: $ Target: $400
 0% 

Help Edit with Limiting Weapon Giving Per Round


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Kitami
Senior Member
Join Date: Jun 2006
Location: Toronto
Old 07-31-2009 , 21:41   Help Edit with Limiting Weapon Giving Per Round
Reply With Quote #1

This script is to give admins an awp with full bullets and take away any primary weapons, I was wondering if someone could edit this to make it so you can only use this command once per round? Also I have this same script for the M4 & AK I was wondering if its better to use 3 different scripts or merge them all together?

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>
#include <fakemeta>
 
#define PLUGIN    "Test"
#define AUTHOR    "Jim"
#define VERSION    "1.0"
 
#define ACCESS_FLAG ADMIN_VOTE
 
new const pri[18] =
{
    
CSW_AK47,
    
CSW_AUG,
    
CSW_AWP,
    
CSW_FAMAS,
    
CSW_G3SG1,
    
CSW_GALI,
    
CSW_M249,
    
CSW_M3,
    
CSW_M4A1,
    
CSW_MAC10,
    
CSW_MP5NAVY,
    
CSW_P90,
    
CSW_SCOUT,
    
CSW_SG550,
    
CSW_SG552,
    
CSW_TMP,
    
CSW_UMP45,
    
CSW_XM1014
}
 
public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("amx_awpme""give_awp"ACCESS_FLAG"give an awp")
}
 
public 
give_awp(idlvlcid)
{
    if(!
cmd_access(idlvlcid1))
        return 
PLUGIN_HANDLED
    
    
if(is_user_alive(id))
    {
        new 
weapons pev(idpev_weapons) & ~(1<<31)
        for(new 
i18; ++i)
        {
            if(
weapons & (1<<pri[i]))
            {
                new 
wpname[20]
                
get_weaponname(pri[i], wpname19)
                
engclient_cmd(id"drop"wpname)
                break
            }
        }
        
        
give_item(id"weapon_awp")
        
cs_set_user_bpammo(idCSW_AWP30
    }
    return 
PLUGIN_HANDLED

__________________
You know what I'd like to be? I mean if I had my goddamn choice, I'd just be the catcher in the rye and all.
Kitami is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-31-2009 , 23:18   Re: Help Edit with Limiting Weapon Giving Per Round
Reply With Quote #2

Edit: All 3 weapon commands can now be used in each round. The per-round command limit is controlled via cvar.

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <fakemeta>
#include <fakemeta_util>

#define m_rgpPlayerItems_slot1    368

#define ACCESS_FLAG        ADMIN_VOTE

enum _:AmmoOffsets
{
    
OFFSET_AWM_AMMO 377,
    
OFFSET_SCOUT_AMMO,
    
OFFSET_PARA_AMMO,
    
OFFSET_FAMAS_AMMO,
    
OFFSET_M3_AMMO,
    
OFFSET_USP_AMMO,
    
OFFSET_FIVESEVEN_AMMO,
    
OFFSET_DEAGLE_AMMO,
    
OFFSET_P228_AMMO,
    
OFFSET_GLOCK_AMMO,
    
OFFSET_FLASH_AMMO,
    
OFFSET_HE_AMMO,
    
OFFSET_SMOKE_AMMO,
    
OFFSET_C4_AMMO
};

enum _:WeaponCvar
{
    
AWP,
    
AK47,
    
M4A1
}

new 
g_iWeaponsGiven33 ][ ];
new 
g_iMaxPlayers;
new 
g_pCVar];

public 
plugin_init() 
{
    
register_plugin"WeaponMe" "1.0" "bugsy" );
    
    
register_clcmd"amx_awpme" "GiveAwp" ACCESS_FLAG "give an awp" );
    
register_clcmd"amx_akme" "GiveAk" ACCESS_FLAG "give an ak47" );
    
register_clcmd"amx_m4me" "GiveM4" ACCESS_FLAG "give an m4a1" );
    
    
register_event"HLTV" "fw_EvNewRound" "a" "1=0" "2=0" );
    
    
g_pCVarAWP ] = register_cvar"wm_awp" "1" );
    
g_pCVarAK47 ] = register_cvar"wm_ak47" "1" );
    
g_pCVarM4A1 ] = register_cvar"wm_m4a1" "1" );
    
    
g_iMaxPlayers get_maxplayers();
}

public 
fw_EvNewRound()
{
    for ( new 
id id <= g_iMaxPlayers id++ )
    {
        
g_iWeaponsGivenid ][ AWP ] = 0;
        
g_iWeaponsGivenid ][ AK47 ] = 0;
        
g_iWeaponsGivenid ][ M4A1 ] = 0;
    }
}

public 
GiveAwpid level cid )
{
    if ( !
cmd_access(idlevelcid1) || !is_user_aliveid ) )
        return 
PLUGIN_HANDLED;
        
    static 
iCVariCVar get_pcvar_numg_pCVarAWP ] );
    
    if ( 
g_iWeaponsGivenid ][ AWP ] >= iCVar )
    {
        
client_printid print_chat "* You may only use this command %d time%s per round." iCVar , ( iCVar ) ? "s" "" );
        return 
PLUGIN_HANDLED;
    }
    
    
CmdTransactionid "weapon_awp" 30 );
    
    return 
PLUGIN_HANDLED;
}

public 
GiveAkid level cid )
{
    if ( !
cmd_access(idlevelcid1) || !is_user_aliveid ) )
        return 
PLUGIN_HANDLED;
        
    static 
iCVariCVar get_pcvar_numg_pCVarAK47 ] );
    
    if ( 
g_iWeaponsGivenid ][ AK47 ] >= iCVar )
    {
        
client_printid print_chat "* You may only use this command %d time%s per round." iCVar , ( iCVar ) ? "s" "" );
        return 
PLUGIN_HANDLED;
    }
    
    
CmdTransactionid "weapon_ak47" 90 );
    
    return 
PLUGIN_HANDLED;
}

public 
GiveM4id level cid )
{
    if ( !
cmd_access(idlevelcid1) || !is_user_aliveid ) )
        return 
PLUGIN_HANDLED;
        
    static 
iCVariCVar get_pcvar_numg_pCVarM4A1 ] );
    
    if ( 
g_iWeaponsGivenid ][ M4A1 ] >= iCVar )
    {
        
client_printid print_chat "* You may only use this command %d time%s per round." iCVar , ( iCVar ) ? "s" "" );
        return 
PLUGIN_HANDLED;
    }
    
    
CmdTransactionid "weapon_m4a1" 90 );
    
    return 
PLUGIN_HANDLED;
}

public 
CmdTransactionid szGiveWeapon[] , iMaxBPAmmo )
{
    static 
szWeapon20 ] , iPrimaryWeapon iGiveWeaponID;
    
    
iPrimaryWeapon get_pdata_cbaseid m_rgpPlayerItems_slot1 );
    
    if ( 
iPrimaryWeapon != -)
    {
        
peviPrimaryWeapon pev_classname szWeapon 19 );
        
engclient_cmdid "drop" szWeapon );
    }
    
    
iGiveWeaponID get_weaponidszGiveWeapon );
    
fm_give_itemid szGiveWeapon );
    
fm_set_user_bpammoid iGiveWeaponID iMaxBPAmmo );
    
    switch ( 
iGiveWeaponID )
    {
        case 
CSW_AWPg_iWeaponsGivenid ][ AWP ]++;
        case 
CSW_AK47g_iWeaponsGivenid ][ AK47 ]++;
        case 
CSW_M4A1g_iWeaponsGivenid ][ M4A1 ]++;
    }
    
    return 
PLUGIN_HANDLED;
}

public 
fm_set_user_bpammo(indexweaponamount)
{
    new 
offset;
    
    switch(
weapon)
    {
        case 
CSW_AWPoffset OFFSET_AWM_AMMO;
        case 
CSW_SCOUT,CSW_AK47,CSW_G3SG1offset OFFSET_SCOUT_AMMO;
        case 
CSW_M249offset OFFSET_PARA_AMMO;
        case 
CSW_M4A1,CSW_FAMAS,CSW_AUG,CSW_SG550,CSW_GALI,CSW_SG552offset OFFSET_FAMAS_AMMO;
        case 
CSW_M3,CSW_XM1014offset OFFSET_M3_AMMO;
        case 
CSW_USP,CSW_UMP45,CSW_MAC10offset OFFSET_USP_AMMO;
        case 
CSW_FIVESEVEN,CSW_P90offset OFFSET_FIVESEVEN_AMMO;
        case 
CSW_DEAGLEoffset OFFSET_DEAGLE_AMMO;
        case 
CSW_P228offset OFFSET_P228_AMMO;
        case 
CSW_GLOCK18,CSW_MP5NAVY,CSW_TMP,CSW_ELITEoffset OFFSET_GLOCK_AMMO;
        case 
CSW_FLASHBANGoffset OFFSET_FLASH_AMMO;
        case 
CSW_HEGRENADEoffset OFFSET_HE_AMMO;
        case 
CSW_SMOKEGRENADEoffset OFFSET_SMOKE_AMMO;
        case 
CSW_C4offset OFFSET_C4_AMMO;

        default:
        {
            new 
invalidMsg[27];
            
formatex(invalidMsg,26,"Invalid weapon id %d",weapon);
            
set_fail_state(invalidMsg);
            
            return 
0;
        }
    }
    
    
set_pdata_int(index,offset,amount);
    
    return 
1;

__________________

Last edited by Bugsy; 08-02-2009 at 00:43.
Bugsy is offline
Kitami
Senior Member
Join Date: Jun 2006
Location: Toronto
Old 08-01-2009 , 01:18   Re: Help Edit with Limiting Weapon Giving Per Round
Reply With Quote #3

Alright now where is it defined as one per round?

Quote:
!cmd_access(id, level, cid, 1
I am just wondering as I do try my best to edit .sma files for myself so every little bit of knowledge helps.

Once again THANKS SO MUCH!!! I will be testing it later tonight
__________________
You know what I'd like to be? I mean if I had my goddamn choice, I'd just be the catcher in the rye and all.
Kitami is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-01-2009 , 08:59   Re: Help Edit with Limiting Weapon Giving Per Round
Reply With Quote #4

Quote:
Originally Posted by Kitami View Post
Alright now where is it defined as one per round?
It is hard-coded for now but I will make it defined by a cvar if you want. Also, do you want each weapon command to be available per round or just one of the three per round?
__________________
Bugsy is offline
Kitami
Senior Member
Join Date: Jun 2006
Location: Toronto
Old 08-01-2009 , 20:10   Re: Help Edit with Limiting Weapon Giving Per Round
Reply With Quote #5

I wanted each to be available per round, and if you do put in a cvar in the sma that would be perfect
__________________
You know what I'd like to be? I mean if I had my goddamn choice, I'd just be the catcher in the rye and all.
Kitami is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-02-2009 , 00:11   Re: Help Edit with Limiting Weapon Giving Per Round
Reply With Quote #6

Quote:
Originally Posted by Kitami View Post
I wanted each to be available per round, and if you do put in a cvar in the sma that would be perfect
Done, see above code.
__________________
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 08:04.


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