Guest User

Untitled

a guest
Jun 24th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. If ( player.World == 2 ) return 0;
  2. local DEFAULT_LONGJUMP_MAGNITUDE = 0.08; // Increase the value if you want to make player jump higher.
  3. local DEFAULT_COOLDOWN_TIME = 2; // Time in seconds. If players spam the jump key, they fly.
  4.  
  5. gLongjump <- {}; // Global table to store instances of CLongjump
  6.  
  7. class CLongjump
  8. {
  9. player = null; // The player who enabled long jump
  10. magnitude = 0; // The magnitude of longjump for the player
  11. lastJump = 0; // The timestamp of last executed jump.
  12.  
  13. constructor( player )
  14. {
  15. this.player = player;
  16. this.magnitude = DEFAULT_LONGJUMP_MAGNITUDE;
  17. this.lastJump = 0;
  18.  
  19. this.player.Immunity = 8; // Set player immune to fall damage
  20. gLongjump.rawset( player.ID, this ); // Store this instance in the global table
  21. }
  22. }
  23.  
  24. function onPlayerGameKeysChange( player, old, new )
  25. {
  26. if( gLongjump.rawin( player.ID ) ) // Check if player has enabled longjump, exists in global table
  27. {
  28. local pLongjump = gLongjump.rawget( player.ID ); // Fetch the instance of CLongjump
  29. if( time() - pLongjump.lastJump > DEFAULT_COOLDOWN_TIME ) // Only 1 jump allowed in 2 seconds.
  30. {
  31. if( new - old == 2048 ) // Detects jump keypress
  32. {
  33. player.Speed.z += pLongjump.magnitude; // Set Z speed higher
  34. player.Speed += player.Speed; // Set overall speed higher
  35. pLongjump.lastJump = time(); // Cache player's last executed jump.
  36. }
  37. }
  38. }
  39. }
Add Comment
Please, Sign In to add comment