Burgershot
  • Home
  • Members
  • Team
  • Help
  • Search
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search
Burgershot SA-MP Pawn Scripting [Pawn] IsDynamicActorStreamedIn always returns 0

 
  • 0 Vote(s) - 0 Average
Pawn IsDynamicActorStreamedIn always returns 0
c4p
Offline

Burgershot Member
Posts: 7
Threads: 3
Joined: Dec 2020
Reputation: 0
#1
2021-01-13, 03:26 PM (This post was last modified: 2021-01-13, 03:27 PM by c4p.)
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
Bakr
Offline

Burgershot Member
Posts: 14
Threads: 2
Joined: Oct 2020
Reputation: 6
Location: United States
#2
2021-01-17, 02:20 PM
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.
Expert*
Offline

Burgershot Member
Posts: 61
Threads: 2
Joined: Apr 2019
Reputation: 4
#3
2021-01-18, 07:30 PM (This post was last modified: 2021-01-18, 07:35 PM by Expert*.)
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.
« Next Oldest | Next Newest »



  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Burgershot - Powered by our Community and MyBB Original Theme by Emerald

Linear Mode
Threaded Mode