23.04.2012, 15:27
Hello SA-MP scripters.
I'm releasing a function that has been VERY useful for me, for all kinds of scripts:
What does this function, exactly? Well, it calculates the position where the player WILL be when he receives instructions from the server. Basically, if that player is using a vehicle, and has a high ping, use the CreateExplosion function at the coordinates given by this function so the explosion will occur ON the player on his screen (it may not look like being on him on your screen though).
Keep in mind that you should use this function ONLY if you're having issues with high pingers (or high speed vehicles) in your server functionalities, as it is more CPU consuming than GetPlayerPos. Be VERY careful when using in loops also...
I'm releasing a function that has been VERY useful for me, for all kinds of scripts:
pawn Код:
GetPlayerLagPos(playerid,&Float:x,&Float:y,&Float:z)
{
new Float:vx,Float:vy,Float:vz;
new Float:ping=float(GetPlayerPing(playerid)),vehid=GetPlayerVehicleID(playerid);
if (!vehid)
{
GetPlayerPos(playerid,x,y,z);
GetPlayerVelocity(playerid,vx,vy,vz);
}
else
{
GetVehiclePos(vehid,x,y,z);
GetVehicleVelocity(vehid,vx,vy,vz);
}
x+=vx*ping/25.0;
y+=vy*ping/25.0;
z+=vz*ping/25.0;
}
Keep in mind that you should use this function ONLY if you're having issues with high pingers (or high speed vehicles) in your server functionalities, as it is more CPU consuming than GetPlayerPos. Be VERY careful when using in loops also...