Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Hot air balloon filterscript by Srdjan
- // Date is 01/11/2011
- #include <a_samp>
- #include <mapandreas>
- #define KEY_AIM 128
- #define MAX_BALLOONS 10
- new BalloonID[MAX_BALLOONS];
- new PlayerInBalloon[MAX_PLAYERS];
- new Float: BalloonSpeed[MAX_BALLOONS];
- new Float: Radius[MAX_BALLOONS];
- new Float: Diametar[MAX_BALLOONS];
- new ResetTimer[MAX_BALLOONS];
- new ContinueTimer[MAX_BALLOONS];
- new Text:commands;
- forward ResetSpeed (objectid);
- forward Continue (objectid);
- public OnFilterScriptInit ()
- {
- CreateBalloons ();
- commands = TextDrawCreate (30.0, 270.0,"~w~Commands:~n~Sprint key - speed up~n~Jump key - speed down~n~Key 'Y' - Tilt down~n~Key 'N' - Tilt up~n~LMB - Angle of heading - left~n~RMB - Angle of heading - right");
- TextDrawFont (commands, 2);
- TextDrawLetterSize (commands, 0.3, 0.8);
- MapAndreas_Init (MAP_ANDREAS_MODE_FULL);
- for (new i = 0; i < MAX_PLAYERS; i++) PlayerInBalloon[i] = -1;
- printf ("\nHot Air Balloon by Srdjan loaded.\n");
- return 1;
- }
- CreateBalloons ()
- {
- BalloonID[0] = CreateObject (19334, 198.9927, -1832.8091, 3.0, 0.0, 0.0, 0.0, 300.0);
- BalloonID[1] = CreateObject (19335, 241.3257, -1834.1189, 3.0, 0.0, 0.0, 0.0, 300.0);
- BalloonID[2] = CreateObject (19336, 284.8625, -1830.8752, 3.0, 0.0, 0.0, 0.0, 300.0);
- for (new i = 0; i < 3; i++)
- {
- new id = CreateObject (18699, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 300.0);
- AttachObjectToObject (id, BalloonID[i], 0.0, 0.0, 5.5, 0.0, 180.0, 0.0, 1);
- }
- }
- public OnPlayerCommandText (playerid, cmdtext[])
- {
- if (!strcmp (cmdtext, "/operate"))
- {
- if (PlayerInBalloon[playerid] != -1)
- {
- ClearAnimations (playerid);
- TextDrawHideForPlayer (playerid, commands);
- PlayerInBalloon[playerid] = -1;
- }
- else
- {
- if (GetPlayerBalloonID (playerid, 0) > -1)
- {
- ApplyAnimation (playerid, "GANGS", "leanIDLE", 4.1, 1, 1, 1, 1, 0, 1);
- TextDrawShowForPlayer (playerid, commands);
- PlayerInBalloon[playerid] = GetPlayerBalloonID (playerid, 0);
- }
- else if (GetPlayerBalloonID (playerid, 1) > -1)
- {
- new objectid = BalloonID[GetPlayerBalloonID (playerid, 1)];
- if (IsObjectMoving (objectid))
- {
- ApplyAnimation (playerid, "GANGS", "leanIDLE", 4.1, 1, 1, 1, 1, 0, 1);
- TextDrawShowForPlayer (playerid, commands);
- PlayerInBalloon[playerid] = GetPlayerBalloonID (playerid, 1);
- }
- }
- }
- return 1;
- }
- return 0;
- }
- GetPlayerBalloonID (playerid, b)
- {
- new Float: x, Float: y, Float: z;
- for (new i = 0; i < sizeof (BalloonID); i++)
- {
- GetObjectPos (BalloonID[i], x, y, z);
- if (!b)
- {
- if (!IsPlayerInRangeOfPoint (playerid, 1.5, x, y, z)) continue;
- else return i;
- }
- else if (b)
- {
- if (!IsPlayerInRangeOfPoint (playerid, 5.0, x, y, z)) continue;
- else return i;
- }
- }
- return -1;
- }
- public OnPlayerKeyStateChange (playerid, newkeys, oldkeys)
- {
- if (PlayerInBalloon[playerid] > -1)
- {
- new objectid = BalloonID[PlayerInBalloon[playerid]];
- if ((newkeys & KEY_SPRINT) && !(oldkeys & KEY_SPRINT))
- {
- if (BalloonSpeed[objectid] < 15.0) BalloonSpeed[objectid] += 0.5;
- }
- if ((newkeys & KEY_JUMP) && !(oldkeys & KEY_JUMP))
- {
- if (BalloonSpeed[objectid] > -10.0) BalloonSpeed[objectid] -= 0.5;
- }
- if ((newkeys & KEY_YES) && !(oldkeys & KEY_YES))
- {
- if (Radius[objectid] < 90.0) Radius[objectid] += 5.0;
- }
- if ((newkeys & KEY_NO) && !(oldkeys & KEY_NO))
- {
- if (Radius[objectid] > 0.0) Radius[objectid] -= 5.0;
- }
- if ((newkeys & KEY_FIRE) && !(oldkeys & KEY_FIRE))
- {
- Diametar[objectid] -= 5.0;
- if (Diametar[objectid] < 0.0) Diametar[objectid] = -5.0;
- }
- if ((newkeys & KEY_AIM) && !(oldkeys & KEY_AIM))
- {
- Diametar[objectid] += 5.0;
- if (Diametar[objectid] > 360.0) Diametar[objectid] = 5.0;
- }
- UpdateBalloonMove (objectid);
- }
- return 1;
- }
- UpdateBalloonMove (objectid)
- {
- StopObject (objectid);
- if (BalloonSpeed[objectid] > 0.0)
- {
- Continue (objectid);
- }
- else if (BalloonSpeed[objectid] < 0.0)
- {
- KillTimer (ResetTimer[objectid]);
- new Float: x, Float: y, Float: z;
- GetObjectPos (objectid, x, y, z);
- MapAndreas_FindZ_For2DCoord (x, y, z);
- new time = MoveObject (objectid, x, y, z, floatabs(BalloonSpeed[objectid]));
- ResetTimer[objectid] = SetTimerEx ("ResetSpeed", time, 0, "d", objectid);
- }
- }
- public ResetSpeed (objectid)
- {
- if (BalloonSpeed[objectid] < 0.0) BalloonSpeed[objectid] = 0.0;
- if (Radius[objectid] > 0.0) Radius[objectid] = 0.0;
- }
- public Continue (objectid)
- {
- new Float: x, Float: y, Float: z;
- GetObjectPos (objectid, x, y, z);
- KillTimer (ResetTimer[objectid]);
- KillTimer (ContinueTimer[objectid]);
- z = z + 300 * floatcos (-Radius[objectid], degrees);
- x = x + 1000 * floatsin (-Radius[objectid], degrees) * floatcos (-Diametar[objectid], degrees);
- y = y + 1000 * floatsin (-Radius[objectid], degrees) * floatsin (-Diametar[objectid], degrees);
- new time = MoveObject (objectid, x, y, z, BalloonSpeed[objectid]);
- ContinueTimer[objectid] = SetTimerEx ("Continue", time-2, 0, "d", objectid);
- }
Advertisement
Add Comment
Please, Sign In to add comment