Hello everyone! How can I get an "
entity" at random, as if it were a player, but in reality it is an NPC. For example, a random NPC is selected as a "
hero" but I have done it in different ways and it does not work for me.
Help mee :'(
PHP Code:
make_npc_hero( )
{
new Array:entities = ArrayCreate(1, 32);
new ent = -1, iHero;
while( ( ent = find_ent_by_class( ent, "npc" ) ) )
{
ArrayPushCell( entities, ent );
new iNpcTotal = ArraySize( entities );
if ( random( iNpcTotal - 1 ) )
g_iNPCIsHero[ ent ] = 1;
}
server_print( "CURRENT HERO %i", ent );
}
__________________