#define Loop(%0,%1,%2) for(new %0 = %2; %0 < %1; %0++)
new ActorPos[MAX_ACTORS][4];
stock new_CreateActor(skin,Float:x,Float:y,Float:z,Float:a)
{
new aid = CreateActor(skin,x,y,z,a);
ActorPos[aid][0] = x,ActorPos[aid][1] = y,ActorPos[aid][2] = z,ActorPos[aid][3] = a;
SetActorVirtualWorld(aid, 0);
SetActorInvulnerable(aid, 1);
return aid;
}
stock CheckActorPos()
{
new Float:Pos[3];
Loop(i,GetActorPoolSize()+1,0)
{
if(IsValidActor(i))
{
if(GetActorVirtualWorld(i) == 0)
{
GetActorPos(i, Pos[0], Pos[1], Pos[2]);
if(Pos[0] != ActorPos[i][0] || Pos[1] != ActorPos[i][1] || Pos[2] != ActorPos[i][2])
{
SetActorPos(i, ActorPos[i][0],ActorPos[i][1],ActorPos[i][2]);
SetActorFacingAngle(i, ActorPos[i][3]);
}
}
}
}
return 1;
}
You shouldn't use != or == operators with floats use >=, <=, <, > for comparisons. Anyways you are not even clear at all about your problem with no explanation of anything of what you are doing.
|
forward Float:GetDistanceBetweenPoints(Float:rx1,Float:ry1,Float:rz1,Float:rx2,Float:ry2,Float:rz2);
stock Float:GetDistanceBetweenPoints(Float:rx1,Float:ry1,Float:rz1,Float:rx2,Float:ry2,Float:rz2)
{
return floatadd(floatadd(floatsqroot(floatpower(floatsub(rx1,rx2),2)),floatsqroot(floatpower(floatsub(ry1,ry2),2))),floatsqroot(floatpower(floatsub(rz1,rz2),2)));
}
stock CheckActorPos()
{
new Float:Pos[3];
Loop(i,GetActorPoolSize()+1,0)
{
if(IsValidActor(i))
{
if(GetActorVirtualWorld(i) == 0)
{
GetActorPos(i, Pos[0], Pos[1], Pos[2]);
new Float:dist = GetDistanceBetweenPoints(Pos[0], Pos[1], Pos[2],ActorPos[i][0],ActorPos[i][1],ActorPos[i][2]);
if(dist > 0.0)
{
SetActorPos(i, ActorPos[i][0],ActorPos[i][1],ActorPos[i][2]);
SetActorFacingAngle(i, ActorPos[i][3]);
}
}
}
}
return 1;
}