SA-MP Forums Archive
[Include] Streamer Position Compensation - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] Streamer Position Compensation (/showthread.php?tid=601679)



Streamer Position Compensation - Crayder - 24.02.2016

Streamer position compensation!

So many people complain about setting players on streamed objects. The problem is that these people are setting the player on the objects before the objects are actually streamed in for the player to land on. This will work around that.
__________________________________________________ __________________________________________________

Description:

The only function included is as follows:
pawn Код:
SetPlayerCompensatedPos(playerid, Float:X, Float:Y, Float:Z, wait_time = 1000)
There are two basic usages for this.

1. Absolutely on the ground:2. Probably on the ground:Or if you set the wait_time to 0 and the ground never streams (or if you set the position too high or low) then the player will be frozen forever (or until you release them).


You can predefine define `TP_WAIT_TIME` before including this to set the default wait time.
Slice recommended really high wait times, at least 5 seconds.


Also, on a side note, I haven't tested this yet... Yes, I know I should've tested it before I released it, but I didn't! I don't have any lag to spare. If someone could confirm it works that'd be great. Here's how you can test:
  1. Create a bunch of objects somewhere (THOUSANDS, seriously, a hundred thousand dispersed across an area of about 500x500 should do the trick).
  2. Create a plane object (anything flat and thin) above them.
  3. Spawn a player far away from them.
  4. Set the player on the plane with SetPlayerPos.
  5. Repeat #3.
  6. Repeat #4 using SetPlayerCompensatedPos with wait time 0.
  7. Repeat #3.
  8. Repeat #4 using SetPlayerCompensatedPos with wait time 5000.
  9. Repeat #3.
  10. Repeat #4 using SetPlayerCompensatedPos with wait time 5000 this time higher than the ground, like 2 units higher.
4 should fail if the player is lagging enough or if the objects don't stream fast enough. 6 and 8 should compensate the lag perfectly. 10 should wait 5 seconds and drop the player.
__________________________________________________ __________________________________________________

Credits:

Thanks to Slice and Incognito for the ideas implemented here (combined their ideas).
No thanks to me! I take no credit for this, except sparking Incognito's idea.
__________________________________________________ __________________________________________________

Download!


Re: Streamer Position Compensation - SecretBoss - 24.02.2016

Seems like a good job, +reped


Re: Streamer Position Compensation - AliDollar - 24.02.2016

Great feature gonna use that !
by the way i use Createobject on player spawn object, that's work fine too!!


Re: Streamer Position Compensation - Max_Andolini - 24.02.2016

Great idea you are amazing man


Re: Streamer Position Compensation - DRIFT_HUNTER - 24.02.2016

Good thing someone actually released these
Anyway, small suggestion (dont know if its dumb but its how i would like to have it in my scipt's).
Hook onto SetPlayerPos and SetVehiclePos, set default wait time to be 0 and that means you just Set Player/Vehicle Pos, but if wait time is greater than 0 than preload objects. Not that it would improve performance or anything but i think its nicer these way. Also a macro for default wait time would be welcome so that scripters could just drop in these include, redifine macro and whola! their server is preloading objects (Most useful for stunt server that dont care about anything )


Re: Streamer Position Compensation - Crayder - 24.02.2016

Quote:
Originally Posted by DRIFT_HUNTER
Посмотреть сообщение
Good thing someone actually released these
Anyway, small suggestion (dont know if its dumb but its how i would like to have it in my scipt's).
Hook onto SetPlayerPos and SetVehiclePos, set default wait time to be 0 and that means you just Set Player/Vehicle Pos, but if wait time is greater than 0 than preload objects. Not that it would improve performance or anything but i think its nicer these way. Also a macro for default wait time would be welcome so that scripters could just drop in these include, redifine macro and whola! their server is preloading objects (Most useful for stunt server that dont care about anything )
Can't do it for vehicles, you can't just stream objects to a vehicle as if it were a player. I already considered hooking SetPlayerPos with an extra parameter but I know many people would complain about it breaking other scripts and shit. And the macro, done. Just define TP_WAIT_TIME before including this.


Re: Streamer Position Compensation - TheMallard - 28.02.2016

Код:
static Float:TP_GetDistanceFromAwaiting(playerid)
{
	new Float:pX, Float:pY, Float:pZ;
	GetPlayerPos(playerid, pX, pY, pZ);
	return (floatsqroot(floatpower(pX - TP_AwaitingPos[playerid][0], 2.0) + floatpower(pY - TP_AwaitingPos[playerid][1], 2.0) + floatpower(pZ - TP_AwaitingPos[playerid][2], 2.0)));
}
This can be replaced by VectorSize (https://sampwiki.blast.hk/wiki/VectorSize) and even by GetPlayerDistanceFromPoint.


Re: Streamer Position Compensation - Crayder - 28.02.2016

Quote:
Originally Posted by TheMallard
Посмотреть сообщение
Код:
static Float:TP_GetDistanceFromAwaiting(playerid)
{
	new Float:pX, Float:pY, Float:pZ;
	GetPlayerPos(playerid, pX, pY, pZ);
	return (floatsqroot(floatpower(pX - TP_AwaitingPos[playerid][0], 2.0) + floatpower(pY - TP_AwaitingPos[playerid][1], 2.0) + floatpower(pZ - TP_AwaitingPos[playerid][2], 2.0)));
}
This can be replaced by VectorSize (https://sampwiki.blast.hk/wiki/VectorSize) and even by GetPlayerDistanceFromPoint.
Yeah well even better it could be replaced with a single subtraction since we only need to test Z. I've already done this and forgot to upload.


Re: Streamer Position Compensation - Stanford - 29.02.2016

Amazing and really useful, I appreciate your efforts


Re: Streamer Position Compensation - HydraHumza - 01.03.2016

Marvelous release. Thanks Crayder.