Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.51 KB | None | 0 0
  1. #define FT
  2. /*
  3. This 'definition' determins whether you CAN (if defined) fly through objects, or CAN'T (undefined).
  4. I added this so flying through tunnels is possible
  5. */
  6. #include <a_samp>
  7. #if defined FT
  8. #include <mapandreas>
  9. #endif
  10.  
  11. /*
  12. It is not required, however highly recommended that you change the amount of 'MAX_PLAYERS' to something different
  13. */
  14. #undef MAX_PLAYERS
  15. #define MAX_PLAYERS 500
  16.  
  17.  
  18. #define COLOR_BLUE 0x0000FFFF
  19. new Turtle[MAX_PLAYERS] = {-1, -1, ...};
  20. new FartsPerSecond[MAX_PLAYERS];    //I first thought of making this a float. Then I realized you can't do like 2.5331 farts a second, only 2 OR 3
  21. new TurtlyTimer[MAX_PLAYERS];
  22. forward OnTurtleUpdate(playerid);
  23. public OnFilterScriptInit()
  24. {
  25.     print("\n--------------------------------------");
  26.     print(" Blank Filterscript by your name here");
  27.     print("--------------------------------------\n");
  28.     #if !defined FT
  29.     MapAndreas_Init(MAP_ANDREAS_MODE_FULL);
  30.     #endif
  31.     return 1;
  32. }
  33.  
  34. public OnFilterScriptExit()
  35. {
  36.     return 1;
  37. }
  38.  
  39. public OnPlayerDisconnect(playerid, reason)
  40. {
  41.     if(Turtle[playerid] != -1)
  42.     {
  43.         DestroyObject(Turtle[playerid]);
  44.         Turtle[playerid] = -1;
  45.         KillTimer(TurtlyTimer[playerid]);
  46.     }
  47.     return 1;
  48. }
  49.  
  50. public OnPlayerCommandText(playerid, cmdtext[])
  51. {
  52.     if(!strcmp("/fly", cmdtext, true))
  53.     {
  54.         new Float:Pos[4];
  55.         if(Turtle[playerid] != -1)
  56.         {
  57.             GetObjectRot(Turtle[playerid], Pos[0], Pos[1], Pos[3]);
  58.             GetObjectPos(Turtle[playerid], Pos[0], Pos[1], Pos[2]);
  59.             DestroyObject(Turtle[playerid]);
  60.             Turtle[playerid] = -1;
  61.             TogglePlayerSpectating(playerid, 0);
  62.             SetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
  63.             SetPlayerFacingAngle(playerid, Pos[3]);
  64.             KillTimer(TurtlyTimer[playerid]);
  65.             SendClientMessage(playerid, COLOR_BLUE, "The bean effect has worn off.");
  66.             return 1;
  67.         }
  68.         GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
  69.         GetPlayerFacingAngle(playerid, Pos[3]);
  70.         Turtle[playerid] = CreateObject(8493, Pos[0], Pos[1], Pos[2], 0, 0, Pos[3] * -1);
  71.         TogglePlayerSpectating(playerid, 1);
  72.         FartsPerSecond[playerid] = 0;
  73.         OnTurtleUpdate(playerid);
  74.         TurtlyTimer[playerid] = SetTimerEx("OnTurtleUpdate", 30, 1, "i", playerid);
  75.         SendClientMessage(playerid, COLOR_BLUE, "Yo gave yo turtle sum beans and now it farts all over the place!");
  76.        
  77.         return 1;
  78.     }
  79.     return 0;
  80. }
  81.  
  82. public OnTurtleUpdate(playerid)
  83. {
  84.     new Keys[3];
  85.     GetPlayerKeys(playerid, Keys[0], Keys[1], Keys[2]);
  86.     new Float:Pos[9]; //X - Y - Z - rX - rY - rZ - nZ
  87.     GetObjectRot(Turtle[playerid], Pos[3], Pos[4], Pos[5]);
  88.  
  89.     if(Keys[0] & KEY_JUMP && !(Keys[0] & KEY_SPRINT)) FartsPerSecond[playerid]--;
  90.     if(Keys[0] & KEY_SPRINT && !(Keys[0] & KEY_JUMP)) FartsPerSecond[playerid]++;
  91.    
  92. //Rotation part
  93.     Pos[5] += (((Keys[2] < 0 && FartsPerSecond[playerid] >= 0) || (Keys[2] > 0 && FartsPerSecond[playerid] < 0)) ? (3.5) : ((Keys[2] > 0 && FartsPerSecond[playerid] >= 0) || (Keys[2] < 0 && FartsPerSecond[playerid] < 0) ? (-3.5) : (0.0)));
  94.     //That's quite a line
  95.     //Don't mention this text. I like giving feedback on my own scripting lol.
  96.    
  97.     SetObjectRot(Turtle[playerid], 0, 0, Pos[5]);
  98.  
  99. //Location part - Sarcasm(YAY, YAY, YAY, YAY, YAY, YAY);
  100.     GetObjectPos(Turtle[playerid], Pos[0], Pos[1], Pos[2]);
  101.     Pos[7] = Pos[0] + (floatdiv(FartsPerSecond[playerid], 145) * floatsin(-Pos[5], degrees) * ((Keys[1] == 0) ? (1.0) : (floatdiv(2, 3))));
  102.     Pos[8] = Pos[1] + (floatdiv(FartsPerSecond[playerid], 145) * floatcos(-Pos[5], degrees) * ((Keys[1] == 0) ? (1.0) : (floatdiv(2, 3))));
  103. #if defined FT
  104.     Pos[2] += ((Keys[1] < 0) ? (-0.333) : (Keys[1] > 0) ? (0.333) : (0.0)) * floatdiv(FartsPerSecond[playerid], 145);
  105.     SetObjectPos(Turtle[playerid], Pos[7], Pos[8], Pos[2]);
  106.     MoveObject(Turtle[playerid], Pos[7], Pos[8], Pos[2], 120);
  107. #else
  108.     MapAndreas_FindZ_For2DCoord(Pos[7], Pos[8], Pos[6]);
  109.  
  110.     if(Pos[6] > Pos[2] + 3) SetObjectPos(Turtle[playerid], Pos[0], Pos[1], Pos[2]);
  111.     else if(Pos[6] > Pos[2]) SetObjectPos(Turtle[playerid], Pos[7], Pos[8], Pos[6]);
  112.     else
  113.     {
  114.         Pos[2] += ((Keys[1] < 0) ? (-0.333) : (Keys[1] > 0) ? (0.333) : (0.0)) * floatdiv(FartsPerSecond[playerid], 145);
  115.         SetObjectPos(Turtle[playerid], Pos[7], Pos[8], Pos[2]);
  116.     }
  117. #endif
  118. //Camera part. This pisses me off all the time...
  119.     SetPlayerCameraLookAt(playerid, Pos[0] + (4 * floatsin(-Pos[5], degrees)), Pos[1] + (4 * floatcos(-Pos[5], degrees)), Pos[ ((Pos[6] > Pos[1]+1) ? (6) : (2)) ] + 1);
  120.     Pos[0] -= (68 * floatsin(-Pos[5], degrees));
  121.     Pos[1] -= (68 * floatcos(-Pos[5], degrees));
  122.     SetPlayerCameraPos(playerid, Pos[0], Pos[1], Pos[ ((Pos[6] > Pos[1]+1) ? (6) : (2)) ] + 16);
  123. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement