Closed v1934 closed 3 years ago
You can use -1
in Streamer_ToggleItem
to toggle items for all players.
For example:
new objectid = CreateDynamicObject(4515, 0.0, 0.0, 5.0, 0.0, 0.0, 0.0);
Streamer_ToggleItem(-1, STREAMER_TYPE_OBJECT, objectid, false);
The reason why it's not removing objects for you is that you have to restream it. https://github.com/samp-incognito/samp-streamer-plugin/blob/5696cee2d0becaeed7f6d99d8525ffeb664a88b3/src/streamer.cpp#L902
Indeed passing -1 as playerid has worked, thank you.
Sorry but I have a kinda unrelated question but it's not really an issue and since I have no other way of asking it, I'll do it here.
Is detaching objects from vehicles by changing the E_STREAMER_ATTACHED_VEHICLE
to INVALID_VEHICLE_ID
and calling Streamer_Update()
safe?
I use this trick once in my gamemode when players edit attached object position (With EditDynamicObject
), so I don't need to recreate the whole object. It works, but when I think about it.. it shouldn't. And I have been experiencing a very random and rare bug where some objects actually disappear, just like their IDs were re-used by Streamer. I keep the object IDs for every vehicle in an array, and also every object has E_STREAMER_EXTRA_ID
set to the vehicle's id. While in my array everything matches during that bug, E_STREAMER_EXTRA_ID
doesn't and it looks just like the object with that ID has been destroyed and it's ID reused..
I'm trying to find the cause so I look into every single piece of code that does something with vehicle objects.
Streamer is re-using item IDs.
The best practice is to destroy items when you are not using them.
Is detaching objects from vehicles by changing the E_STREAMER_ATTACHED_VEHICLE to INVALID_VEHICLE_ID and calling Streamer_Update() safe?
It is safe, your object will appear on the coordinates you set on creating the object.
The thing is.. I'm not deleting these objects anywhere. They randomly and very rarily disappear from vehicles, and I have no idea why. I keep track of all attached object IDs in an array and when I added some debug info I noticed that sometimes the object with that ID is not valid anymore, sometimes it is valid but attached to entirely different vehicle. I cannot find any place where I would be deleting attached objects, other than when players delete them (which also deletes objects from my database and variables, so it's not that). Only thing that caught my attention is the trick with detaching from vehicle, i thought it may be screwing up the object and maybe streamer deletes it later thinking the vehicle has been deleted or something.
I recently updated the streamer plugin from v2.9.1 to v2.9.5, but needed to fall back after I noticed some stuff related to VW of objects attached to vehicles stopped working
Disabling/enabling neons, I have a
/neon
command which changed theE_STREAMER_WORLD_ID
like this:Streamer_SetIntData(STREAMER_TYPE_OBJECT, pvehData[id][Neons][i], E_STREAMER_WORLD_ID, toggle ? pvehData[id][VW] : VW_VOID)
WhereVW_VOID
is just some random number thats guaranteed to be out of useFixing some crash areas (specifically openable garages) where certain object models crash the game when attached to a nearby vehicle, basically the same principle as above, I set up dynamic areas in these places and just hide malicious objects when player enters the area.
Now this stopped working, objects don't disappear from the vehicle but stay on it, just like Streamer ignored the VW change. I can understand this is caused by some fixes related to attaching, for example
Fixed some attached object bugs
in v2.9.2, but if thats the case then is there any other way to simply achieve what I did with manipulating the world ID earlier? I see there are functions likenative Streamer_ToggleItem(playerid, type, STREAMER_ALL_TAGS:id, toggle);
, but they work per-player and I need them global (looping through players is not an option..)I have tried using
E_STREAMER_INTERIOR_ID
instead of VW, and it works! But i somehow dislike the idea of using interior ids for this, since vws are imo more suitable for such tasks.