• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] IsDynamicActorStreamedIn always returns 0
#1
Hey. In my mod there is a system which creates shop actors if a player goes inside, and destroys them when everybody went out.
Or at least that's the goal. Creating the actor works fine, as the mod detects if the actor is already created and doesnt spawn it again, etc.
But if anybody leaves the shop and my custom function gets called, the shop actor gets deleted immediately, no matter if someone else got the actor streamed in.

My code:
Code:
DestroyShopActorIfUnstreamed(virtualworldid)
{
? ? if (!IsValidDynamicActor(shopactor[virtualworldid])) return 1;
for(new i = 0; i < MAX_PLAYERS  1; i)
? ? {
? ? ? ? if (IsDynamicActorStreamedIn(shopactor[virtualworldid], i))
? ? ? ? {
? ? ? ? ? ? print("streamed");
? ? ? ? ? ?break;
? ? ? ? }
? ? printf("shopactor %i deleted", virtualworldid);
? ? DestroyDynamicActor(shopactor[virtualworldid]);
? ? }
return 1;
}

I know i messed up something with the code
  Reply
#2
If the actor is not streamed in for ID 0 you delete it immediately after. Move the DestroyDynamicActor line outside the loop, and switch the break to a return statement.
  Reply
#3
You don't need to delete actors if u use streamer plugin. They 'r automagicly deleted/creatated and don't occupy a slot in default actor? -POOL?? - ( when not visable ).

I'd say delete dynamic actors this way only if they are usless/random.



Now, we have multiple mistakes in your code.



for(new i = 0; i < MAX_PLAYERS 1; i) >> for(new i = 0; i < MAX_PLAYERS; i)



? ? ? ? if (IsDynamicActorStreamedIn(shopactor[virtualworldid], i))

? ? ? ? {

? ? ? ? ? ? print("streamed");

? ? ? ? ? break;

? ? ? ? }



>>>



? ? ? ? if (IsDynamicActorStreamedIn(shopactor[virtualworldid], i))

? ? ? ? {

? ? ? ? ? ? print("streamed");

? ? ? ? ? return 0; // or 1

? ? ? ? }





And, consider adding IsPlayerConnected.
  Reply


Forum Jump: