SetPlayerVelocity calculated with GetPlayerFacingAngle
#1

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 ?
Reply
#2

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;
}
Reply
#3

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

thx btw.
Reply
#4

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

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

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

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);
Reply
#8

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)