forked from AddstarMC/BungeeUnscramble
-
Notifications
You must be signed in to change notification settings - Fork 0
/
unscramble.ms
55 lines (44 loc) · 1.55 KB
/
unscramble.ms
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
52
53
54
55
register_channel('Unscramble')
proc(_us_award_item, @sessionId, @playerName, @material, @data, @count,
assign(@remain, pgive_item(@playerName, concat(data_values(@material),':', @data), @count))
if(@remain != 0){
assign(@ba, byte_array())
ba_put_string(@ba, 'AwardFail')
ba_put_int(@ba, @sessionId)
ba_put_byte(@ba, 1)
ba_put_int(@ba, @remain)
send_plugin_message('Unscramble', @ba)
}
else {
assign(@ba, byte_array())
ba_put_string(@ba, 'AwardOk')
ba_put_int(@ba, @sessionId)
send_plugin_message('Unscramble', @ba)
}
)
proc(_us_award_money, @sessionId, @playerName, @amount,
acc_add(@playerName, @amount)
assign(@ba, byte_array())
ba_put_string(@ba, 'AwardOk')
ba_put_int(@ba, @sessionId)
send_plugin_message('Unscramble', @ba)
)
bind('plugin_message_received', null, array(channel:'Unscramble'), @event,
assign(@ba, @event['bytes'])
ba_rewind(@ba)
assign(@subchannel, ba_get_string(@ba))
assign(@sessionId, ba_get_int(@ba))
if(@subchannel == 'Award$') {
_us_award_money(@sessionId, ba_get_string(@ba), ba_get_double(@ba))
}
else if(@subchannel == 'AwardItem') {
_us_award_item(@sessionId, ba_get_string(@ba), ba_get_string(@ba), ba_get_byte(@ba), ba_get_byte(@ba))
}
else {
assign(@ba, byte_array())
ba_put_string(@ba, 'AwardFail')
ba_put_int(@ba, @sessionId)
ba_put_byte(@ba, 2)
send_plugin_message('Unscramble', @ba)
}
)