Vice City: Multiplayer

Server Development => Scripting and Server Management => Snippet Showroom => Topic started by: Sebastian on Feb 25, 2017, 05:43 PM

Title: [SA Style] Parachuting System (now colorable!)
Post by: Sebastian on Feb 25, 2017, 05:43 PM
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


https://youtu.be/SKOGkIwgmNI

now colorable: http://i.imgur.com/XRsAdMl.png

[spoiler=Instalation guide]
1. Download the custom files from >here< (http://www.mediafire.com/file/fp67yjr2j9nr31h/VCMP+Parachute+%28wep%2C+veh%29+v2.zip) 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.
/me 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  !
Title: Re: [SA Style] Parachuting System
Post by: Cool on Feb 25, 2017, 06:01 PM
I will give a try but From Video its looking so cool.
Awesome Work dude
Title: Re: [SA Style] Parachuting System
Post by: Xmair on Feb 25, 2017, 06:06 PM
Well done.
Title: Re: [SA Style] Parachuting System
Post by: MatheuS on Feb 25, 2017, 07:04 PM
Nice job Seby! ;D
Title: Re: [SA Style] Parachuting System
Post by: rulk on Feb 25, 2017, 07:24 PM
innovative, love it!!
Title: Re: [SA Style] Parachuting System
Post by: Luis_Labarca on Feb 25, 2017, 08:06 PM
Good job, my friend, congratulations :D
Title: Re: [SA Style] Parachuting System
Post by: kennedyarz on Feb 25, 2017, 10:04 PM
nice nice nice nice nice
Title: Re: [SA Style] Parachuting System
Post by: PunkNoodle on Feb 26, 2017, 01:19 AM
Seby, simply the most creative person in VC:MP :)
Title: Re: [SA Style] Parachuting System
Post by: jayant on Feb 26, 2017, 03:56 AM
Innvation Nation !! We would love to see more things <A jetpack :P> @sseebbyy
Title: Re: [SA Style] Parachuting System
Post by: vito on Feb 26, 2017, 05:51 AM
good job
Title: Re: [SA Style] Parachuting System
Post by: NicusorN5 on Feb 26, 2017, 06:47 AM
Good job ^^ !
Title: Re: [SA Style] Parachuting System
Post by: Sebastian on Feb 26, 2017, 09:54 AM
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 !
Title: Re: [SA Style] Parachuting System
Post by: KAKAN on Feb 26, 2017, 12:45 PM
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
Title: Re: [SA Style] Parachuting System
Post by: vito on Feb 26, 2017, 12:56 PM
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.
Title: Re: [SA Style] Parachuting System
Post by: Sebastian on Feb 26, 2017, 01:27 PM
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.
Title: Re: [SA Style] Parachuting System
Post by: jayant on Feb 26, 2017, 01:56 PM
@sseebbyy - Used your code base with some changes and now I got working jetpack,but for some seconds. It was fun.
Title: Re: [SA Style] Parachuting System
Post by: Diego^ on Mar 02, 2017, 02:04 PM
Good job, @sseebbyy :)
Title: Re: [SA Style] Parachuting System (now colorable!)
Post by: Sebastian on Mar 04, 2017, 10:22 PM
Update

Changelog:

First post was updated with new download link + some code edits.

(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi.imgur.com%2FXRsAdMl.png&hash=e257713a5c36e68db986ad00ff3a7b9afe8d5a31)
Title: Re: [SA Style] Parachuting System (now colorable!)
Post by: Luis_Labarca on Mar 05, 2017, 02:27 AM
Quote from: sseebbyy on Mar 04, 2017, 10:22 PMUpdate

Changelog:
  • made parachute be colorable (in 2 colors)
  • changed animation ID when player "detaches" parachute - to avoid a bug
  • made parachute spawn in random colors by start

First post was updated with new download link + some code edits.

(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi.imgur.com%2FXRsAdMl.png&hash=e257713a5c36e68db986ad00ff3a7b9afe8d5a31)
Cool friend :D

Title: Re: [SA Style] Parachuting System (now colorable!)
Post by: KAKAN on Mar 05, 2017, 05:31 AM
To note: onPlayerGameKeysChange doesn't work with secondary keys.
Random function can be updated to a better one. Also, to make it truly random, add a srand( GetTickCount() ); to it.
Title: Re: [SA Style] Parachuting System (now colorable!)
Post by: Sebastian on Mar 05, 2017, 03:50 PM
Quote from: KAKAN on Mar 05, 2017, 05:31 AMAlso, to make it truly random, add a srand( GetTickCount() ); to it.

