Advertisement
ipsBruno

(Pawn) GetPlayerVehicleSide

Jul 31st, 2014
614
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.88 KB | None | 0 0
  1. /*
  2. * Pegar lado em qual o player está do veículo
  3. * Por Bruno da Silva
  4. * Usando função do MP2
  5. */
  6.  
  7.  
  8. enum {
  9.     VEHICLE_FRONT, VEHICLE_BACK, VEHICLE_LEFT, VEHICLE_RIGHT
  10. }
  11.  
  12. // Código por Bruno da Silva
  13. GetPlayerVehicleSide(playerid, vehicleid)
  14. {
  15.     static Float:x[5],Float:y[5],Float:z[5];
  16.  
  17.     GetPosBetweenVehicle(vehicleid, x[0], y[0], z[0],.dangle = -180.0); // atras
  18.     GetPosBetweenVehicle(vehicleid, x[1], y[1], z[1],.dangle = -000.0); // frente
  19.     GetPosBetweenVehicle(vehicleid, x[2], y[2], z[2],.dangle = -090.0); // esquerda
  20.     GetPosBetweenVehicle(vehicleid, x[3], y[3], z[3],.dangle =  090.0); // direita
  21.  
  22.     z[0] = GetPlayerDistanceFromPoint(playerid, x[0], y[0], z[0]);
  23.     z[1] = GetPlayerDistanceFromPoint(playerid, x[1], y[1], z[1]);
  24.     z[2] = GetPlayerDistanceFromPoint(playerid, x[2], y[2], z[2]);
  25.     z[3] = GetPlayerDistanceFromPoint(playerid, x[3], y[3], z[3]);
  26.  
  27.     if(z[0]<z[1])
  28.     if(z[0]<z[2])
  29.     if(z[0]<z[3])
  30.     return VEHICLE_BACK;
  31.  
  32.     if(z[1]<z[2])
  33.     if(z[1]<z[3])
  34.     return VEHICLE_FRONT;
  35.  
  36.  
  37.     if(z[2]<z[3])
  38.     return VEHICLE_LEFT;
  39.  
  40.     return VEHICLE_RIGHT;
  41.  
  42. }
  43.  
  44.  
  45. // Código por MP2
  46. stock GetPosBetweenVehicle(vehicleid, &Float:x, &Float:y, &Float:z, Float:offset=0.5, Float:dangle = 0.0)
  47. {
  48.     new Float:vehicleSize[3], Float:vehiclePos[3];
  49.     GetVehiclePos(vehicleid, vehiclePos[0], vehiclePos[1], vehiclePos[2]);
  50.     GetVehicleModelInfo(GetVehicleModel(vehicleid), VEHICLE_MODEL_INFO_SIZE, vehicleSize[0], vehicleSize[1], vehicleSize[2]);
  51.     GetXYBehindVehicle(vehicleid, vehiclePos[0], vehiclePos[1], (vehicleSize[1]/2)+offset, dangle);
  52.     x = vehiclePos[0];
  53.     y = vehiclePos[1];
  54.     z = vehiclePos[2];
  55.     return 1;
  56. }
  57.  
  58. GetXYBehindVehicle(vehicleid, &Float:q, &Float:w, Float:distance, Float:dangle = 0.0)
  59. {
  60.     new Float:a;
  61.     GetVehiclePos(vehicleid, q, w, a);
  62.     GetVehicleZAngle(vehicleid, a);
  63.     q += (distance * -floatsin(-a-dangle, degrees));
  64.     w += (distance * -floatcos(-a-dangle, degrees));
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement