Duplicate Actors bug - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP (
https://sampforum.blast.hk/forumdisplay.php?fid=3)
+--- Forum: Bug Reports (
https://sampforum.blast.hk/forumdisplay.php?fid=20)
+--- Thread: Duplicate Actors bug (
/showthread.php?tid=573086)
Duplicate Actors bug -
Admigo - 04.05.2015
When trying to recreate the actors when they die the actor is getting duplicated.
[ame]www.youtube.com/watch?v=nQgEAoWOadE[/ame]
If you can see the Actor will be recreated but will also be duplicated.
pawn Код:
for(new i = 0, j = GetActorPoolSize(); i <= j; i++)
  {
    //if(!IsActorInvulnerable(i)) //Check if actor is vulnerable
    //{
    if(IsValidActor(ActorID[i]))
    {
      if(ActorCreated[i]==1)
      {
        new Float:health;
        GetActorHealth(ActorID[i], health); //Get current health
        if(health <= 0.0)
        {
          new Float:x,Float:y,Float:z;
          GetActorPos(ActorID[i],x,y,z);
          DestroyActor(ActorID[i]);
          ActorID[i]=CreateActor(ActorSkin[i],x,y,z,ActorAngle[i]);
          return 1;
        }
      }
    }
    //}
  }
Re: Duplicate Actors bug -
long76 - 04.05.2015
maybe better recreated actors in OnPlayerGiveDamageActor
pawn Код:
public OnPlayerGiveDamageActor(playerid, damaged_actorid, Float: amount, weaponid, bodypart)
{
Â
  if(!IsActorInvulnerable(damaged_actorid)) //Check if actor is vulnerable
  {
    new Float:health;
    GetActorHealth(damaged_actorid, health); //Get current health
    SetActorHealth(damaged_actorid, health-amount); //Apply damage, set new health
    if( (health-amount)<= 0.0)
    {
new Float:x,Float:y,Float:z;
          GetActorPos(ActorID,x,y,z);
          DestroyActor(ActorID);
          ActorID=CreateActor(ActorSkin,x,y,z,ActorAngle[i]);
}
  }
  return 1;
}
Re: Duplicate Actors bug -
Pizzy - 06.05.2015
new Float

,Float:y,Float:z;
GetActorPos(ActorID[i],x,y,z);
DestroyActor(ActorID[i]);
ActorID[i]=CreateActor(ActorSkin[i],x,y,z,ActorAngle[i]);
You destroy the actor - and then you immediately make another one after it's been destroyed.
? Just remove the last CreateActor line?
Or add: ActorCreated[ActorID]==0; under the 'DestroyActor' ?