[Include] [INC] Hot air balloon (flying system)
#1

What is this?
This is a script which allows you to fly on the hot air balloon-objects. It can be useful if you want to have some fun.


Pictures:
/imageshack/img837/7615/73375682.png
/imageshack/img404/3717/95324615.png
/imageshack/img543/5105/88085357.png
/imageshack/img69/3102/79696899.png


Credits:
- ****** for foreach & GetXYInFrontOfPlayer functions,
- ZeeX for zcmd command processor.


How to install?
It's easy and simple - download and put the hab.inc into the \pawno\include\ folder and do the same thing with the foreach.inc and zcmd.inc file.
Open your script and put this:
pawn Код:
#include <foreach>
#include <zcmd>
#include <hab>
right after the
pawn Код:
#include <a_samp>
Put the balloons in the OnGameModeInit callback.
Example:
pawn Код:
/*
CreateHotAirBalloon(modelid, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz = 0.0);
*/

CreateHotAirBalloon(1, 1461.8, -2544.3, 12.51, 0.0, 0.0, 0.0);
CreateHotAirBalloon(2, 1511.8, -2544.3, 12.51, 0.0, 0.0, 0.0);
CreateHotAirBalloon(5, 1561.8, -2544.3, 12.51, 0.0, 0.0, 0.0);
CreateHotAirBalloon(3, 1731.8, -2544.3, 12.51, 0.0, 0.0, 0.0);
CreateHotAirBalloon(7, 1791.8, -2544.3, 12.51, 0.0, 0.0, 0.0);
These 5 balloons are located at the Los Santos Airport. Here are the spawn coordinates:
pawn Код:
1560.0, -2530.0, 13.547

Functions:
CreateHotAirBalloon
Adds the hot air balloon to the server.
@modelid = Model-ID of the balloon - valid model-IDs are from 1 to 7.
@Float: x = Balloon spawn X position.
@Float: y = Balloon spawn Y position.
@Float: z = Balloon spawn Z position.
@Float: rx = Balloon spawn X rotation.
@Float: ry = Balloon spawn Y rotation.
@Float: rz = Balloon spawn Z rotation.
returns the balloon ID which starts with 0. If you exceed the MAX_HOT_AIR_BALLOONS define then it will return the invalid ID which is -1.
Example:
pawn Код:
new
        gBalloon = -1;

public OnGameModeInit()
{
    gBalloon = CreateHotAirBalloon(1, 1461.8, -2544.3, 12.51, 0.0, 0.0, 0.0);
    return true;
}
DestroyHotAirBalloon
Deletes the hot air balloon from the server.
@habid = The balloon ID.
returns true if the balloon is valid and false if it's not.
Example:
pawn Код:
DestroyHotAirBalloon(gBalloon);
IsHotAirBalloonCreated
Checks if hot air balloon is created.
@habid = The balloon ID.
returns true if the balloon is valid and false if it's not.
Example:
pawn Код:
if(IsHotAirBalloonCreated(gBalloon)) printf("Balloon is created.");
else printf("Balloon is NOT created.");
StopHotAirBalloon
Stops the hot air balloon.
@habid = The balloon ID.
returns true if the balloon is valid and false if it's not.
Example:
pawn Код:
StopHotAirBalloon(gBalloon);
RespawnHotAirBalloon
Re-spawns the hot air balloon.
@habid = The balloon ID.
returns true if the balloon is valid and false if it's not.
Example:
pawn Код:
RespawnHotAirBalloon(gBalloon);
SetHotAirBalloonSpeed
Sets the speed of the hot air balloon.
@habid = The balloon ID.
@balloonspeed = The speed to set for the balloon.
returns true if the balloon is valid and false if it's not.
If the you set the speed which is higher than MAX_HOT_AIR_BALLOON_SPEED, then the function will automatically set it to the MAX_HOT_AIR_BALLOON_SPEED.
Example:
This will set the speed of the balloon to 3.5:
pawn Код:
SetHotAirBalloonSpeed(gBalloon, 3.5);
This will set the speed of the balloon to the maximum (which is defined with MAX_HOT_AIR_BALLOON_SPEED):
pawn Код:
SetHotAirBalloonSpeed(gBalloon);
IsPlayerAtHotAirBalloon
Checks if player is near the hot air balloon.
@playerid = The ID of the player.
@habid = The balloon ID.
returns true if the player is near the balloon and false if he isn't.
Example:
pawn Код:
if(IsPlayerAtHotAirBalloon(playerid, gBalloon)) printf("Player is near the balloon with ID %i.", gBalloon);
else printf("Player is NOT near the balloon with ID %i.", gBalloon);
IsPlayerAtAnyHotAirBalloon
Checks if player is near any hot air balloon.
@playerid = The ID of the player.
returns ID of the balloon which stars with 0 if player is near any balloon and -1 is he's not.
Example:
pawn Код:
new
        gBalloon = IsPlayerAtAnyHotAirBalloon(playerid);

