index.js 903 B

12345678910111213141516171819202122232425262728
  1. // Version 1.2.3
  2. const Command = require('command')
  3. module.exports = function AFKer(dispatch) {
  4. let enabled = true,
  5. lasttimemoved = Date.now()
  6. dispatch.hook('C_PLAYER_LOCATION', 5, event => {
  7. if([0,1,5,6].indexOf(event.type) > -1) // running / walking / jumping / jumping (steep terrain)
  8. lasttimemoved = Date.now()
  9. })
  10. dispatch.hook('C_RETURN_TO_LOBBY', 'raw', () => {
  11. if (enabled && Date.now() - lasttimemoved >= 3600000) return false // Prevents you from being logged out after not moving for 1 hour
  12. })
  13. // ################# //
  14. // ### Chat Hook ### //
  15. // ################# //
  16. const command = Command(dispatch)
  17. command.add('afk', () => {
  18. enabled = !enabled
  19. command.message('[AFKer] ' + (enabled ? '<font color="#56B4E9">enabled</font>' : '<font color="#E69F00">disabled</font>'))
  20. console.log('[AFKer] ' + (enabled ? 'enabled' : 'disabled'))
  21. })
  22. }