main.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
// 죽을 시 죽은 플레이어의 인벤토리에 있는 아이템 2종류 1~64 개(랜덤)을 온라인인 유저 아무한테나 랜덤으로 떨굼 (떨굴 유저가 없으면 죽은 플레이어의 아이템은 그냥 사라짐)
// 위의 기능과 덧붙여 죽을 시 가진 돈의 ~%를 잃는 기능(~%는 자주 변경될 수 있음)
// 만약 가진 돈이 0 원 또는 음수라면 죽을 때 마다 -500 원 씩 적자
// 위의 기능이 작동하는 월드를 지정할 수 있는 기능
// 아이템을 받은 사람한테 ~~아이템을 받았다고 채팅 알림
include('proc.ms')
export('DeathDrop.Worlds', 'island_normal_world') // 적용할 월드
export('DeathDrop.DropMoney_Percentage', 1) // 소지금액에서 퍼센트로 떨굴 비율
bind('player_death', null, null, @eData){
@player = @eData['player']
if (import('DeathDrop.Worlds') == pinfo(@player, 7)) {
@prefix = '[DeathDrop] '
if (pisop(@player)) {
die(@prefix'OP권한이 있어 아아템을 잃지 않습니다.')
}
@array = _getHavingSlot(@player)
/*
@has_money = acc_balance(@player)
if (@has_money <= 500) {
@take_money = 100
} else {
@take_money = round(divide(@has_money / 100), import('DeathDrop.DropMoney_Percentage'))
}
*/
@take_money = 10
acc_subtract(@player, @take_money)
tmsg(@player, @prefix '나락속으로'@take_money'원을 잃어버렸습니다..')
if (length(@array) == 1) {
modify_event('death_message', null)
@item = pinv(@player, @array[0]);
if (@item['qty'] == 1){}else{
@item['qty'] = rand(1, @item['qty'])}
ptake_item(@player, @item)
try{
if (is_null(@item['meta']['display'])){
broadcast(@prefix @player'님이'@item['name'] @item['qty'].'개를 떨어트렸습니다..')
} else {
broadcast(@prefix @player'님이'@item['meta']['display'] @item['qty']'개를 떨어트렸습니다..')
}
}catch(CastException @e) {
broadcast(@prefix @player'님이'@item['name'] @item['qty'].'개를 떨어트렸습니다..')
}
@if_player = all_players(import('DeathDrop.Worlds'))
array_remove(@if_player, array_index(@if_player, @player))
if (length(@if_player) > 1) {
@target = array_get_rand(@if_player)
tmsg(@target, @prefix @player'님이 떨어트린 아이템이 당신의 머리위에 떨어졌습니다.')
drop_item(@target, @item)
} else {
console('[DeathDrop][Info] There were no players on the server that could have '.@player.'\'s items.')
}
} else if (length(@array) > 1) {
modify_event('death_message', null)
@item = array()
@temp = array_rand(@array, 2)
for(assign(@i, 0), @i < 2, @i++){
array_push(@item, pinv(@player, @array[@temp[@i]]))
}
for(assign(@i, 0), @i < 2, @i++){
if (@item[@i]['qty'] == 1){ }else{
@item[@i]['qty'] = rand(1, @item[@i]['qty']) }
}
ptake_item(@player, @item[0])
ptake_item(@player, @item[1])
@item_string_array = array();
for(assign(@i, 0), @i < 2, @i++){
try{
if (is_null(@item['meta']['display'])){
array_push(@item_string_array, @item[@i]['name'].' '.@item[@i]['qty'])
} else {
array_push(@item_string_array, @item[@i]['meta']['display'].' '.@item[@i]['qty'])
}
} catch(CastException @e){
array_push(@item_string_array, @item[@i]['name'].' '.@item[@i]['qty'])
}
}
broadcast(@prefix @player'님이'@item_string_array[0].'개, '.@item_string_array[1].'개를 떨어트렸습니다..')
@if_player = all_players(import('DeathDrop.Worlds'))
array_remove(@if_player, array_index(@if_player, @player))
if (length(@if_player) >= 1) {
@target = array_get_rand(@if_player)
tmsg(@target, @prefix @player'님이 떨어트린 아이템이 당신의 머리위에 떨어졌습니다.')
drop_item(@target, @item[0])
drop_item(@target, @item[1])
} else {
console('[DeathDrop][Info] There were no players on the server that could have '.@player.'\'s items.')
}
} else {
// 들고있는 아이템 없음
}
}
}
|
cs |
proc.ms
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
proc _getHavingSlot(@target){
@array = array()
@inv = pinv(@target)
for(assign(@i, 0), @i < 36, @i++){
if (@inv[@i] != null){
array_push(@array, @i)
}
}
for(assign(@i, 100), @i < 104, @i++){
if (@inv[@i] != null){
array_push(@array, @i)
}
}
if (@inv[-106] != null){
array_push(@array, -106)
}
return(@array)
}
|
cs |
반응형