Raised This Month: $ Target: $400
 0% 

Give Weapon By Command


Post New Thread Reply   
 
Thread Tools Display Modes
Electric Boy
Member
Join Date: Jun 2017
Old 06-02-2017 , 21:11   Re: Give Weapon By Command
Reply With Quote #11

Quote:
Originally Posted by Natsheh View Post
I updated the code & iwrote it on the phone and you should br able to give ammo.
Still man Its not fixed
Electric Boy is offline
Electric Boy
Member
Join Date: Jun 2017
Old 06-02-2017 , 21:12   Re: Give Weapon By Command
Reply With Quote #12

Quote:
Originally Posted by Natsheh View Post
I updated the code & iwrote it on the phone and you should br able to give ammo.
How to use?
Electric Boy is offline
Electric Boy
Member
Join Date: Jun 2017
Old 06-02-2017 , 21:13   Re: Give Weapon By Command
Reply With Quote #13

Quote:
Originally Posted by Natsheh View Post
Fyi houssam its not useless if that what he requested


On topic cmd that give wpns

PHP Code:
#include amxmodx
#include amxmisc
#include fun
#include cstrike

public plugin_init() {

    
register_plugin("CMD GIVE WEAPON""1.0""Natsheh")
    
register_concmd("amx_weapon""cmd_wpn"ADMIN_KICK)
    
}

public 
cmd_wpn(idlevelcid)
{
       if(!
cmd_access(idlevelcid3)) return 1;
       new 
szTarget[32], szWpn[24], szAmmo[4];
       
read_argv(1szTargetcharsmax(szTarget))
       
read_argv(2szWpn23)
       
read_argv(3szAmmo3)
       new 
player cmd_target(idszTarget, ~CMDTARGET_OBEY_IMMUNITY)
       
format(szWpncharsmax(szWpn), "weapon_%s"szWpn)
       
strtolower(szWpn)
       if(!
player || !get_weaponid(szWpn)) return 1;
       
give_item(playerszWpn)
       
cs_set_user_bpammo(id,get_weaponid(szWpn),str_to_num(szAmmo))
       return 
1;

Example amx_weapon "Natsheh" "Ak47" "90" will give player nats.... An ak47
Rep+ Thanks man
Electric Boy is offline
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 06-03-2017 , 07:44   Re: Give Weapon By Command
Reply With Quote #14

Or even better:
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <cstrike>
#include <fun>

public plugin_init( )
{
    
register_plugin("amx_give_weapon""1.0""Craxor");
    
register_concmd"amx_give_weapon""_givecmd"ADMIN_KICK"amx_give_weapon <Name> <weapon_*  Name> <Ammo> <BpAmmo>" );
}

public 
_givecmdidlevelcid )
{
    if( !
cmd_accessidlevelcid) )
    {
        return 
PLUGIN_HANDLED;
    }
    
    new 
szArg1[32];
    new 
szArg2[20];
    new 
szArg3[5];
    new 
szArg4[5];

    
read_argv1szArg1charsmaxszArg1 ) );    
    
read_argv2szArg2charsmaxszArg2 ) );
    
read_argv3szArg3charsmaxszArg3 ) );
    
read_argv4szArg4charsmaxszArg4 ) );

    new 
player cmd_targetidszArg1, ~CMDTARGET_OBEY_IMMUNITY CMDTARGET_ONLY_ALIVE );
    new 
iWeaponID get_weaponidszArg2 );

    if( !
player || !iWeaponID )
    {
        return 
PLUGIN_HANDLED;
    }

    new 
szWeaponName[20];
    new 
szAdminName[32]; get_user_nameidszAdminNamecharsmaxszAdminName ) );

    
give_user_weapon player iWeaponIDstr_to_numszArg3 ), str_to_numszArg4 ), szWeaponNamecharsmaxszWeaponName ) );
    
client_printplayerprint_chat"Admin '%s' give you the weapon: %s"szAdminNameszWeaponName );

    return 
PLUGIN_HANDLED;
}


give_user_weaponindex iWeaponTypeID iClip=iBPAmmo=szWeapon[]="" maxchars=)
{
    if ( !( 
CSW_P228 <= iWeaponTypeID <= CSW_P90 ) || ( iClip ) || ( iBPAmmo ) || !is_user_aliveindex ) )
        return -
1;
    
    new 
szWeaponName20 ] , iWeaponEntity bool:bIsGrenade;
    
    const 
GrenadeBits = ( ( << CSW_HEGRENADE ) | ( << CSW_FLASHBANG ) | ( << CSW_SMOKEGRENADE ) | ( << CSW_C4 ) );
    
    if ( ( 
bIsGrenade bool:!!( GrenadeBits & ( << iWeaponTypeID ) ) ) )
        
