[SA Style] Parachuting System (now colorable!)

Started by Sebastian, Feb 25, 2017, 05:43 PM

Previous topic - Next topic

Sebastian

CREDITS:


Parachuting System
"  I'm presenting you the future  "


Fully controllable parachute, released by using it's own bag
Even able to listen radio, if you really wish to
The only way you can go is down, slowly
It auto-detaches by itself almost everytime you get on ground
Players with high ping won't be disadvantaged




[spoiler=Instalation guide]
1. Download the custom files from >here< and place them in your store
2. Place this script in the top:
srand( GetTickCount() ); // KAKAN's suggestion for a pure random coloring

local wepParaID = 100;  // the weapon ID of the parachute
local vehParaID = 6400;  // the vehicle ID of the parachute

local plrParachute = array( GetMaxPlayers(), 0 );
local forParachute = array( GetMaxPlayers(), 0 );
local g_PlayerFallAccum = array(GetMaxPlayers(), 0.0);

function onPlayerFall(player, speed)
{
    if( speed > 13 ) if( player.Weapon == 100 ) Announce( "Open your parachute!", player, 1 );
}

function _PlayerFallResetFunc()
{
    g_PlayerFallAccum.apply(@(v) 0.0);

for( local i = 0; i <= GetMaxPlayers(); i++ )
{
local player = FindPlayer( i );
if( player )
{
if( (player.Vehicle) && (plrParachute[player.ID]) && (player.Vehicle.ID == plrParachute[player.ID].ID) )
{
if( forParachute[player.ID] == 1 )
{
local vSpd = player.Vehicle.Speed;
player.Vehicle.AddSpeed( Vector( vSpd.x *1.5, vSpd.y *1.5, vSpd.z +0.2 ) );
forParachute[player.ID] = 0;
}
else if( ( player.Vehicle.Speed.z < 0.01 ) && ( player.Vehicle.Speed.z > -0.01 ) )
onPlayerExitVehicle( player, player.Vehicle );
}
}
}
}

local _PlayerFallResetTimer = NewTimer("_PlayerFallResetFunc", 500, 0);

3. This goes under onPlayerMove( player, lastX, lastY, lastZ, newX, newY, newZ ):
if( !player.Vehicle )
{
// Get the speed to avoid too many table lookups
    local speed = g_PlayerFallAccum[player.ID];
   
// Update the accumulated speed
    speed += lastZ > newZ ? lastZ - newZ : 0.0;
   
// Check the accumulated speed
            if (speed > 1.0) onPlayerFall(player, speed);
            else if( player.Weapon == 100 ) Announce( "", player, 1 );
   
// Save the accumulated speed
    g_PlayerFallAccum[player.ID] = speed;
}

4. This one, under onPlayerGameKeysChange( player, oldKey, newKey )
if( ( newKey == KEY_ONFOOT_FIRE ) && ( !player.Vehicle ) && (player.Weapon == wepParaID) && (g_PlayerFallAccum[player.ID] != 0) )
{
player.SetWeapon( wepParaID, 0 );
player.SetWeapon( 0, 0 );

plrParachute[player.ID] = CreateVehicle( vehParaID, 0, player.Pos, 0, 0, 0 );
plrParachute[player.ID].EulerAngle.z = player.Angle ;
plrParachute[player.ID].Colour1 = random( 2, 59 );
plrParachute[player.ID].Colour2 = random( 0, 59 );
player.Vehicle = plrParachute[player.ID];
//player.SetAnim( 0, 161 );
player.Vehicle.Radio = 10;

Announce( "", player, 1 );
forParachute[player.ID] = 1;
}

5. And this one goes in onPlayerExitVehicle( player, vehicle )
if( plrParachute[player.ID] && vehicle.ID == plrParachute[player.ID].ID )
{
vehicle.Delete();
player.SetAnim( 0, 144 );
}

6. Now comes a new function that may be at the end of your script
function random( min, max )
{
// coded by Gudio
        if ( min < max )
                return rand() % (max - min + 1) + min.tointeger();
        else if ( min > max )
                return rand() % (min - max + 1) + max.tointeger();
        else if ( min == max )
                return min.tointeger();
}
[/spoiler]


PS: It might not be perfect, but it is a start.
* sseebbyy waits for your suggestions/complaints

PS2: Is there anybody good in modeling/editing vehicles ?
Since the parachute is a vehicle, it can also have 2 editable colors that will be fun to play with. :D

Done with help from @ermaccer  !

Cool

I will give a try but From Video its looking so cool.
Awesome Work dude

Xmair


Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

MatheuS

if( !sucess ) tryAgain();
Thanks to the VCMP community. It was the happiest period of my life.

rulk

We are all god's children.

Luis_Labarca

Good job, my friend, congratulations :D
My server RP
IP: 51.222.28.159:8194

kennedyarz


PunkNoodle

Seby, simply the most creative person in VC:MP :)

jayant

Innvation Nation !! We would love to see more things <A jetpack :P> @sseebbyy

vito


NicusorN5


Sebastian

#11
Quote from: jayant on Feb 26, 2017, 03:56 AMWe would love to see more things <A jetpack :P>

You have my bless to use this as a base :D

PS: Thanks everyone !

KAKAN

Hope we could do something like that in the client side for a height meter :D
ontopic: Cool work seby. You really are the most creative guy around here :D
oh no

vito

Quote from: KAKAN on Feb 26, 2017, 12:45 PMHope we could do something like that in the client side for a height meter :D
Currently it's possible on client side only with your-own player.Angle and tons of raytrace and it will lag for others players anyway.
So using vehicle it's really best way to avoid lags.

Sebastian

Quote from: vito on Feb 26, 2017, 12:56 PMSo using vehicle it's really best way to avoid lags.

Do you mean it will work using vehicle.Pos.z ? 'cause that's what I believe will do the job.
Unfortunately, I won't work on such a thing yet, since I'm still learning client-side scripting.