[Include] Streamer Position Compensation
#1

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:
  • The position you specify is exactly where the player would be if they were standing on the ground. You can set wait_time to 0 so the player won't be controllable until the objects are definitely streamed.
2. Probably on the ground:
  • The position you specify MAY be on the ground. Just set the wait_time (which defaults to 1 second) to how long the script will wait for the objects to stream. If the objects are detected the player will be set controllable. If the objects do not stream before wait_time is over the player will be released then.
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!
Reply
#2

Seems like a good job, +reped
Reply
#3

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

Great idea you are amazing man
Reply
#5

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 )
Reply
#6

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.
Reply
#7

Код:
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.
Reply
#8

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.
Reply
#9

Amazing and really useful, I appreciate your efforts
Reply
#10

Marvelous release. Thanks Crayder.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)