-
Notifications
You must be signed in to change notification settings - Fork 1
/
script_javascript.js
51 lines (42 loc) · 1.57 KB
/
script_javascript.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const { SocketClientTCP } = require('netlinkwrapper')
const host = '192.168.1.89'
const port = 13001
const password = 'SHOWMETHEMONEY'
const cmd = 'USER_COUNT'
/*
cmd variable can be:
IS_SERVER_UP - returns string (YES or NO)
USER_COUNT - returns string (total, empire1, empire2, empire3, local)
DC <playerName> - returns string (Player kicked out)
BLOCK_CHAT <playerName> - returns string (BLOCK_CHAT <playerName> or BLOCK_CHAT FAIL)
NOTICE <message> - returns UNKNOWN
SHUTDOWN - returns UNKNOWN
PRIV_EMPIRE <privEmpire> <empire> <type> <value> <duration> - returns string (PRIV_EMPIRE SUCCEED or PRIV_EMPIRE FAIL)
RELOAD - reloads protos - returns UNKNOWN
RELOAD <option> -
u - reloads state user count - returns UNKNOWN
p - reloads protos - returns UNKNOWN
s - reloads database strings - returns UNKNOWN
f - reloads fishing - returns UNKNOWN
a - reloads admins - returns UNKNOWN
*/
const client = new SocketClientTCP(port, host)
let received
client.send(`\x40${password}\n`)
client.receive()
client.send(`\x40${cmd}\n`)
received = client.receive()
if (received) {
received = received.toString().replace(/\r?\n|\r/, '')
if (!isNaN(Number(received.charAt(0)))) {
const userCount = received.split(/[ ]+/)
console.log(`Total[${userCount[0]}] ${userCount[1]} / ${userCount[2]} / ${userCount[3]} (this server ${userCount[4]})`)
} else if (received === 'UNKNOWN') {
console.log('Command sent and executed with no custom response')
} else {
console.log(received)
}
} else {
console.log('An error occurred.')
}
client.disconnect()