Streamer advice needed
#1

Hey

What do you recommend how I should loop through all dynamic items with a specific type? I'd like to loop through all dynamic map icons to show/hide for player(s).

BUT!
Some map icon are just toggled for specific players, for example owned property icons, or mission objectives.
How should I check to miss theese items? And how should I loop through theese items?

Код:
for(new index, items = Streamer_GetUpperBound(STREAMER_TYPE_MAP_ICON); index < items; index++)
{
}
Should I check for IsValidDynamicMapIcon or what do you recommend for the fastest loop?
Reply
#2

bump
Reply
#3

You need to use IsValidMapIcon since there can be unassigned IDs.
To determine whether or not a player, virtual world, or interior is toggled for that Map Icon, you should use Streamer_IsInArrayData.

However, if you have a limited and somewhat low amout of "per-player" MapIcons it might be better to make a list of those for each player (an array), since the total amount of MapIcons can get quite large and a huge part of them might be unrelated, so for example it loops through 2000 map icons just to find 10. But it depends on the amount, if there are too many it might require a huge non-dynamic array which isn't optimal either.

Generally I try to avoid these kind of loops as they might be fast today, but if you extend your mode and the total amount keeps growing, this will be a huge loop.

This would be unfeasible for objects on some server for example, where there are 60k dynamic objects (depending on the use case and how often you need to do it).

You could also think about more dynamic data containers, eg with PawnPlus you could make a dynamic list of relevant items to avoid a static array of MAX_PLAYERS * 1000 (or so) cells.
But again that depends on the total amount, if it's relatively low this isn't really a problem.
Reply
#4

Quote:
Originally Posted by NaS
Посмотреть сообщение
You need to use IsValidMapIcon since there can be unassigned IDs.
To determine whether or not a player, virtual world, or interior is toggled for that Map Icon, you should use Streamer_IsInArrayData.

However, if you have a limited and somewhat low amout of "per-player" MapIcons it might be better to make a list of those for each player (an array), since the total amount of MapIcons can get quite large and a huge part of them might be unrelated, so for example it loops through 2000 map icons just to find 10. But it depends on the amount, if there are too many it might require a huge non-dynamic array which isn't optimal either.

Generally I try to avoid these kind of loops as they might be fast today, but if you extend your mode and the total amount keeps growing, this will be a huge loop.

This would be unfeasible for objects on some server for example, where there are 60k dynamic objects (depending on the use case and how often you need to do it).

You could also think about more dynamic data containers, eg with PawnPlus you could make a dynamic list of relevant items to avoid a static array of MAX_PLAYERS * 1000 (or so) cells.
But again that depends on the total amount, if it's relatively low this isn't really a problem.
The amount of map icons will be a lot. All properties have 2 map icons (1 for the available for purchase and one for the player, who own's it. And there will be about 1000-1500 house, and about 500 business too.)
But this is why I want to hide theese map icons for the player's, who doing missions or jobs. But whenever I toggle them and set them visible, the "hidden" map icons will appear too. This is what I want to avoid of. Could you give me any advice how I can do this?
Reply
#5

You could delete the MapIcon of a property once it is bought (which would hide it for everyone).

For the player who owns it you could create and store the Map Icon seperately and save it in an per-player array. It would be created when the player joins only for him, and deleted if he leaves the server or sells the house (then the House Icon is recreated).

That doesn't need a single loop except finding the associated house when someone joins. The player Icon would be associated with the player so no loop is required, and when selling or buying a house the ID is known too, so again no loop required.

The downside is that it wouldn't show owned houses that aren't yours. Not sure if that would be a valid solution for you.
Reply
#6

Have you tried this?

Toggle with exceptions parameter:

Streamer_ToggleAllItems(playerid, STREAMER_TYPE_MAP_ICON , toggle, const exceptions[] = { -1 }, maxexceptions = sizeof exceptions);

And loop with < Streamer_CountVisibleItems(playerid, STREAMER_TYPE_MAP_ICON)
Reply
#7

Quote:
Originally Posted by raydx
Посмотреть сообщение
Have you tried this?

Toggle with exceptions parameter:

Streamer_ToggleAllItems(playerid, STREAMER_TYPE_MAP_ICON , toggle, const exceptions[] = { -1 }, maxexceptions = sizeof exceptions);

And loop with < Streamer_CountVisibleItems(playerid, STREAMER_TYPE_MAP_ICON)
Have you tried to read the thread before posting unnecessary comments?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)