Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streamer_Update and Streamer_UpdateEx not working correctly in the class selection #75

Closed
FSAOskar opened this issue Sep 13, 2015 · 31 comments

Comments

@FSAOskar
Copy link

I've got this problem for over a year now. I can do what ever I want but my objects (CreateDynamicObject) won't show up in the class selection except when I enter the class selection when the objects are already streamed in. Normal objects (CreateObject) are fine.
The objects will only show up for like half a second and then they will dissappear again.
I'm not doing anything special, just creating the objects. I also didn't modify the streamer in any way.

@Ryder17z
Copy link

It is possible that CreatePlayerObject do not work in class selection.

@Crayder
Copy link

Crayder commented Sep 13, 2015

@Patrik356b Yes, it does work. CreatePlayerObject and CreateObject will both work fine without streamer. The streamer just can't get the right player position (to stream the dynamic objects to) in class selection so you need to tell it where the player is (Streamer_UpdateEx).

It works perfectly fine for me though, so I'm guessing it's something to do with your script.

@FSAOskar
Copy link
Author

But the problem is I can't imagine what could cause this. I'm just creating the objects normally and I don't do anything with them after it.
Well like I said, everytime I use Streamer_UpdateEx the objects will only show for half a second and then dissappear again.

@Crayder
Copy link

Crayder commented Sep 14, 2015

An alternative attempt such as checking if the player is in class selection and repeatedly updating in OnPlayerUpdate may temporarily fix your issue. As far as I can see though it is working perfectly fine in my scripts. I just Streamer_UpdateEx once in OnPlayerRequestClass with the position of the objects and the correct interior and everything goes as it should.

@samp-incognito
Copy link
Owner

It works for me as well. Something must be conflicting in your script.

@FSAOskar
Copy link
Author

Well, probably. But I can't think of anything which could make the function don't work correctly.

@samp-incognito
Copy link
Owner

You are using, specifically, Streamer_UpdateEx under OnPlayerRequestClass, right? Streamer_Update won't work there. If you are using those natives anywhere else (on a timer, for example), it could cause the objects to be streamed in a different place. See if you can reproduce it in an empty script.

@FSAOskar
Copy link
Author

Yeah I am using Streamer_UpdateEx under OnPlayerRequestClass. I'll try what you said now

@FSAOskar
Copy link
Author

So it was working with a blank script. Even with the same plugins I'm using so it has to be the my gamemode as I haven't got any filterscripts.
I've got Streamer_UpdateEx multiple times in my script but it also doesn't work if I remove them.
It only works when I respawn while the objects are already streamed in.
I really don't know what I'm doing wrong.

@samp-incognito
Copy link
Owner

Print to the server log every time your script uses one of those natives so you can see where the offending code is.

@FSAOskar
Copy link
Author

Well like I said, I got the same result when I only got it under OnPlayerRequestClass. It also only prints when I change my class

@samp-incognito
Copy link
Owner

Your script must be calling it somewhere else as well, perhaps in an include. The only other thing I can think of is that Streamer_ToggleIdleUpdate being enabled would prevent objects from being streamed properly in the class selection.

@FSAOskar
Copy link
Author

Couldn't find anthing like that in my gamemode or in any include. Not sure how else I could debug my script. Maybe I could hook EVERY streamer function and print it to the console when it gets called.

Could you maybe hook SetPlayerPos inside the plugin and then automatically update the player's position in the class selection to his actual position (as GetPlayerPos doesn't when changing class) so that Streamer_UpdateEx isn't needed in this case anymore ?

@IstuntmanI
Copy link
Contributor

I bet that you are actually using Streamer_Update somewhere in a timer, or something like that. Streamer_UpdateEx always worked for me at class request.

The idea of internally using Streamer_UpdateEx at class isn't possible, unless there would be a function like "Streamer_SetClassPos( playerid, X, Y, Z );", because GetPlayerPos isn't working, so the streamer can't automatically get class's position. It is also a really bad idea, because, at least for me, Streamer_UpdateEx at OnPlayerRequestClass is lagging the client for a few milliseconds/seconds (this may be an issue ? I don't think this behaviour is normal, because streamer plugin is based on zones and shouldn't lag). So I only use Streamer_UpdateEx when the player enters first time in request class, and with a timer of ~100-200milliseconds, so it wouldn't hang the rendering (if I use without timer CJ skin will be shown instead of the normal one).

You have to check your script (includes, filterscripts), we can't help you at all. The Streamer Plugin is working fine, the objects are shown normally with that function.

@FSAOskar
Copy link
Author

I've already checked ALL of my filterscripts, includes and my gamemode. So there has to be an other problem in my script not related to one of the streamer's natives. And I don't think you get what I mean.
My idea is to hook SetPlayerPos and then check in the hooked function if the player is in the class selection. If he is in the class selection then it should save the coordinates in an array, set the players position and process the new previously saved position internally. Should be posible in my opinion.

It would also help other players which don't have the same problem like me. Cause much players which haven't used the streamer before probably don't know that they have to use Streamer_UpdateEx to get the objects appearing in the class selection.

@IstuntmanI
Copy link
Contributor

Aw, my bad. It is possible, yes, but I don't think it should be implemented in streamer, it should stay at our decision what we want to do, maybe someone wants the request class to be somewhere, but without showing the objects which are there, there can be many ideas only with that thing.

