Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define FT
- /*
- This 'definition' determins whether you CAN (if defined) fly through objects, or CAN'T (undefined).
- I added this so flying through tunnels is possible
- */
- #include <a_samp>
- #if defined FT
- #include <mapandreas>
- #endif
- /*
- It is not required, however highly recommended that you change the amount of 'MAX_PLAYERS' to something different
- */
- #undef MAX_PLAYERS
- #define MAX_PLAYERS 500
- #define COLOR_BLUE 0x0000FFFF
- new Turtle[MAX_PLAYERS] = {-1, -1, ...};
- 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
- new TurtlyTimer[MAX_PLAYERS];
- forward OnTurtleUpdate(playerid);
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Blank Filterscript by your name here");
- print("--------------------------------------\n");
- #if !defined FT
- MapAndreas_Init(MAP_ANDREAS_MODE_FULL);
- #endif
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- if(Turtle[playerid] != -1)
- {
- DestroyObject(Turtle[playerid]);
- Turtle[playerid] = -1;
- KillTimer(TurtlyTimer[playerid]);
- }
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if(!strcmp("/fly", cmdtext, true))
- {
- new Float:Pos[4];
- if(Turtle[playerid] != -1)
- {
- GetObjectRot(Turtle[playerid], Pos[0], Pos[1], Pos[3]);
- GetObjectPos(Turtle[playerid], Pos[0], Pos[1], Pos[2]);
- DestroyObject(Turtle[playerid]);
- Turtle[playerid] = -1;
- TogglePlayerSpectating(playerid, 0);
- SetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
- SetPlayerFacingAngle(playerid, Pos[3]);
- KillTimer(TurtlyTimer[playerid]);
- SendClientMessage(playerid, COLOR_BLUE, "The bean effect has worn off.");
- return 1;
- }
- GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
- GetPlayerFacingAngle(playerid, Pos[3]);
- Turtle[playerid] = CreateObject(8493, Pos[0], Pos[1], Pos[2], 0, 0, Pos[3] * -1);
- TogglePlayerSpectating(playerid, 1);
- FartsPerSecond[playerid] = 0;
- OnTurtleUpdate(playerid);
- TurtlyTimer[playerid] = SetTimerEx("OnTurtleUpdate", 30, 1, "i", playerid);
- SendClientMessage(playerid, COLOR_BLUE, "Yo gave yo turtle sum beans and now it farts all over the place!");
- return 1;
- }
- return 0;
- }
- public OnTurtleUpdate(playerid)
- {
- new Keys[3];
- GetPlayerKeys(playerid, Keys[0], Keys[1], Keys[2]);
- new Float:Pos[9]; //X - Y - Z - rX - rY - rZ - nZ
- GetObjectRot(Turtle[playerid], Pos[3], Pos[4], Pos[5]);
- if(Keys[0] & KEY_JUMP && !(Keys[0] & KEY_SPRINT)) FartsPerSecond[playerid]--;
- if(Keys[0] & KEY_SPRINT && !(Keys[0] & KEY_JUMP)) FartsPerSecond[playerid]++;
- //Rotation part
- 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)));
- //That's quite a line
- //Don't mention this text. I like giving feedback on my own scripting lol.
- SetObjectRot(Turtle[playerid], 0, 0, Pos[5]);
- //Location part - Sarcasm(YAY, YAY, YAY, YAY, YAY, YAY);
- GetObjectPos(Turtle[playerid], Pos[0], Pos[1], Pos[2]);
- Pos[7] = Pos[0] + (floatdiv(FartsPerSecond[playerid], 145) * floatsin(-Pos[5], degrees) * ((Keys[1] == 0) ? (1.0) : (floatdiv(2, 3))));
- Pos[8] = Pos[1] + (floatdiv(FartsPerSecond[playerid], 145) * floatcos(-Pos[5], degrees) * ((Keys[1] == 0) ? (1.0) : (floatdiv(2, 3))));
- #if defined FT
- Pos[2] += ((Keys[1] < 0) ? (-0.333) : (Keys[1] > 0) ? (0.333) : (0.0)) * floatdiv(FartsPerSecond[playerid], 145);
- SetObjectPos(Turtle[playerid], Pos[7], Pos[8], Pos[2]);
- MoveObject(Turtle[playerid], Pos[7], Pos[8], Pos[2], 120);
- #else
- MapAndreas_FindZ_For2DCoord(Pos[7], Pos[8], Pos[6]);
- if(Pos[6] > Pos[2] + 3) SetObjectPos(Turtle[playerid], Pos[0], Pos[1], Pos[2]);
- else if(Pos[6] > Pos[2]) SetObjectPos(Turtle[playerid], Pos[7], Pos[8], Pos[6]);
- else
- {
- Pos[2] += ((Keys[1] < 0) ? (-0.333) : (Keys[1] > 0) ? (0.333) : (0.0)) * floatdiv(FartsPerSecond[playerid], 145);
- SetObjectPos(Turtle[playerid], Pos[7], Pos[8], Pos[2]);
- }
- #endif
- //Camera part. This pisses me off all the time...
- 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);
- Pos[0] -= (68 * floatsin(-Pos[5], degrees));
- Pos[1] -= (68 * floatcos(-Pos[5], degrees));
- SetPlayerCameraPos(playerid, Pos[0], Pos[1], Pos[ ((Pos[6] > Pos[1]+1) ? (6) : (2)) ] + 16);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement