Player falling implementation.

Started by ., Jul 16, 2015, 06:34 PM

Previous topic - Next topic

.

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
.

Sebastian

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)


Murdock

#2
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

Gudio

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.

Sebastian

#4
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. :)

[VSS]Shawn

so Gudio when are u posting that system?? xD

KAKAN

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
oh no

.

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.
.

Murdock

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

Thijn

Insulting replies removed. Keep it nice. Keep it clean.

DizzasTeR

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 ;)