Raised This Month: $ Target: $400
 0% 

[STOCK] give_user_weapon


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 01-25-2016 , 02:57   [STOCK] give_user_weapon
Reply With Quote #1

Give User Weapon


This is pro-variant of default native give_item()

What's the difference between mine and default one?
  • Check if user is alive
  • Check if user already have respective weapon and set only clip/ammo without giving him the weapon and throw error.
  • Ability to set Clip of weapon
  • Ability to set BPAmmo of the weapon
  • Return the name of weapon without weapon_ prefix!
  • Return properly the Weapon Entity ID you give
  • Use CSW_ constants to give an weapon to a player instead of weapon_ id.
  • Error with "native cs_set_weapon_ammo" has been resolved.


Authors Craxor and Bugsy.

OverView

Code:
/*      give_user_weapon( index, CSW_weapon, Clip, BPAmmo, szWeapon, maxchars )         @param index: The Player Index to give an weapon.         @param iWeaponTypeID: Weapon ID ( CSW_* )         @param iClip: Clip of ammo (bullets).         @param iBPAmmo: Back Pack ammo of the weapon.         @param szWeapon[]:(Optionaly) The weapon name pointer to receive the weapon name.                                               The Weapon name is without 'weapon_' prefix. Example: m4a1         @param maxchars: (Optionaly if you use szWeapon param ) szWeapon[] size. The value 20 is recommended for most weapons.                 @return: Weapon Entity ID */  give_user_weapon( index , iWeaponTypeID , iClip=0 , iBPAmmo=0 , szWeapon[]="" , maxchars=0 )

Function
Spoiler



Required modules:
CStrike, Engine, Fun.

Usage Example:
Code:
// Give to a index a deagle with 1 clip and 0 back pack ammo in stock.
give_user_weapon( id, CSW_DEAGLE, 1, 0 );
Code:
// Give to a index 10 hegrenades:
give_user_weapon( id, CSW_HEGRENADE, 5 );
  • Here's a note about get weapon name parameter.


Credit's:
HamletEagle(for idea get_weaponname and remove lot of switchs)
Nubo, Lux0r - some little modifications
Bugsy - a lot of things and rewrite the code with lot of optimization's
AMX Mod Dev(i forgot he help me with old code)
addons_zz( Parameter's doc help )

Changelog:
1.0: First realease.
1.1: Return the CSW_ Weapon ID
1.2: Bugsy: code cleaning/optimization.
1.3: Bugsy: Added grenade support.
1.4: Added C4 support.
1.5: Bugsy&Craxor: Added Weapon Name support, bomb icon, can skip Clip parameter if is grenade.
1.6: Removed uppercase first char, re-write weapon name code, etc, etc ...
1.7: Removed redundant if/else, use "?" comparator.
1.8: Bugsy update.
1.9: Bugsy added an condition for filltering attempt of giving ammo/bpammo to a knife.

Last edited by Craxor; 05-13-2017 at 04:57.
Craxor is offline
Send a message via ICQ to Craxor
 



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 02:05.


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