From f7805623b021ad1c2005a591c21f80eb5482f779 Mon Sep 17 00:00:00 2001 From: Borja Ferrer Date: Sat, 13 May 2006 14:59:24 +0000 Subject: [PATCH] added request at29591 --- amxmodx/amxmodx.cpp | 15 +++++++++++++++ plugins/include/amxmodx.inc | 6 ++++++ 2 files changed, 21 insertions(+) diff --git a/amxmodx/amxmodx.cpp b/amxmodx/amxmodx.cpp index 23c01e05..5edb7e07 100755 --- a/amxmodx/amxmodx.cpp +++ b/amxmodx/amxmodx.cpp @@ -634,6 +634,20 @@ static cell AMX_NATIVE_CALL get_weaponname(AMX *amx, cell *params) /* 3 param */ return set_amxstring(amx, params[2], g_weaponsData[index].fullName.c_str(), params[3]); } +static cell AMX_NATIVE_CALL get_weaponid(AMX *amx, cell *params) +{ + int ilen; + const char *name = get_amxstring(amx, params[1], 0, ilen); + + for (int i = 0; i < MAX_WEAPONS; i++) + { + if (!strcmp(g_weaponsData[i].fullName.c_str(), name)) + return g_weaponsData[i].iId; + } + + return -1; +} + static cell AMX_NATIVE_CALL get_user_weapons(AMX *amx, cell *params) /* 3 param */ { int index = params[1]; @@ -4112,6 +4126,7 @@ AMX_NATIVE_INFO amxmodx_Natives[] = {"hcsardhnexsnu", register_byval}, {"get_user_weapon", get_user_weapon}, {"get_user_weapons", get_user_weapons}, + {"get_weaponid", get_weaponid}, {"get_weaponname", get_weaponname}, {"get_xvar_float", get_xvar_num}, {"get_xvar_id", get_xvar_id}, diff --git a/plugins/include/amxmodx.inc b/plugins/include/amxmodx.inc index 6a150a4e..ac4d8e07 100755 --- a/plugins/include/amxmodx.inc +++ b/plugins/include/amxmodx.inc @@ -1061,3 +1061,9 @@ native get_pcvar_string(pcvar, string[], maxlen); * Sets a whole array to a certain value. */ native arrayset(array[], value, size); + +/** + * Returns the weapon id, otherwise -1 when no id found. + * The weapon name is case sensitive, and has the weapon_* form. + */ +native get_weaponid(const name[]);