View Single Post
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 09-20-2020 , 11:48   Re: Store string in array
Reply With Quote #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},    //CSW_NONE            0
    
2525 },    //CSW_P228            1
    
2525 },    //CSW_GLOCK           2  
    
2525 },    //CSW_SCOUT           3
    
1},    //CSW_HEGRENADE       4
    
2525 },    //CSW_XM1014          5
    
0},    //CSW_C4              6
    
2525 },    //CSW_MAC10           7
    
2525 },    //CSW_AUG             8
    
1},    //CSW_SMOKEGRENADE    9
    
2525 },    //CSW_ELITE           10
    
2525 },    //CSW_FIVESEVEN       11
    
2525 },    //CSW_UMP45           12
    
2525 },    //CSW_SG550           13
    
2525 },    //CSW_GALIL           14
    
2525 },    //CSW_FAMAS           15
    
2525 },    //CSW_USP             16
    
2525 },    //CSW_GLOCK18         17
    
2525 },    //CSW_AWP             18
    
2525 },    //CSW_MP5NAVY         19
    
2525 },    //CSW_M249            20
    
2525 },    //CSW_M3              21
    
2525 },    //CSW_M4A1            22
    
2525 },    //CSW_TMP             23
    
2525 },    //CSW_G3SG1           24
    
1},    //CSW_FLASHBANG       25
    
2525 },    //CSW_DEAGLE          26
    
2525 },    //CSW_SG552           27
    
2530 },    //CSW_AK47            28
    
0},    //CSW_KNIFE           29
    
2525 }    //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 
WeaponAmmoget_weaponidWeaponName ) ][ atType ];

__________________

Last edited by Bugsy; 09-20-2020 at 12:04.
Bugsy is offline