iClip clampiClip iClip iBPAmmo );
    
    
get_weaponnameiWeaponTypeID szWeaponName charsmaxszWeaponName ) );
    
    if ( ( 
iWeaponEntity user_has_weaponindex iWeaponTypeID ) ? find_ent_by_owner( -szWeaponName index ) : give_itemindex szWeaponName ) ) > )
    {
        if ( 
iWeaponTypeID != CSW_KNIFE )
        {
            if ( 
iClip && !bIsGrenade )
                
cs_set_weapon_ammoiWeaponEntity iClip );
        
            if ( 
iWeaponTypeID == CSW_C4 
                
cs_set_user_plantindex );
            else
                
cs_set_user_bpammoindex iWeaponTypeID bIsGrenade iClip iBPAmmo ); 
        }
        
        if ( 
maxchars )
            
copyszWeapon maxchars szWeaponName[7] );
    }
    
    return 
iWeaponEntity;

Example:

amx_give_weapon Craxor weapon_m4a1 30 90

4 parameters
1 - name of who to get weapon
2 - weapon name ( ex, weapon_awp )
3 - Ammo (bullets)
4 - Back Pack Ammo ( realoading bullets )
__________________
Project: Among Us

Last edited by Craxor; 06-03-2017 at 08:08.
Craxor is offline
Send a message via ICQ to Craxor
Electric Boy
Member
Join Date: Jun 2017
Old 06-03-2017 , 09:09   Re: Give Weapon By Command
Reply With Quote #15

Quote:
Originally Posted by Craxor View Post
Or even better:
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <cstrike>
#include <fun>

public plugin_init( )
{
    
register_plugin("amx_give_weapon""1.0""Craxor");
    
register_concmd"amx_give_weapon""_givecmd"ADMIN_KICK"amx_give_weapon <Name> <weapon_*  Name> <Ammo> <BpAmmo>" );
}

public 
_givecmdidlevelcid )
{
    if( !
cmd_accessidlevelcid) )
    {
        return 
PLUGIN_HANDLED;
    }
    
    new 
szArg1[32];
    new 
szArg2[20];
    new 
szArg3[5];
    new 
szArg4[5];

    
read_argv1szArg1charsmaxszArg1 ) );    
    
read_argv2szArg2charsmaxszArg2 ) );
    
read_argv3szArg3charsmaxszArg3 ) );
    
read_argv4szArg4charsmaxszArg4 ) );

    new 
player cmd_targetidszArg1, ~CMDTARGET_OBEY_IMMUNITY CMDTARGET_ONLY_ALIVE );
    new 
iWeaponID get_weaponidszArg2 );

    if( !
player || !iWeaponID )
    {
        return 
PLUGIN_HANDLED;
    }

    new 
szWeaponName[20];
    new 
szAdminName[32]; get_user_nameidszAdminNamecharsmaxszAdminName ) );

    
give_user_weapon player iWeaponIDstr_to_numszArg3 ), str_to_numszArg4 ), szWeaponNamecharsmaxszWeaponName ) );
    
client_printplayerprint_chat"Admin '%s' give you the weapon: %s"szAdminNameszWeaponName );

    return 
PLUGIN_HANDLED;
}


give_user_weaponindex iWeaponTypeID iClip=iBPAmmo=szWeapon[]="" maxchars=)
{
    if ( !( 
CSW_P228 <= iWeaponTypeID <= CSW_P90 ) || ( iClip ) || ( iBPAmmo ) || !is_user_aliveindex ) )
        return -
1;
    
    new 
szWeaponName20 ] , iWeaponEntity bool:bIsGrenade;
    
    const 
GrenadeBits = ( ( << CSW_HEGRENADE ) | ( << CSW_FLASHBANG ) | ( << CSW_SMOKEGRENADE ) | ( << CSW_C4 ) );
    
    if ( ( 
bIsGrenade bool:!!( GrenadeBits & ( << iWeaponTypeID ) ) ) )
        
iClip clampiClip iClip iBPAmmo );
    
    
get_weaponnameiWeaponTypeID szWeaponName charsmaxszWeaponName ) );
    
    if ( ( 
iWeaponEntity user_has_weaponindex iWeaponTypeID ) ? find_ent_by_owner( -szWeaponName index ) : give_itemindex szWeaponName ) ) > )
    {
        if ( 
iWeaponTypeID != CSW_KNIFE )
        {
            if ( 
iClip && !bIsGrenade )
                
cs_set_weapon_ammoiWeaponEntity iClip );
        
            if ( 
iWeaponTypeID == CSW_C4 
                
cs_set_user_plantindex );
            else
                
cs_set_user_bpammoindex iWeaponTypeID bIsGrenade iClip iBPAmmo ); 
        }
        
        if ( 
maxchars )
            
copyszWeapon maxchars szWeaponName[7] );
    }
    
    return 
iWeaponEntity;

Example:

amx_give_weapon Craxor weapon_m4a1 30 90

4 parameters
1 - name of who to get weapon
2 - weapon name ( ex, weapon_awp )
3 - Ammo (bullets)
4 - Back Pack Ammo ( realoading bullets )
Thank you
Electric Boy 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 15:53.


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