That's some really old code written by Gudio, but it was doing it's job.
Never thought of a better one, because I didn't really need one.

But now may be the moment. How exactly should I use that srand( GetTickCount() ) ?
Title: Re: [SA Style] Parachuting System (now colorable!)
Post by: DizzasTeR on Mar 05, 2017, 04:06 PM
Quote from: sseebbyy on Mar 05, 2017, 03:50 PMBut now may be the moment. How exactly should I use that srand( GetTickCount() ) ?

The srand inserts a seed which is used by the rand function in its algorithm. In this case GetTickCount which is being changed every second. Making a seed with srand( GetTickCount() ) will set a unique seed everytime the script runs so it will generate a pure random number rather than a sequential default seed one.

Hope I you get it.

p.s: inb4 someone comes and says that's not what srand does in squirrel ;D cuz I forgot
Title: Re: [SA Style] Parachuting System (now colorable!)
Post by: Sebastian on Mar 05, 2017, 04:14 PM
Quote from: Doom_Kill3R on Mar 05, 2017, 04:06 PM.

Oh, this is pretty cool. Thank you !



First post updated !

Now the parachute will get really random colors, thanks to @KAKAN 's suggestion.
Title: Re: [SA Style] Parachuting System (now colorable!)
Post by: Luis_Labarca on Apr 19, 2017, 05:24 PM
Bro I've tried this great

Suggestion to these changes

add local ParachuteWorldID = 0;  // the vehicle WorldID of the parachute

Change
if( player.Weapon == 100) Announce( "Open your parachute!", player, 1 );
to
if( player.Weapon == wepParaID) Announce( "Open your parachute!", player, 1 );

Change
if( ( newKey == KEY_ONFOOT_FIRE ) && ( !player.Vehicle ) && (player.Weapon == 100) && (g_PlayerFallAccum[player.ID] != 0) )
to
if( ( newKey == KEY_ONFOOT_FIRE ) && ( !player.Vehicle ) && (player.Weapon == wepParaID) && (g_PlayerFallAccum[player.ID] != 0) )


Change
plrParachute[player.ID] = CreateVehicle( 6400, 0, player.Pos, 0, 0, 0 );
to
plrParachute[player.ID] = CreateVehicle( vehParaID, 0, player.Pos, 0, 0, 0 );

I suggest those changes because I thought it did not work because I changed wepParaID = 100; To the correct id on my server and as there were functions like if (player.Weapon == 100) Announce ("Open your parachute!", Player, 1); I did not work but now
Title: Re: [SA Style] Parachuting System (now colorable!)
Post by: kennedyarz on Apr 19, 2017, 10:02 PM
Quote from: Luis_Labarca on Apr 19, 2017, 05:24 PMBro I've tried this great

Suggestion to these changes

add local ParachuteWorldID = 0;  // the vehicle WorldID of the parachute

Change
if( player.Weapon == 100) Announce( "Open your parachute!", player, 1 );
to
if( player.Weapon == wepParaID) Announce( "Open your parachute!", player, 1 );

Change
if( ( newKey == KEY_ONFOOT_FIRE ) && ( !player.Vehicle ) && (player.Weapon == 100) && (g_PlayerFallAccum[player.ID] != 0) )
to
if( ( newKey == KEY_ONFOOT_FIRE ) && ( !player.Vehicle ) && (player.Weapon == wepParaID) && (g_PlayerFallAccum[player.ID] != 0) )


Change
plrParachute[player.ID] = CreateVehicle( 6400, 0, player.Pos, 0, 0, 0 );
to
plrParachute[player.ID] = CreateVehicle( vehParaID, 0, player.Pos, 0, 0, 0 );

I suggest those changes because I thought it did not work because I changed wepParaID = 100; To the correct id on my server and as there were functions like if (player.Weapon == 100) Announce ("Open your parachute!", Player, 1); I did not work but now

