AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
|
09-20-2020
, 11:48
Re: Store string in array
|
#5
|
It would be best to store the CSW_ weapon ID in the array instead of weapon name. Doing this, you can build an array to store info for each weapon, though you can get away with using the weapon name by using the get_weaponid() native. Keep in mind that the array must be built so that the weapon ID corresponds to the appropriate slot in the array, as outlined below.
PHP Code:
#include <amxmodx>
enum AmmoType { MaxClipAmmo, MaxBPAmmo }
new const WeaponAmmo[][ AmmoType ] = { { 0, 0 }, //CSW_NONE 0 { 25, 25 }, //CSW_P228 1 { 25, 25 }, //CSW_GLOCK 2 { 25, 25 }, //CSW_SCOUT 3 { 1, 1 }, //CSW_HEGRENADE 4 { 25, 25 }, //CSW_XM1014 5 { 0, 0 }, //CSW_C4 6 { 25, 25 }, //CSW_MAC10 7 { 25, 25 }, //CSW_AUG 8 { 1, 1 }, //CSW_SMOKEGRENADE 9 { 25, 25 }, //CSW_ELITE 10 { 25, 25 }, //CSW_FIVESEVEN 11 { 25, 25 }, //CSW_UMP45 12 { 25, 25 }, //CSW_SG550 13 { 25, 25 }, //CSW_GALIL 14 { 25, 25 }, //CSW_FAMAS 15 { 25, 25 }, //CSW_USP 16 { 25, 25 }, //CSW_GLOCK18 17 { 25, 25 }, //CSW_AWP 18 { 25, 25 }, //CSW_MP5NAVY 19 { 25, 25 }, //CSW_M249 20 { 25, 25 }, //CSW_M3 21 { 25, 25 }, //CSW_M4A1 22 { 25, 25 }, //CSW_TMP 23 { 25, 25 }, //CSW_G3SG1 24 { 1, 1 }, //CSW_FLASHBANG 25 { 25, 25 }, //CSW_DEAGLE 26 { 25, 25 }, //CSW_SG552 27 { 25, 30 }, //CSW_AK47 28 { 0, 0 }, //CSW_KNIFE 29 { 25, 25 } //CSW_P90 30 };
public plugin_init() { new iAmmo = get_maxammo( "weapon_ak47" , MaxClipAmmo ); new iBPAmmo = get_maxammo( "weapon_ak47" , MaxBPAmmo ); } get_maxammo( const WeaponName[] , AmmoType:atType ) { return WeaponAmmo[ get_weaponid( WeaponName ) ][ atType ]; }
__________________
Last edited by Bugsy; 09-20-2020 at 12:04.
|
|