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

Support for dynamic objects #97

Closed
WoutProvost opened this issue Jul 17, 2017 · 18 comments
Closed

Support for dynamic objects #97

WoutProvost opened this issue Jul 17, 2017 · 18 comments

Comments

@WoutProvost
Copy link
Contributor

Regarding FCNPC_SetSurfingPlayerObject.
Forum post: click

@ziggi
Copy link
Owner

ziggi commented Jul 17, 2017

Did you mean dynamic object from the Streamer plugin?

@WoutProvost
Copy link
Contributor Author

Yes

@rt-2
Copy link

rt-2 commented Jul 18, 2017

There might be a second cmd like FCNPC_SetSurfingPlayerDynamicObject. We'd need to check if the streamer-plugin is included and if yes include those functions too.
That's my opinion.
rt-2

@WoutProvost
Copy link
Contributor Author

WoutProvost commented Jul 18, 2017

FCNPC_SetSurfingPlayerDynamicObject is too long for the pawn compiler. It will result in the Warning 200 - symbol "foobar" is truncated to 31 characters.

EDIT:
Besides, a dynamic object is already a player object, so that word can be left out, so it should be:
FCNPC_SetSurfingDynamicObject

@rt-2
Copy link

rt-2 commented Jul 18, 2017

FCNPC_SetSurfingPlayerDynObject is 31 exactly.

@WoutProvost
Copy link
Contributor Author

CreateObject ==> Global object
CreatePlayerObject ==> Player object
CreateDynamicObject ==> Dynamic object

FCNPC_SetSurfingObject ==> Global object
FCNPC_SetSurfingPlayerObject ==> Player object
FCNPC_SetSurfingDynamicObject ==> Dynamic object

Keep it consistent.

@WoutProvost
Copy link
Contributor Author

WoutProvost commented Nov 27, 2017

Think I have a (temporary) fix.

FCNPC_SetSurfingPlayerObject(npcid, Streamer_GetItemInternalID(npcid, STREAMER_TYPE_OBJECT, streamerid));

Haven't tested yet though.

@ziggi
Copy link
Owner

ziggi commented Nov 28, 2017

Yeap, I think I will fix this by Pawn, this is more simple way I guess

@WoutProvost
Copy link
Contributor Author

Just tested my possible fix. It doesn't seem to work...

@ziggi
Copy link
Owner

ziggi commented Jan 4, 2018

So, I guess what it's not possible because Streamer plugin uses per-player objects, so, this objects is are visible only for players for which they were created. NPC can't surf on object which isn't existed for him.
This means that you should use CreateObject for this type of objects.
I will remove FCNPC_SetSurfingPlayerObject soon (this not working and can't be working)...

@WoutProvost
Copy link
Contributor Author

This means that you should use CreateObject for this type of objects.

That's unfortunate :/

@WoutProvost
Copy link
Contributor Author

Since Dynamic objects are player objects under the hood and NPCs can in fact handle player objects of themselves (yes, I tested this), we should be able to make this work.

Therefore, instead of adding a FCNPC_SetSurfingDynamicObject function, we should look into what makes FCNPC_SetSurfingPlayerObject fail.

@WoutProvost
Copy link
Contributor Author

WoutProvost commented Sep 18, 2018

Possible cause found.
Code:

printf("STREAMER ID %d, INTERNAL ID PLAYER %d, INTERNAL ID NPC %d", testDynamicObject, Streamer_GetItemInternalID(playerid, STREAMER_TYPE_OBJECT, testDynamicObject), Streamer_GetItemInternalID(testNPC, STREAMER_TYPE_OBJECT, testDynamicObject));
FCNPC_SetSurfingPlayerObject(testNPC, Streamer_GetItemInternalID(testNPC, STREAMER_TYPE_OBJECT, testDynamicObject));
MoveDynamicObject(testDynamicObject, -1456.719, 501.297, 9.914, 1);

Result:

STREAMER ID 4828, INTERNAL ID PLAYER 6, INTERNAL ID NPC 65535

So, the streamer plugin doesn't handle NPCs.
https://github.com/samp-incognito/samp-streamer-plugin/blob/f7c7d31ba8c5a59c5b6af7b499d857a355514a2c/src/streamer.cpp#L295

@WoutProvost
Copy link
Contributor Author

WoutProvost commented Sep 18, 2018

Also found a server crash.
When you destroy the playerobject belonging to the NPC after you destroy the NPC, the server crashes.

EDIT:
Crash only happens when YSF is loaded as well.

EDIT 2:
Crash only happens with player objects, not with dynamic objects.

@WoutProvost
Copy link
Contributor Author

See the comments on pull request #205

Either find a possible fix for this, or remove the surfing natives for player and dynamic objects. Related commits:
45ca4c0
bbd56a2

@0x416c69
Copy link
Contributor

Was there an issue about this all along?

Fix for this is easy, let me see if I can code it for you.

@0x416c69
Copy link
Contributor

0x416c69 commented Nov 11, 2019

0x416c69@c7e463c

@WoutProvost There you go, should I make a PR?

Now making it for dynamic obejcts are easy:

  • Go make a PR and add playerid in Streamer_OnItemStreamIn/Out (streamer)
  • Declare a variable to determine if dynamic object is attached to the NPC
  • Streamer_OnItemStreamIn(type, id, playerid): if variable on id is set, set surfing NPC on Streamer_GetItemInternalID(playerid, STREAMER_TYPE_OBJECT, id) on playerid

@WoutProvost
Copy link
Contributor Author

Can't test right now, but wtf dude, where have you been all this time? We could've used someone like you before. Yes please make a PR if you're sure it works.

You make me realise I don't know shit about syncing.

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

No branches or pull requests

4 participants