|
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
|

05-08-2021
, 11:21
Re: weapon names
|
#7
|
This will allow you to have a standard and custom weapon name.
GetWeaponName() allows you to retrieve either the standard or custom name. If you ask for the custom name and the custom name is not defined, it will return the standard name instead.
You can build a function to populate this array with a weapon name as needed:
PHP Code:
copy( g_weapons[ CSW_M4A1 ][ CustomName ] , charsmax( g_weapons[][] ) , "M4A-One" );
PHP Code:
#include <amxmodx>
enum WeaponNameTypes { StandardName, CustomName }
new g_weapons[33][ WeaponNameTypes ][32] = { { "", "" }, { "P250", "" }, { "", "" }, { "Steyr Scout", "" }, { "HE Grenade", "" }, { "XM1014", "" }, { "C4 Explosive", "" }, { "MAC-10", "" }, { "AUG", "" }, { "Smoke Grenade", "" }, { "Dual Berettas", "" }, { "Five-SeveN", "" }, { "UMP-45", "" }, { "SCAR-20", "" }, { "Galil AR", "" }, { "FAMAS", "" }, { "USP-S", "" }, { "Glock-18", "" }, { "AWP", "" }, { "MP5", "" }, { "M249", "" }, { "M3", "" }, { "M4A1-S", "" }, { "Steyr TMP", "" }, { "G3SG1", "" }, { "Flashbang", "" }, { "Desert Eagle", "" }, { "SG 552", "" }, { "AK47", "" }, { "Classic Knife", "" }, { "P90", "" }, { "vest", "" }, { "vest + helmet" , "" } }
public plugin_init() { new szTemp[ 32 ]; GetWeaponName( CSW_M4A1 , CustomName , szTemp , charsmax( szTemp ) ); server_print( szTemp ); }
GetWeaponName( WeaponID , WeaponNameTypes:wnType , szBuffer[ 32 ] , maxchars ) { new WeaponNameTypes:wnWeaponNameType = ( ( wnType == CustomName ) && ( g_weapons[ WeaponID ][ wnType ][ 0 ] != EOS ) ) ? CustomName : StandardName; return copy( szBuffer , maxchars , g_weapons[ WeaponID ][ wnWeaponNameType ] ); }
__________________
Last edited by Bugsy; 05-08-2021 at 11:21.
|
|