You're not doing anything, it's the same thing, for me it's always worked like this
Title: Re: [SA Style] Parachuting System (now colorable!)
Post by: Luis_Labarca on Apr 20, 2017, 01:24 AM
Quote from: kennedyarz on Apr 19, 2017, 10:02 PM
Quote from: Luis_Labarca on Apr 19, 2017, 05:24 PMBro I've tried this great

Suggestion to these changes

add local ParachuteWorldID = 0;  // the vehicle WorldID of the parachute

Change
if( player.Weapon == 100) Announce( "Open your parachute!", player, 1 );
to
if( player.Weapon == wepParaID) Announce( "Open your parachute!", player, 1 );

Change
if( ( newKey == KEY_ONFOOT_FIRE ) && ( !player.Vehicle ) && (player.Weapon == 100) && (g_PlayerFallAccum[player.ID] != 0) )
to
if( ( newKey == KEY_ONFOOT_FIRE ) && ( !player.Vehicle ) && (player.Weapon == wepParaID) && (g_PlayerFallAccum[player.ID] != 0) )


Change
plrParachute[player.ID] = CreateVehicle( 6400, 0, player.Pos, 0, 0, 0 );
to
plrParachute[player.ID] = CreateVehicle( vehParaID, 0, player.Pos, 0, 0, 0 );

I suggest those changes because I thought it did not work because I changed wepParaID = 100; To the correct id on my server and as there were functions like if (player.Weapon == 100) Announce ("Open your parachute!", Player, 1); I did not work but now

You're not doing anything, it's the same thing, for me it's always worked like this

My suggestion is not for you :P
Title: Re: [SA Style] Parachuting System (now colorable!)
Post by: MatheuS on Apr 20, 2017, 01:58 AM
Quote from: Luis_Labarca on Apr 20, 2017, 01:24 AM
Quote from: kennedyarz on Apr 19, 2017, 10:02 PM
Quote from: Luis_Labarca on Apr 19, 2017, 05:24 PMBro I've tried this great

Suggestion to these changes

add local ParachuteWorldID = 0;  // the vehicle WorldID of the parachute

Change
if( player.Weapon == 100) Announce( "Open your parachute!", player, 1 );
to
if( player.Weapon == wepParaID) Announce( "Open your parachute!", player, 1 );

Change
if( ( newKey == KEY_ONFOOT_FIRE ) && ( !player.Vehicle ) && (player.Weapon == 100) && (g_PlayerFallAccum[player.ID] != 0) )
to
if( ( newKey == KEY_ONFOOT_FIRE ) && ( !player.Vehicle ) && (player.Weapon == wepParaID) && (g_PlayerFallAccum[player.ID] != 0) )


Change
plrParachute[player.ID] = CreateVehicle( 6400, 0, player.Pos, 0, 0, 0 );
to
plrParachute[player.ID] = CreateVehicle( vehParaID, 0, player.Pos, 0, 0, 0 );

I suggest those changes because I thought it did not work because I changed wepParaID = 100; To the correct id on my server and as there were functions like if (player.Weapon == 100) Announce ("Open your parachute!", Player, 1); I did not work but now

You're not doing anything, it's the same thing, for me it's always worked like this

My suggestion is not for you :P

He only gave his opinion.

And he was right.
Title: Re: [SA Style] Parachuting System (now colorable!)
Post by: kennedyarz on Apr 20, 2017, 02:25 AM
Quote from: MatheuS on Apr 20, 2017, 01:58 AM
Quote from: Luis_Labarca on Apr 20, 2017, 01:24 AM
Quote from: kennedyarz on Apr 19, 2017, 10:02 PM
Quote from: Luis_Labarca on Apr 19, 2017, 05:24 PMBro I've tried this great

Suggestion to these changes

add local ParachuteWorldID = 0;  // the vehicle WorldID of the parachute

Change
if( player.Weapon == 100) Announce( "Open your parachute!", player, 1 );
to
if( player.Weapon == wepParaID) Announce( "Open your parachute!", player, 1 );

Change
if( ( newKey == KEY_ONFOOT_FIRE ) && ( !player.Vehicle ) && (player.Weapon == 100) && (g_PlayerFallAccum[player.ID] != 0) )
to
if( ( newKey == KEY_ONFOOT_FIRE ) && ( !player.Vehicle ) && (player.Weapon == wepParaID) && (g_PlayerFallAccum[player.ID] != 0) )


