Vice City: Multiplayer

Server Development => Scripting and Server Management => Snippet Showroom => Topic started by: . on Jul 16, 2015, 06:34 PM

Title: Player falling implementation.
Post by: . on Jul 16, 2015, 06:34 PM
Just a small idea that shows how to see if a player is falling. The 'speed' isn't actually the real speed because it's not accurate. Because even if the player stopped falling, it still shows the last highest speed until it's reset. A more frequent timer should fix that with the added 'bonus' of more computation required. But the function that the timer calls is very lightweight and I doubt a faster timer would do any harm.

local g_PlayerFallAccum = array(GetMaxPlayers(), 0.0);

function onPlayerFall(player, speed)
{
    print(player.Name + " is falling with speed " + speed);
}

function onPlayerMove(player, px, py, pz, cx, cy, cz)
{
    // Get the speed to avoid too many table lookups
    local speed = g_PlayerFallAccum[player.ID];
    // Update the accumulated speed
    speed += pz > cz ? pz - cz : 0.0;
    // Check the accumulated speed
    if (speed > 1.0) onPlayerFall(player, speed);
    // Save the accumulated speed
    g_PlayerFallAccum[player.ID] = speed;
}

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

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

Have phun ;D
Title: Re: Player falling implementation.
Post by: Sebastian on Jul 17, 2015, 11:16 AM
All we need now is a Height meter like in San Andreas.
(and maybe a parachute, using custom vehicle, and the bag, using custom weapon)

(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi.imgur.com%2FZ73RwPJ.jpg&hash=c1d5539cc659824875bea256ad6f69cd90fb5082)
Title: Re: Player falling implementation.
Post by: Murdock on Jul 17, 2015, 12:26 PM
Quote from: sseebbyy on Jul 17, 2015, 11:16 AMAll we need now is a Height meter like in San Andreas.
(and maybe a parachute, using custom vehicle, and the bag, using custom weapon)

What about using a custom weapon (hat), using a model of a parachute?
Then all we need is to set player's gravity and we'd have some sort of parachute
Title: Re: Player falling implementation.
Post by: Gudio on Jul 17, 2015, 12:26 PM
Parachute? No problemo
- custom weapon to have parachute above the head,
- altimeter by using sprites,
- controlling the parachute by pressing keys.
No vehicle required.

Back to the topic. This snippet script can be used to detect if player is using some external software like teleporting or speed hacks. Ofc we need to remember that while setting player's position, it's needed to set some value to stop detecking player's speed for a moment.
Title: Re: Player falling implementation.
Post by: Sebastian on Jul 17, 2015, 01:52 PM
Quote from: Gudio on Jul 17, 2015, 12:26 PMNo vehicle required.

There is no player.Gravity function in 0.4, so for a more real feeling you will need a vehicle that has weight and handling. ( a car with FlyingMode on )
Also, you can remove the "parachute" when the vehicle is damaged. ( with some sort of colision, it will be damaged even when touching the land )

No keybinds required.

Also, I believe you can use proper animations.

PS: if you are going to create that altimeter, enable it for helicopter/planes too. :)
Title: Re: Player falling implementation.
Post by: [VSS]Shawn on Jul 17, 2015, 01:52 PM
so Gudio when are u posting that system?? xD
Title: Re: Player falling implementation.
Post by: KAKAN on Jul 17, 2015, 02:12 PM
Don't post shit, if u think u r a good scripter, then go script, I dare that u can't even make a countdown cmd
Title: Re: Player falling implementation.
Post by: . on Jul 17, 2015, 02:20 PM
Quote from: [VSS]Shawn on Jul 17, 2015, 01:52 PMso Gudio when are u posting that system?? xD

Stop entering conversations you can't understand you noobs.
Title: Re: Player falling implementation.
Post by: Murdock on Jul 17, 2015, 02:31 PM
Quote from: sseebbyy on Jul 17, 2015, 01:52 PMThere is no player.Gravity function in 0.4

You should post that in the suggestions board, it should've been a compatibility function (as in 0.3) already imo
Title: Re: Player falling implementation.
Post by: Thijn on Jul 17, 2015, 07:02 PM
Insulting replies removed. Keep it nice. Keep it clean.
Title: Re: Player falling implementation.
Post by: DizzasTeR on Jul 18, 2015, 03:25 AM
Quote from: Thijn on Jul 17, 2015, 07:02 PMInsulting replies removed. Keep it nice. Keep it clean.

I just showed a reality, anyway as I said in my previous reply here, This could be useful, I have some ideas that will need the use of this function ;)