SA-MP Forums Archive
SetPlayerVelocity calculated with GetPlayerFacingAngle - 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: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: SetPlayerVelocity calculated with GetPlayerFacingAngle (/showthread.php?tid=96191)



SetPlayerVelocity calculated with GetPlayerFacingAngle - Trooper[Y] - 06.09.2009

Hey there.
I want to use SetPlayerVelocity to let the players jump high.
To get this, i need Velocity to get the X & Y - Points.
I tried to calculate it like you normally do to spawn smth. (an object for example) in front of a player,
but this failed....

I tried:

GetPos
GetAngle
Calculate both
Result - 1st GetPos

But it didnt worked, and i got some result around ~1.000.

Can you help me with this ?


Re: SetPlayerVelocity calculated with GetPlayerFacingAngle - dice7 - 06.09.2009

pawn Код:
if (strcmp("/gofast", cmdtext, true, 10) == 0)
{
  if(IsPlayerInAnyVehicle(playerid))
  {
    new Float:x, Float:y, Float:z;
    GetVehicleVelocity(GetPlayerVehicleID(playerid),x,y,z);
    x = (x + 2)*2;
    y = (y + 2)*2;
    z = (z + 2)*2;
    SetVehicleVelocity(GetPlayerVehicleID(playerid),x,y,z);
  }
  return 1;
}



Re: SetPlayerVelocity calculated with GetPlayerFacingAngle - Trooper[Y] - 06.09.2009

Can you explain how its done ?
I mean, +2 is easy to understand, but why *2 ?!

thx btw.


Re: SetPlayerVelocity calculated with GetPlayerFacingAngle - dice7 - 06.09.2009

Just experiment. *2 is so that you go very fast, +2 is just in case if you're standing still


Re: SetPlayerVelocity calculated with GetPlayerFacingAngle - Trooper[Y] - 07.09.2009

Hum, tried now.
Same problem as before.
I just fly in 1 direction, which is not related to players angle.


Re: SetPlayerVelocity calculated with GetPlayerFacingAngle - Killerkid - 07.09.2009

Look at Donny's AddPlayerVelocityDirection function: http://forum.sa-mp.com/index.php?topic=120606.0


Re: SetPlayerVelocity calculated with GetPlayerFacingAngle - Trooper[Y] - 07.09.2009

Love you men, perfect
Works !
Код:
GetPlayerVelocity(playerid,x1[playerid],y1[playerid],z1[playerid]);
			GetPlayerFacingAngle(playerid,a1[playerid]);
			x1[playerid] += ( 0.5 * floatsin( -a1[playerid], degrees ) );
      y1[playerid] += ( 0.5 * floatcos( -a1[playerid], degrees ) );
			SetPlayerVelocity(playerid,x1[playerid],y1[playerid],z1[playerid]+0.7);



Re: SetPlayerVelocity calculated with GetPlayerFacingAngle - JonyAvati - 25.10.2009

Quote:
Originally Posted by Trooper[Y
]
Love you men, perfect
Works !
Код:
GetPlayerVelocity(playerid,x1[playerid],y1[playerid],z1[playerid]);
			GetPlayerFacingAngle(playerid,a1[playerid]);
			x1[playerid] += ( 0.5 * floatsin( -a1[playerid], degrees ) );
      y1[playerid] += ( 0.5 * floatcos( -a1[playerid], degrees ) );
			SetPlayerVelocity(playerid,x1[playerid],y1[playerid],z1[playerid]+0.7);
You will get a lot of errors of "Loose identation" with that code xDDD