Advertisement
Guest User

Untitled

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