if(gBalloon != -1) printf("Player is near the balloon with ID %i.", gBalloon);
else printf("Player is NOT near any balloon.");

Defines:
pawn Код:
#define MAX_HOT_AIR_BALLOONS (5)
#define MAX_HOT_AIR_BALLOON_SPEED (10.0)
MAX_HOT_AIR_BALLOONS - The maximum amount of balloons allowed for script to load on the server.
MAX_HOT_AIR_BALLOON_SPEED - The maximum speed of the balloon. It shouldn't be too big.


How to get coordinates for balloons?
I myself am using JernejL's REAL Map Editor, in which I place the hot air balloon objects (IDs: from 19332 to 19338 ID) where I want to have them. This Map Editor is not for people with weak computers, so if you have a weak computer, you can use any other Map Editor which supports new 0.3e objects such as these hot air balloons. The z rotation is the rotation of the balloon.


Download:
http://www.solidfiles.com/d/79cb75ec23


Other:
If you want to start with the flying, then get near the balloon (jump inside of it) and use the "/balloon" command. If you want to stop with the flying, then use the "/balloon" command once again.

Use keys (arrow UP, arrow DOWN, arrow LEFT, arrow RIGHT, JUMP and SPRINT) to control the balloon's movement:
arrow UP = forward
arrow DOWN = stopping
arrow LEFT = turn left
arrow RIGHT = turn right
JUMP = go up
SPRINT = go down

When you delete the last balloon then the timer will stop so you don't have to do anything, and when you add the first balloon then it will start again.

If you fall of from the balloon, then the balloon will automatically re-spawn. It will also automatically re-spawn if you fly into the object (example - mountain).

There is a height limit (z coordinate) in the include:
- Limit of lowest height is 2.0,
- limit of highest height is 700.0.
Reply
#2

Wow, that's nice
Reply
#3

Wait so its an object attached\replaced vehicle model or its an actual flying object ?
Reply
#4

Nice
Reply
#5

Quote:
Originally Posted by xkirill
Посмотреть сообщение
Wait so its an object attached\replaced vehicle model or its an actual flying object ?
This is the sub-forum for scripts, not mods, so yes - it's an actual flying object - check the source code.
Reply
#6

Quote:
Originally Posted by Correlli
Посмотреть сообщение
This is the sub-forum for scripts, not mods, so yes - it's an actual flying object - check the source code.
Well you can also attach it to a vehicle, and make vehicle invisible, maybe that's what he meant
Reply
#7

Quote:
Originally Posted by [P4]
Посмотреть сообщение
Well you can also attach it to a vehicle, and make vehicle invisible, maybe that's what he meant
In one part of his sentence I can see that he meant object attachment, but in other where he's talking about "replaced vehicle model" I thought he means the modding. But however, like I said - it's player controlled object.
Reply
#8

Good Job Correlli, I might use it for my next release.
Reply
#9

He can fly thorugh walls or not?
Reply
#10

Good job! If only we could sync this better so players stick inside the object..
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)