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

Checkpoints restreaming bug

Open IstuntmanI opened this issue 7 years ago • 7 comments

Originally posted by BeckzyBoi here: http://forum.sa-mp.com/showpost.php?p=3960733&postcount=5703


OnPlayerCommandText:

Streamer_ToggleItemUpdate(playerid, STREAMER_TYPE_CP, 0);
TogglePlayerAllDynamicCPs2(playerid, 0);
TogglePlayerSpectating(playerid, 1);

OnPlayerSpawn:

Streamer_ToggleItemUpdate(playerid, STREAMER_TYPE_CP, 1);
TogglePlayerAllDynamicCPs2(playerid, 1);

TogglePlayerDynamicCPs2:

TogglePlayerAllDynamicCPs2(playerid, toggle, exceptions[] = { -1 }, maxexceptions = sizeof exceptions)
{
    if (toggle == 0 && GetPlayerVisibleDynamicCP(playerid) != 0) {
        DisablePlayerCheckpoint(playerid);
    }
    TogglePlayerAllDynamicCPs(playerid, toggle, exceptions, maxexceptions);
}

When the player re-spawns in the range of a checkpoint, the checkpoint is not shown. They must re-enter the checkpoint streaming distance.


I think that this happens because the DisablePlayerCheckpoint function is used in this case to cancel a dynamic CP, but because the Streamer Plugin didn't hook the DisablePlayerCheckpoint function, the Streamer Plugin still thinks that the player sees an checkpoint, so it doesn't get restreamed yet. Probably hooking this function and setting player.visibleCheckpoint, player.activeCheckpoint and player.delayedCheckpoint to 0 would fix that ? (also doing this for race checkpoints)

IstuntmanI avatar Dec 06 '17 14:12 IstuntmanI

By the way, with this SDK you can easily redirect AMX functions: https://github.com/maddinat0r/samp-plugin-sdk/

Example: https://github.com/udan11/samp-plugin-timerfix/blob/70a7477346d358bf5f613934298e18e7524f42f7/src/main.cpp#L77-L81

(not sure if hooking DisablePlayerCheckpoint and returning sampgdk::DisablePlayerCheckpoint in the hooked function would create an infinite loop, didn't test that yet, maybe @maddinat0r can respond to this ?)

IstuntmanI avatar Dec 06 '17 18:12 IstuntmanI

Yes, he shouldn't be using DisablePlayerCheckpoint. The right native to use in that case would be Streamer_ToggleItem (or TogglePlayerDynamicCP).

If you were to hook DisablePlayerCheckpoint, I would think you'd also have to hook SetPlayerCheckpoint and reset those variables (there's already some native hooking code here which could be refactored: https://github.com/samp-incognito/samp-streamer-plugin/blob/master/src/utility/amx.cpp#L47-L67). However, these natives will still ultimately be incompatible with the streamer plugin natives. The next time the streamer updates, the streamed checkpoint will just be set for the player again. There should be a note on the wiki about not using them together.

samp-incognito avatar Dec 07 '17 01:12 samp-incognito

The reason I'm using DisablePlayerCheckpoint is because neither Streamer_ToggleItem, TogglePlayerDynamicCP, or TogglePlayerAllDynamicCPs are hiding the checkpoint when used. DisablePlayerCheckpoint is the only way I can remove the checkpoint from the map when using Streamer_ToggleItemUpdate and TogglePlayerAllDynamicCPs

BeckzyBoi avatar Dec 08 '17 10:12 BeckzyBoi

The checkpoint should be hidden, but it won't take effect until the next update. You should call Streamer_ToggleItem, Streamer_Update, and then finally Streamer_ToggleItemUpdate.

samp-incognito avatar Dec 08 '17 21:12 samp-incognito

That doesn't hide the checkpoint either.

BeckzyBoi avatar Dec 09 '17 13:12 BeckzyBoi

For the life of me I can't get the visible checkpoint to disappear before using Streamer_ToggleItemUpdate and TogglePlayerAllDynamicCPs WITHOUT using DisablePlayerCheckpoint. Help?

BeckzyBoi avatar Dec 11 '17 01:12 BeckzyBoi

Not to bump this but.. maybe your doing something wrong.

I use Streamer_ToggleItem to stop showing checkpoints lets say when a player enters a custom transfender i made, then reenable it when they are done. It all works fine.

karimcambridge avatar Jul 15 '18 19:07 karimcambridge