Duplicate Actors bug
#1

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;
                }
            }
        }
        //}
    }
Reply
#2

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;
}
Reply
#3

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' ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)