I have made a npc plugin but the problem is the npc stuck on the ground but before i add the animation code server reads a origins config and respawning them in the places written in the configfile but they dont move after i add the animation code all the npcs stuck on one place and attacking.
PHP Code:
Load_Npc()
{
//Get the correct filepath and mapname
new szConfigDir[256], szFile[256], szNpcDir[256];
get_configsdir(szConfigDir, charsmax(szConfigDir));
new szMapName[32];
get_mapname(szMapName, charsmax(szMapName));
formatex(szNpcDir, charsmax(szFile), "%s/zombie_nightmare", szConfigDir);
formatex(szFile, charsmax(szFile), "%s/%s.cfg", szNpcDir, szMapName);
//If the map config file does not exist we will make one
if (!file_exists(szFile))
{
//return PLUGIN_HANDLED_MAIN;
//write_file(szFile, "");
}
//Variables to store when reading our file
new szFileOrigin[3][32];
new sOrigin[128], sAngle[128], Float:fOrigin[3], Float:fAngles[3];
new iLine, iLength, sBuffer[256];
//When we are reading our file...
while (read_file(szFile, iLine++, sBuffer, charsmax(sBuffer), iLength))
{
//Move to next line if the line is commented
if((sBuffer[0]== ';') || !iLength)
continue;
//Split our line so we have origin and angle. The split is the vertical bar character
strtok(sBuffer, sOrigin, charsmax(sOrigin), sAngle, charsmax(sAngle), '|', 0);
//Store the X, Y and Z axis to our variables made earlier
parse(sOrigin, szFileOrigin[0], charsmax(szFileOrigin[]), szFileOrigin[1], charsmax(szFileOrigin[]), szFileOrigin[2], charsmax(szFileOrigin[]));
fOrigin[0] = str_to_float(szFileOrigin[0]);
fOrigin[1] = str_to_float(szFileOrigin[1]);
fOrigin[2] = str_to_float(szFileOrigin[2]);
//Store the yawn angle
fAngles[1] = str_to_float(sAngle[1]);
//Keep reading the file until the end
create_zombie()
}
return PLUGIN_CONTINUE;
}
public create_zombie()
{
new ent = create_entity("info_target")
ent2 = ent
entity_set_origin(ent, g_spawn_point)
entity_set_float(ent, EV_FL_takedamage,1.0)
entity_set_float(ent, EV_FL_health, 100.0)
entity_set_string(ent, EV_SZ_classname, ZB_CLASSNAME)
entity_set_model(ent, zombie_model)
entity_set_int(ent, EV_INT_solid, 2)
entity_set_int(ent, EV_INT_movetype, MOVETYPE_STEP)
set_pev(ent, pev_victim, 0)
entity_set_byte(ent, EV_BYTE_controller1, 125)
entity_set_byte(ent, EV_BYTE_controller2, 125)
entity_set_byte(ent, EV_BYTE_controller3, 125)
entity_set_byte(ent, EV_BYTE_controller4, 125)
new Float:maxs[3] = {16.0, 16.0, 36.0}
new Float:mins[3] = {-16.0, -16.0, -36.0}
entity_set_size(ent, mins, maxs)
play_anim(ent, ANIM_IDLE, 1.0)
entity_set_float(ent,EV_FL_nextthink, halflife_time() + 0.01)
drop_to_floor(ent)
RegisterHamFromEntity(Ham_TakeDamage, ent, "fw_zb_takedmg")
RegisterHamFromEntity(Ham_Killed, ent, "fw_zb_killed")
return 1
}
}