TeraProxy лет назад: 9
Родитель
Сommit
a848f1806a
2 измененных файлов с 26 добавлено и 6 удалено
  1. 5 2
      README.md
  2. 21 4
      index.js

+ 5 - 2
README.md

@@ -6,10 +6,13 @@ While ingame, open a whisper chat session with "!Essentials" by typing "/w !esse
 This serves as the script's command interface. 
 This serves as the script's command interface. 
 The following commands are supported:  
 The following commands are supported:  
   
   
-* on - Enables the script  
+* on - Enables the script (default)  
 * off - Disables the script  
 * off - Disables the script  
   
   
-Any other input returns a summary of above commands in the game.
+Any other input returns a summary of above commands in the game.  
+  
+Alternative commands in all other chats:  
+* !essentials - Toggles between "on" and "off" state  
   
   
 ## Safety
 ## Safety
 Whatever you send to "!Essentials" ingame is intercepted client-side. The chat is NOT sent to the server.  
 Whatever you send to "!Essentials" ingame is intercepted client-side. The chat is NOT sent to the server.  

+ 21 - 4
index.js

@@ -38,7 +38,7 @@ module.exports = function Essentials(dispatch) {
 	if(HIDE_MESSAGE)
 	if(HIDE_MESSAGE)
 		dispatch.hook('S_SYSTEM_MESSAGE', 1, event => {
 		dispatch.hook('S_SYSTEM_MESSAGE', 1, event => {
 			let msg = event.message.split('\x0b'),
 			let msg = event.message.split('\x0b'),
-				type = msg[0].startsWith('@') ? sysmsg.map.code[msg[0].slice(1)] : ''
+				type = msg[0].startsWith('@') ? sysmsg.maps.get(dispatch.base.protocolVersion).code.get(msg[0].slice(1)) : ''
 
 
 			if(type == 'SMT_ITEM_USED' || type == 'SMT_CANT_USE_ITEM_COOLTIME') {
 			if(type == 'SMT_ITEM_USED' || type == 'SMT_CANT_USE_ITEM_COOLTIME') {
 				let obj = {}
 				let obj = {}
@@ -192,13 +192,14 @@ module.exports = function Essentials(dispatch) {
 		if(event.target.toUpperCase() === "!essentials".toUpperCase()) {
 		if(event.target.toUpperCase() === "!essentials".toUpperCase()) {
 			if (/^<FONT>on?<\/FONT>$/i.test(event.message)) {
 			if (/^<FONT>on?<\/FONT>$/i.test(event.message)) {
 				enabled = true
 				enabled = true
-				message('Essentials <font color="#00EE00">enabled</font>.')
+				message('Essentials <font color="#56B4E9">enabled</font>.')
 			}
 			}
 			else if (/^<FONT>off?<\/FONT>$/i.test(event.message)) {
 			else if (/^<FONT>off?<\/FONT>$/i.test(event.message)) {
 				enabled = false
 				enabled = false
-				message('Essentials <font color="#DC143C">disabled</font>.')
+				message('Essentials <font color="#E69F00">disabled</font>.')
 			}
 			}
-			else message('Commands: "on" (enable Essentials),'
+			else message('Commands:<br>'
+								+ ' "on" (enable Essentials),<br>'
 								+ ' "off" (disable Essentials)'
 								+ ' "off" (disable Essentials)'
 						)
 						)
 			return false
 			return false
@@ -216,4 +217,20 @@ module.exports = function Essentials(dispatch) {
 			message: msg
 			message: msg
 		})
 		})
 	}
 	}
+	
+	dispatch.hook('C_CHAT', 1, event => {
+		if(/^<FONT>!essentials<\/FONT>$/i.test(event.message)) {
+			if(!enabled) {
+				enabled = true
+				message('Essentials <font color="#56B4E9">enabled</font>.')
+				console.log('Essentials enabled.')
+			}
+			else {
+				enabled = false
+				message('Essentials <font color="#E69F00">disabled</font>.')
+				console.log('Essentials disabled.')
+			}
+			return false
+		}
+	})
 }
 }