Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local DEFAULT_LONGJUMP_MAGNITUDE = 0.08; // Increase the value if you want to make player jump higher.
- local DEFAULT_COOLDOWN_TIME = 2; // Time in seconds. If players spam the jump key, they fly.
- gLongjump <- {}; // Global table to store instances of CLongjump
- class CLongjump
- {
- player = null; // The player who enabled long jump
- magnitude = 0; // The magnitude of longjump for the player
- lastJump = 0; // The timestamp of last executed jump.
- constructor( player )
- {
- this.player = player;
- this.magnitude = DEFAULT_LONGJUMP_MAGNITUDE;
- this.lastJump = 0;
- this.player.Immunity = 8; // Set player immune to fall damage
- gLongjump.rawset( player.ID, this ); // Store this instance in the global table
- }
- }
- function onPlayerGameKeysChange( player, old, new )
- {
- if( gLongjump.rawin( player.ID ) ) // Check if player has enabled longjump, exists in global table
- {
- local pLongjump = gLongjump.rawget( player.ID ); // Fetch the instance of CLongjump
- if( time() - pLongjump.lastJump > DEFAULT_COOLDOWN_TIME ) // Only 1 jump allowed in 2 seconds.
- {
- if( new - old == 2048 ) // Detects jump keypress
- {
- player.Speed.z += pLongjump.magnitude; // Set Z speed higher
- player.Speed += player.Speed; // Set overall speed higher
- pLongjump.lastJump = time(); // Cache player's last executed jump.
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement