Linux
Build 6153
Metamod v1.21p37
AMX Mod X 1.8.3-dev+4936
PHP Code:
#include <amxmodx>
#include <cstrike>
#include <engine>
public plugin_init()
{
register_concmd("test1", "commandTest1");
register_concmd("test2", "commandTest2");
}
public commandTest1( iPlayerID )
{
/* Create the entity */
new iEntityID = cs_create_entity("info_target");
if (!is_valid_ent(iEntityID))
{
console_print(iPlayerID, "[Test1] invalid entity");
return;
}
entity_set_string(iEntityID, EV_SZ_classname, "testEntity1");
/* Try to find the entity */
console_print(iPlayerID, "[Test1] cs_find_ent_by_class: %d", cs_find_ent_by_class(-1, "testEntity1"));
console_print(iPlayerID, "[Test1] find_ent_by_class: %d", find_ent_by_class(-1, "testEntity1"));
}
public commandTest2( iPlayerID )
{
/* Create the entity */
new iEntityID = create_entity("info_target");
if (!is_valid_ent(iEntityID))
{
console_print(iPlayerID, "[Test2] invalid entity");
return;
}
entity_set_string(iEntityID, EV_SZ_classname, "testEntity2");
/* Try to find the entity */
console_print(iPlayerID, "[Test2] cs_find_ent_by_class: %d", cs_find_ent_by_class(-1, "testEntity2"));
console_print(iPlayerID, "[Test2] find_ent_by_class: %d", find_ent_by_class(-1, "testEntity2"));
}
Output:
PHP Code:
test1
[Test1] cs_find_ent_by_class: 0
[Test1] find_ent_by_class: 37
test2
[Test2] cs_find_ent_by_class: 0
[Test2] find_ent_by_class: 38
cs_find_ent_by_class should return the entity index on test1