以下是我NPC 侦测 NPC 的 FUNCTION, 但一执行, 伺服器就当掉了:
复制程式
public FindClosesEnemy(entid)
{
new Float:Dist
new Float:maxdistance=5000.0
new indexid=0
new i;
while ((is_valid_ent(i = find_ent_by_class (i, CLASSNAME))) || (is_valid_ent(i = find_ent_by_class (i, "player"))))
//for(new i=1;i <= get_maxplayers();i++)
{
new Ptdclassname[32]
pev(i, pev_classname, Ptdclassname, charsmax(Ptdclassname))
if (equal(Ptdclassname, CLASSNAME) && i != entid)
{
if (is_valid_ent(i) && pev(i,pev_health) > 0.0)
{
Dist = entity_range(entid, i)
if(Dist <= maxdistance)
{
maxdistance=Dist
indexid=i
}
}
}
else if (equal(Ptdclassname, "player"))
{
if(is_user_alive(i) && is_valid_ent(i) && cs_get_user_team(i) == CS_TEAM_CT && is_user_connected(i))
{
Dist = entity_range(entid, i)
if(Dist <= maxdistance)
{
maxdistance=Dist
indexid=i
}
}
}
}
return indexid
}
请问一下, CODE 在那里出了问题?