Advertisement
GabyM

fly.inc

Jun 29th, 2017
831
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.14 KB | None | 0 0
  1. // =======================================================================================
  2. // fly.inc
  3. //
  4. // Author: Norck
  5. //
  6. // msn:         [email protected]
  7. // icq:         44-055-21
  8. // skype:       paul_norck
  9. //
  10. // Credits: Creator of SetPlayerLookAt function. Sorry, I can't remember their name
  11. //
  12. // you are allowed to edit this script
  13. // you are not allowed to sell this script
  14. //
  15. // Please, don't remove the credits
  16. // =======================================================================================
  17.  
  18. static bool:OnFly[MAX_PLAYERS];
  19. static Float:flySpeed[MAX_PLAYERS];
  20. static Float:flyZAngle[MAX_PLAYERS];
  21. static playerIsInVehicle[MAX_PLAYERS];
  22. forward InitFly(playerid);
  23. forward bool:StartFly(playerid);
  24. forward Fly(playerid);
  25. forward bool:StopFly(playerid);
  26.  
  27. InitFly(playerid)
  28. {
  29.     OnFly[playerid] = false;
  30.     flySpeed[playerid] = 1.024;
  31.     return true;
  32. }
  33. bool:StartFly(playerid)
  34. {
  35.     if(OnFly[playerid]) return false;
  36.  
  37.     if(IsPlayerInAnyVehicle(playerid))
  38.         playerIsInVehicle[playerid] = true;
  39.     else
  40.         ApplyAnimation(playerid,"PARACHUTE","FALL_SkyDive_Accel",6.1,1,1,1,1,0,1);
  41.     OnFly[playerid] = true;
  42.     Fly(playerid);
  43.     return true;
  44. }
  45. bool:StopFly(playerid)
  46. {
  47.     if(!OnFly[playerid]) return false;
  48.  
  49.     OnFly[playerid] = false;
  50.     SetPlayerHealth(playerid,100.0);
  51.     if(playerIsInVehicle[playerid])
  52.         SetVehicleHealth(GetPlayerVehicleID(playerid),1000.0);
  53.     else
  54.         ClearAnimations(playerid);
  55.     playerIsInVehicle[playerid] = false;
  56.     return true;
  57. }
  58. public Fly(playerid)
  59. {
  60.     if(!IsPlayerConnected(playerid)) return 1;
  61.     if(!OnFly[playerid]) return 1;
  62.     if(IsPlayerInAnyVehicle(playerid) ^ playerIsInVehicle[playerid]) return StopFly(playerid);
  63.  
  64.     new k,ud,lr;
  65.     new Float:v_x,Float:v_y,Float:v_z;
  66.     GetPlayerKeys(playerid,k,ud,lr);
  67.     if(ud < 0)
  68.     {
  69.         GetPlayerCameraFrontVector(playerid,v_x,v_y,v_z);
  70.         v_x = v_x*flySpeed[playerid];
  71.         v_y = v_y*flySpeed[playerid];
  72.         if(v_x == 0.0)
  73.             v_x = v_x+0.001;
  74.         flyZAngle[playerid] = atan(v_y/v_x)-90.0;
  75.         if(v_x < 0)
  76.             flyZAngle[playerid] = flyZAngle[playerid]+180.0;
  77.         if(playerIsInVehicle[playerid])
  78.             SetVehicleHealth(GetPlayerVehicleID(playerid),99999.0);
  79.         else
  80.         {
  81.             SetPlayerHealth(playerid,99999.0);
  82.             SetPlayerFacingAngle(playerid,flyZAngle[playerid]);
  83.             if(GetPlayerAnimationIndex(playerid) != 959)
  84.                 ApplyAnimation(playerid,"PARACHUTE","FALL_SkyDive_Accel",6.1,1,1,1,1,0,1);
  85.         }
  86.     }
  87.     if(k & KEY_ANALOG_LEFT)
  88.         flySpeed[playerid] = flySpeed[playerid]/2;
  89.     else if(k & KEY_ANALOG_RIGHT)
  90.         flySpeed[playerid] = flySpeed[playerid]*2;
  91.     if(flySpeed[playerid] > 20.0)
  92.         flySpeed[playerid] = 20.0;
  93.     if(lr < 0)     // down
  94.         v_z = -0.5*flySpeed[playerid];
  95.     else if(lr > 0)   // up
  96.         v_z = 0.5*flySpeed[playerid];
  97.     else
  98.         v_z = 0.025;
  99.     if(playerIsInVehicle[playerid])
  100.     {
  101.         SetVehicleVelocity(GetPlayerVehicleID(playerid),v_x,v_y,v_z);
  102.         SetVehicleZAngle(GetPlayerVehicleID(playerid),flyZAngle[playerid]);
  103.     }
  104.     else
  105.     {
  106.         SetPlayerVelocity(playerid,v_x,v_y,v_z);
  107.         if(v_x == 0 && v_y == 0)
  108.             if(GetPlayerAnimationIndex(playerid) == 959)
  109.                 ApplyAnimation(playerid,"PARACHUTE","PARA_steerR",6.1,1,1,1,1,0,1);
  110.     }
  111.     SetTimerEx("Fly",100,false,"i",playerid);
  112.     return 1;
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement