Advertisement
Guest User

Cálculo de deslocamento e velocidade angular

a guest
Oct 12th, 2022
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 0.82 KB | Gaming | 0 0
  1. stock Float:GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
  2. {
  3.     static Float:a;
  4.     GetPlayerPos(playerid, x, y, a);
  5.  
  6.     if(IsPlayerInAnyVehicle(playerid))
  7.         GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
  8.     else
  9.         GetPlayerFacingAngle(playerid, a);
  10.  
  11.     x += (distance * floatsin(-a, degrees));
  12.     y += (distance * floatcos(-a, degrees));
  13.     return a;
  14. }
  15.  
  16. stock BoostPlayer(playerid, Float:speed, bool:use_z = false)
  17. {
  18.     static
  19.         Float:X, Float:Y, Float:Z,
  20.         Float:x, Float:y, Float:z;
  21.        
  22.     GetPlayerPos(playerid, x, y, z);
  23.     GetPlayerPos(playerid, X, Y, Z);
  24.     GetXYInFrontOfPlayer(playerid, X, Y, speed);
  25.  
  26.     x = ((X < x) ? (x - X) : (X - x));
  27.     y = ((Y < y) ? (y - Y) : (Y - y));
  28.  
  29.     if(use_z)
  30.         z = ((Z < z) ? (z - Z) : (Z - z));
  31.     else
  32.         z = 0.0;
  33.  
  34.     return SetPlayerVelocity(playerid, x, y, z);
  35. }
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement