From 7e11cb5cc12a7fe22e01d67a10f49133d7c2f228 Mon Sep 17 00:00:00 2001 From: Vincent Herbet Date: Wed, 7 Aug 2013 16:40:37 +0200 Subject: [PATCH] Add has_map_ent_class native (bug 5814, r=Nextra) Former-commit-id: bfa749105feb49cf9f9b3878dededa33ae7d699c --- amxmodx/amxmodx.cpp | 11 +++++++++++ plugins/include/amxmodx.inc | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/amxmodx/amxmodx.cpp b/amxmodx/amxmodx.cpp index 43787912..13d36377 100755 --- a/amxmodx/amxmodx.cpp +++ b/amxmodx/amxmodx.cpp @@ -4623,6 +4623,16 @@ static cell AMX_NATIVE_CALL LookupLangKey(AMX *amx, cell *params) set_amxstring(amx,params[1],def,params[2]); return 1; }; + +// has_map_ent_class(const classname[]) +static cell AMX_NATIVE_CALL has_map_ent_class(AMX *amx, cell *params) +{ + int len; + char *name = get_amxstring(amx, params[1], 0, len); + + return len && !FNullEnt(FIND_ENTITY_BY_STRING(NULL, "classname", name)); +}; + static cell AMX_NATIVE_CALL is_rukia_a_hag(AMX *amx, cell *params) { return 1; @@ -4728,6 +4738,7 @@ AMX_NATIVE_INFO amxmodx_Natives[] = {"get_xvar_float", get_xvar_num}, {"get_xvar_id", get_xvar_id}, {"get_xvar_num", get_xvar_num}, + {"has_map_ent_class", has_map_ent_class}, {"int3", int3}, {"is_amd64_server", is_amd64_server}, {"is_dedicated_server", is_dedicated_server}, diff --git a/plugins/include/amxmodx.inc b/plugins/include/amxmodx.inc index 9f403348..358cb518 100755 --- a/plugins/include/amxmodx.inc +++ b/plugins/include/amxmodx.inc @@ -1084,5 +1084,16 @@ native admins_lookup(num, AdminProp:Property, Buffer[]="", BufferSize=0); * Clears the list of dynamically stored admins */ native admins_flush(); + +/** + * Searches whether a map contains at least one entity with the provided class name. + * + * @param classname The entity classname to check. + * + * @return Returns true if an entity is found, otherwise false. + */ +native bool:has_map_ent_class(const classname[]); + + // Keep this always at the bottom of this file #include