samp-streamer-plugin icon indicating copy to clipboard operation
samp-streamer-plugin copied to clipboard

Streamer_ToggleItemStatic does not make items static for real

Open Adi007z opened this issue 5 years ago • 3 comments

I write this because Streamer_ToggleItemStatic is not doing whan it is supposed to do...it should convert an item to native and let it spawned (and block that item slot until the scripter free it by destroying it or by using Streamer_ToggleItem).

It would be extremely useful to be able to manually enable "stream IN" and "stream OUT" of certain dynamic objects.

More specific, adding a function by which a dynamic object can be converted to an object identical to one created by the native CreatePlayerObject function. Converted objects to native, in this way are removed from the grid (they won't be in any distance loop checkings so it cannot be destroyed by distance checks and also it saves CPU) and obviously the number of objects that the plugin can use will drop from 1000 to 999 if 1 dynamic object was converted to native .

This update would help in cases where many objects are created in different virtual-worlds, but at the same coordinates, in the same place (which makes the cell huge with too many objects, so a big loop for object distance checkings).

The programmer would be the one who take care to release the converted objects to native using Streamer_ToggleItem (which will delete them if they are created).

I made this suggestion for you after testing on a server with about 650 online players. The server was loaded with about 15.000 objects created in the same range, but in different virtual-worlds (like a place where there are about 150 objects spawned in every 0-100 virtual-world => 150 * 100 worlds = 15.000 objects). When too many players were in that place, the streamer had in the loop the cell with 15.000 objects for every player in that place, which made the server to run with 70% CPU. Removing the 15.000 objects which were spawned in the same place but in different worlds made the CPU go down to 35%. CPU: i7 (don't know which exactly).

So, if you would create a function to convert objects to native objects, we can bypass this CPU problem when creating a lot of objects in the same cell (over more virtual-worlds). The scripter can manually use Streamer_ToggleItem to hide it for a player when the pleayer leaves the area of these objects, which is useful because it destroy the item which was converted to native and free up the object slot.

Yes, it is true that we can achive the same thing by using CreatePlayerObject to create the objects needed when a player enters in such as area, and DestroyPlayerObject when the player leaves that area, but it would be nice to be able to manage all objects through the streamer (it will also know that the objects slots are not 1000 anymore when converting to native some objects).

Of course the scripter has to assure that he don't place objects converted to native in places where there are many other dynamic objects, because the streamer will not be able to create object anymore as time as slots are reserved for the ones converted to native objects.

Note: When i say "native object" i mean object converted from DynamicObject to CreatePlayerObject (which can't be destroyed by the cell distance checks in streamer and it is also removed from any cell, in order to save the CPU because it won't be in the cell loop).

Adi007z avatar Jan 13 '19 17:01 Adi007z

So this problem is related to heavy CPU usage on objects placed in the same place, but in different virtual worlds. It may be a duplicate of https://github.com/samp-incognito/samp-streamer-plugin/issues/136.

IstuntmanI avatar May 23 '19 09:05 IstuntmanI

Set the stream distance to something negative. This makes them static.

Crayder avatar May 23 '19 19:05 Crayder

See https://github.com/samp-incognito/samp-streamer-plugin/blob/6dad0a121d60613b25bd1ec9aa6ca38701da3270/CHANGES.md#v2750

I was looking for the issue where I had this same problem and incognito added that but couldn't find it. Found another one though where we discussed a similar issue with per-area objects, now you can use negative area ID's to stream objects everywhere except the specified area.

Crayder avatar May 23 '19 19:05 Crayder