[CommandHelper/Function] 플레이어가 죽었을 때 특정 아이템을 떨구는 기능

2021. 2. 21. 19:16·Games/Minecraft

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 {
            // 들고있는 아이템 없음
        }
    }
}
Colored by Color Scripter
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)
}
Colored by Color Scripter
cs

 

반응형
저작자표시 비영리 (새창열림)
'Games/Minecraft' 카테고리의 다른 글
  • 마인크래프트 서버 생태계는 방대하다
  • [CommandHelper/Function] AutoQuiz(자동 퀴즈) 기능
  • [CommandHelper/Function] 특정 거리안의 플레이어 찾기
  • [Skript/Function] 판매대/상점(SellTable) 기능 공유
Kua
Kua
정보 공유, 개인 정리 공간 입니다.
  • Kua
    Kua's Miscellaneous
    Kua
    • 분류 전체보기 (185)
      • 대문 (2)
      • Tips (25)
        • Chrome (2)
        • Windows (4)
        • IDE (3)
        • 기타 (16)
      • CodingTest (44)
      • Language (20)
        • PHP (5)
        • C# (7)
        • Java (1)
        • Kotlin (7)
      • Framework & Runtime (16)
        • SpringBoot (12)
        • Node.js (2)
        • Vue.js (1)
        • Gradle (1)
      • DevOps (13)
        • Linux (1)
        • Docker (4)
        • Kubernetes (2)
        • Apache Kafka (1)
        • AWS (1)
      • 일상다반사 (53)
        • 도서 (1)
        • 개발 (8)
        • 후기 - IT (7)
        • 후기 - 일상 (13)
        • 차가리 (4)
        • 방송통신대학교 (4)
        • 음식 (2)
      • Games (12)
        • Minecraft (7)
        • VR (2)
        • 그외 (3)
  • 최근 글

  • 인기 글

  • 태그

    bronze2
    후기
    spring
    갤럭시
    백준
    bronze1
    c#
    java
    Algorithm
    Silver5
    error
    Windows
    github
    Plugin
    Spring Boot
    codingtest
    코딩테스트
    알고리즘
    Kotlin
    minecraft
  • 전체
    오늘
    어제
  • hELLO· Designed By정상우.v4.10.0
Kua
[CommandHelper/Function] 플레이어가 죽었을 때 특정 아이템을 떨구는 기능
상단으로

티스토리툴바