Yes, many owners don't know that they should use Streamer_UpdateEx (personally I told a few owners to use it, because they didn't understand why the objects aren't there) at request class, it should be documented somewhere (still, many don't read the documentation, but they should, so this is no longer our problem).

It is alright how it is now, there is a problem with your code and you have to find it.

But still, the remaining issue is that it lags a bit when used. I have over 100.000 objects, but the checking is made for that zone and the ones next to it, so it shouldn't lag.

@JernejL
Copy link

JernejL commented Sep 22, 2015

it could be implemented in streamer, while it might not know where player is, the streamer could check if it's class selection and use the player's camera position as streaming point.

@Crayder
Copy link

Crayder commented Sep 22, 2015

@JernejL if that was the case, there is a function that toggles between player position and camera position already. I don't think it works in class selection.

@JernejL
Copy link

JernejL commented Sep 23, 2015

Crayder: It should work with that switch then.

Camera vector + position updates are sent in a totally separate updates from car / foot movement updates and iirc they are sent in class selection aswell.

samp-incognito pushed a commit that referenced this issue Sep 23, 2015
@FSAOskar
Copy link
Author

FSAOskar commented Oct 1, 2015

@JernejL I just tried it and getting the camera pos gives the same result as getting the player's pos in the class selection. It just gives the last position of the player's camera before he went into the class selection.

@Crayder
Copy link

Crayder commented Oct 1, 2015

That has been a known bug for years. If the camera position functions and class selection callbacks were hooked it could be done with less precision.

Like I said, "I don't think it works in class selection."

@JernejL
Copy link

JernejL commented Oct 2, 2015

Streamer_UpdateEx seems like a better option than hooking that just for class selection tho..

@Crayder
Copy link

Crayder commented Oct 2, 2015

@JernejL Yeah, that has always worked for me. But apparently that doesn't work for him.

@FSAOskar
Copy link
Author

FSAOskar commented Oct 9, 2015

Yep. I've searched the whole script for every streamer native. The only ones I am using are:
Streamer_SetVisibleItems
Streamer_GetFloatData
CreateDynamicObject,
MoveDynamicObject,
CreateDynamicRectangle,
CreateDynamicPickup,
CreateDynamicCheckpoint
and Streamer_UpdateEx
I really don't have any clue what could cause this bug in my script. I've already debugged some parts in my gamemode but there was nothing wrong.
Anyone got an idea what I could directly debug in the plugin ?

@mikecnr
Copy link

mikecnr commented Oct 15, 2015

I've had this problem for a week and have been doing some investigating.

Do you happen to hide class selection at all (using TogglePlayerSpectating)? And then showing it again using ForceClassSelection? For me, this seems to be what breaks it. ForceClassSelection.

@Crayder
Copy link

Crayder commented Oct 15, 2015

ForceClassSelection would not matter. Even then, if you force an update the objects will be streamed in.

@mikecnr
Copy link

mikecnr commented Oct 15, 2015

But it does matter. I made a test gamemode, and when I run it normally (not disabling class selection), the objects stream fine, but when I TogglePlayerSpectating true then ForceClassSelection then TogglePlayerSpectating false, the objects do not stream, even with Streamer_UpdateEx. They stream for one 'cycle', then disappear again.

@FSAOskar
Copy link
Author

That could be the problem as I'm hiding the class selection once when the player connects so that the login screen doesn't get messed up by the class selection.
I'll try some stuff now and see if it works.

edit It really works when I'm not using ForceClassSelection but now I gotta find another way to put the player into the class selection without getting this bug again. Thanks mate!

edit2 Killing the player seems to do the job but dying after the the login would probably confuse players and isn't a good solution.

@mikecnr
Copy link

mikecnr commented Oct 16, 2015

Found a solution!

Simply disable normal object updates when class selection starts (OnPlayerRequestClass) with:

Streamer_ToggleItemUpdate(playerid, STREAMER_TYPE_OBJECT, false);

Then force updates yourself using Streamer_UpdateEx (NOTE: YOU MUST SPECIFY .type = STREAMER_TYPE_OBJECT.). You also cannot use GetPlayerPos or GetPlayerCameraPos. You must specify the coordinates yourself.

Then re-enable object updates under OnPlayerSpawn with:

Streamer_ToggleItemUpdate(playerid, STREAMER_TYPE_OBJECT, true);

EDIT: Another thing I have discovered. If you leave class selection alone to run normally, GetPlayerState returns 0 (PLAYER_STATE_NONE), but if you TogglePlayerSpectating true to hide csel, then force them back and toggle spectating on, GetPlayerState returns 9 (PLAYER_STATE_SPECTATING). I assume the streamer starts using the camera position in this state or something? It should be easy to keep track of whether a player is in csel or not using OnPlayerRequestClass and OnPlayerSpawn, right? I know this is a SA-MP bug but it should be able to be worked around.

@FSAOskar
Copy link
Author

Thank you so much, it worked!
I would have probably never gotten the idea that ForceClassSelection + TogglePlayerSpectating causes this!

@samp-incognito
Copy link
Owner

I see. GetPlayerPos (and presumably GetPlayerCameraPos) only work while the player is spawned. The streamer checks if the player state is PLAYER_STATE_NONE or PLAYER_STATE_WASTED before starting an update, but not if it's PLAYER_STATE_SPECTATING. I guess I could add an additional check to see if the player is in the class selection, which should fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants