Просмотр исходного кода

Automated behavior/command support

TeraProxy лет назад: 9
Родитель
Сommit
fb686fcd9b
2 измененных файлов с 45 добавлено и 6 удалено
  1. 18 3
      README.md
  2. 27 3
      index.js

+ 18 - 3
README.md

@@ -3,17 +3,32 @@ A tera-proxy module that prevents you from getting back to the character select
 This has the side effect that the server's AFK check will not kick you out of the game.  
   
 ## Usage  
+The script is enabled by default and will prevent you from getting logged out when you are standing still for an hour.  
+Simply moving your character will make you able to go back to character selection and reset the 1 hour timer.  
 While ingame, open a whisper chat session with "!AFKer" by typing "/w !afker" in chat and hitting the space bar.
 This serves as the script's command interface. 
 The following commands are supported:  
   
-* on - Enables the script  
-* off - Disables the script (default)  
+* on - Enables the script (default)  
+* off - Disables the script  
   
 Any other input returns a summary of above commands in the game.  
   
 Alternative commands in all other chats:  
 * !afk - Toggles between "on" and "off" state  
   
+Support for Pinkie Pie's command module:  
+* /proxy afk - Toggles between "on" and "off" state  
+  
 ## Safety
-Whatever you send to "!AFKer" ingame is intercepted client-side. The chat is NOT sent to the server.
+Whatever you send to "!AFKer" ingame is intercepted client-side. The chat is NOT sent to the server.
+  
+## Changelog
+### 1.2.0
+* [+] AFKer will now activate itself after standing still for an hour
+* [*] AFKer is now enabled by default
+* [+] Added support for Pinkie Pie's command module which is now a requirement
+### 1.1.0
+* [+] Added !afk command to toggle between "on" and "off" in non-whisper chats
+### 1.0.0
+* [*] Initial Release

+ 27 - 3
index.js

@@ -1,15 +1,25 @@
+const Command = require('command')
+
 module.exports = function AFKer(dispatch) {
-	let enabled = false,
+	let enabled = true,
+		afk = false,
 		cid = null,
-		player = ''
+		player = '',
+		afkCheck = null
 		
 	dispatch.hook('S_LOGIN', 1, event => {
 		({cid} = event)
 		player = event.name
 	})
+	
+	dispatch.hook('C_PLAYER_LOCATION', 1, () => {
+		clearTimeout(afkCheck)
+		afk = false
+		afkCheck = setTimeout(() => {afk = true}, 3600000) // 1 hour
+	})
 
 	dispatch.hook('C_RETURN_TO_LOBBY', 1, () => {
-		if (enabled) return false // Prevents you from being automatically logged out while AFK
+		if (enabled && afk) return false // Prevents you from being automatically logged out while AFK
 	})
   
 	// ################# //
@@ -61,4 +71,18 @@ module.exports = function AFKer(dispatch) {
 			return false
 		}
 	})
+	
+	const command = Command(dispatch)
+	command.add('afk', function() {
+		if(!enabled) {
+			enabled = true
+			message('AFKer <font color="#56B4E9">enabled</font>.')
+			console.log('AFKer enabled.')
+		}
+		else {
+			enabled = false
+			message('AFKer <font color="#E69F00">disabled</font>.')
+			console.log('AFKer disabled.')
+		}
+	})
 }