Change
plrParachute[player.ID] = CreateVehicle( 6400, 0, player.Pos, 0, 0, 0 );
to
plrParachute[player.ID] = CreateVehicle( vehParaID, 0, player.Pos, 0, 0, 0 );

I suggest those changes because I thought it did not work because I changed wepParaID = 100; To the correct id on my server and as there were functions like if (player.Weapon == 100) Announce ("Open your parachute!", Player, 1); I did not work but now

You're not doing anything, it's the same thing, for me it's always worked like this

My suggestion is not for you :P

He only gave his opinion.

And he was right.

exact. Besides, I better shut up ...
Title: Re: [SA Style] Parachuting System (now colorable!)
Post by: Sebastian on Apr 21, 2017, 09:19 AM
Good point.
I've updated the code. Thank you.

Report anything else wrong, if there is any. :)
Title: Re: [SA Style] Parachuting System (now colorable!)
Post by: vito on Apr 21, 2017, 09:24 AM
Can you tell me where model taken from? I'm going to use it in my server so I need credits of model, thanks.
Title: Re: [SA Style] Parachuting System (now colorable!)
Post by: luchgox on Apr 21, 2017, 10:44 AM
tutorial for installation?
Title: Re: [SA Style] Parachuting System (now colorable!)
Post by: Cool on Apr 21, 2017, 11:17 AM
Quote from: QW.jester on Apr 21, 2017, 10:44 AMtutorial for installation?
Noob Stick to Play
(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi66.tinypic.com%2F34jb1ue.png&hash=b6a8ef7c14c6db1fa1187beac5e48e8e56312d62)
Title: Re: [SA Style] Parachuting System (now colorable!)
Post by: Sebastian on Apr 21, 2017, 12:16 PM
Quote from: vito on Apr 21, 2017, 09:24 AMCan you tell me where model taken from? I'm going to use it in my server so I need credits of model, thanks.

From GTA:SanAndreas, edited by me.
Title: Re: [SA Style] Parachuting System (now colorable!)
Post by: kennedyarz on May 19, 2017, 09:51 PM
Suggestion to avoid annoying warning whenever you have the parachute. The ad will only appear when you reach a speed of at least 150 m/s that is when you fall.

if (speed > 150.0) onPlayerFall(player, speed);
You can see its speed using this... Just to check. Do not leave it there

AnnounceAll ( speed + "", 0);
Then, for the data to be deleted to prevent the ad from continuing to appear, use this

if ( player.Pos.z < 20 ) speed = 0;
Then everything will be better. and it will be like this

speed += lastZ > newZ ? lastZ - newZ : 0.0;
AnnounceAll ( speed + "", 0);
if (speed > 150.0) onPlayerFall(player, speed);
if ( player.Pos.z < 20 ) speed = 0;

But without this AnnounceAll ( speed + "", 0);

Title: Re: [SA Style] Parachuting System (now colorable!)
Post by: Sebastian on May 19, 2017, 10:26 PM
Quote from: kennedyarz on May 19, 2017, 09:51 PMSuggestion to avoid annoying warning whenever you have the parachute. The ad will only appear when you reach a speed

Thanks ! Got the point and did the update.

Changelog:
Title: Re: [SA Style] Parachuting System (now colorable!)
Post by: [TkD]MarineForce123 on Jun 16, 2017, 06:59 AM
AweSome Best I Like Plese You enjoy Parachuting System in my server :

 http://www49.zippyshare.com/v/36387578/file.html
http://www.mediafire.com/file/fp67yjr2j9nr31h/VCMP+Parachute+%28wep%2C+veh%29+v2.zip

Enjoy In The Server cmd  Parachuting System   



Help me
@Shadow
@sseebbyy
@ermaccer
Title: Re: [SA Style] Parachuting System (now colorable!)
Post by: Sebastian on Jun 27, 2017, 07:13 PM
Quote from: [TkD]MarineForce123 on Jun 16, 2017, 06:59 AMAweSome Best I Like Plese You enjoy Parachuting System in my server :

It is pretty easy to implement it in your server buddy, just give it a try.
If you face problems, show us a screenshot with the error and the line provoking the error. We will help.
(it's all about copy/paste and following the written instructions)
Title: Re: [SA Style] Parachuting System (now colorable!)
Post by: Mahmoud Tornado on Aug 26, 2017, 05:56 PM
Cool Man!