개인 자료란 (JE)

  서버 커뮤니티

Profile SpringOnionEgg 대표칭호 없음
Profile

강좌 자바 에디션(JE) 플러그인 개발

스크립트 (Skript) 강좌 5 강 - 플라이 쿠폰

2019.12.03 조회 수 3648 추천 수 1
분야 스크립트 
게임버전 1.12.x, 1.13.x, 1.14.x 

 

 

오늘은 플라이 쿠폰 스크립트 강좌를 하려합니다.

 

코드를 보기 전에 변수의 종류에 대해서 잠깐 설명하겠습니다.

 

기본 코드와 주석이 달린 코드는 글의 맨 밑에 첨부해두니 참고해주시길 바랍니다!

 

 

────────────────────────────────────────────

 

[ Variables ]

 

 - 기본적인 변수는 중괄호{} 안에 변수의 이름을 넣는 형태입니다.

 

 - 지역변수: {_변수이름} 처럼 변수의 이름 앞에 언더바_를 붙여서 만드며, 발생된 그 이벤트에서만 존재하는 변수입니다. 해당 이벤트가 끝나면 저장된 값이 사라집니다.
 이는 보통 잠시 사용할 변수가 필요할 때 자주 쓰입니다.

 

 - 배열변수: {변수이름::*} <- 이 형태의 변수는 여러개의 값을 저장할 수 있습니다.

add [값] to {변수이름::*} 으로 값을 저장할 수 있으며,

{변수이름::1}, {변수이름::2}, {변수이름::3}... 이런식으로 데이터에 접근할 수 있습니다.

 

 

 

────────────────────────────────────────────

 

[ Skript without lore ]

 

options:
     f : &f[&bFly coupon&f]

        
command /플라이 [<text>] [<integer>]:
    trigger:
        if arg 1 is not set:
            if player is not op:
                if {플라이가능월드목록::*} doesn't contain player's world:
                    send "{@f} &c이 월드에서는 플라이를 사용할 수 없습니다."
                    stop
                if {flytime.%uuid of player%} is not set:
                    set {flytime.%uuid of player%} to 0
                if {flytime.%uuid of player%} <= 0:
                    send "{@f} &c플라이 시간이 부족합니다!"
                    stop
            if player's flight mode is true:
                set player's flight mode to false
                send "{@f} 플라이가 비활성화되었습니다."
            else if player's flight mode is false:
                set player's flight mode to true
                send "{@f} 플라이가 활성화되었습니다."
                
        else if arg 1 is "남은시간":
            if player is op:
                send "{@f} 잔여 플라이 시간: &a무제한&f(OP)"
                stop
            send "{@f} 잔여 플라이 시간: &a%floor({flytime.%uuid of player%}/60)%&f분 &a%mod({flytime.%uuid of player%},60)%&f초"
            stop
            
        else if arg 1 is "도움말":
            send ""
            send "&f[ &b플라이 명령어&f ]"
            send ""
            send "{@f} /플라이 &7- 플라이 On/Off"
            send "{@f} /플라이 남은시간 &7- 남은시간을 봅니다. (OP는 무제한)"
            send "{@f} /플라이 액션바 &7- 액션바에 뜨는 남은시간 On/Off"
            if player is op:
                send "{@f} /플라이 발급 <분> &7- 플라이쿠폰 발급"
                send "{@f} /플라이 월드추가  &7- 현재 자신이 서있는 월드를 플라이가 가능한 월드로 추가합니다."
                send "{@f} /플라이 월드초기화 &7- 플라이가 가능한 월드목록을 초기화시킵니다."
            send ""
            stop
            
        else if arg 1 is "액션바":
            if {fly-actionbar.%uuid of player%} is true:
                set {fly-actionbar.%uuid of player%} to false
                send "{@f} 액션바 플라이 남은시간 표시 Off"
            else if {fly-actionbar.%uuid of player%} is false:
                set {fly-actionbar.%uuid of player%} to true
                send "{@f} 액션바 플라이 남은시간 표시 On"
        if player is op:
            if arg 1 is "발급":
                if arg 2 is not set:
                    send "&c발급할 플라이 추가권의 시간(분)를 입력해주세요."
                    stop
                give enchanted book named "{@f} &b%arg 2% &f분" with lore "&f└좌클릭으로 사용" and "&f└/플라이 남은시간 으로 확인" to player
                send "{@f} &b%arg 2%&f 분 이 발급되었습니다."
                stop
            else if arg 1 is "월드추가":
                if {플라이가능월드목록::*} contain player's world:
                    send "{@f} &c%player's world% 월드는 이미 플라이를 사용할 수 있습니다."
                    stop
                add player's world to {플라이가능월드목록::*}
                send "{@f} &a이제 %player's world% 월드에서도 플라이를 사용할 수 있습니다."
            else if arg 1 is "월드초기화":
                delete {플라이가능월드목록::*}
                send "{@f} &a플라이가 가능한 월드목록을 모두 초기화하였습니다."
                 stop

on left click with enchanted book:
    if name of tool of player contain "Fly coupon":
        set {_itemname::*} to uncolored name of player's tool split by " "
        set player's tool to air
#        remove 1 of enchanted book named "%colored name of player's tool%" with lore "&f└좌클릭으로 사용" and "&f└/플라이 남은시간 으로 확인" from player's inventory
        add {_itemname::3} parsed as integer*60 to {flytime.%uuid of player%}
         send "{@f} 플라이 시간 &b%{_itemname::3}%&f분이 추가되었습니다. [&a%floor({flytime.%uuid of player%}/60)%&f분 &a%mod({flytime.%uuid of player%},60)%&f초]"

on join:
    if {flytime.%uuid of player%} is not set:
        set {flytime.%uuid of player%} to 0
    if {fly-actionbar.%uuid of player%} is not set:
        set {fly-actionbar.%uuid of player%} to true
        
every 1 seconds:
    loop all players:
        if loop-player is not op:
            if loop-player's flight mode is true:
                subtract 1 from {flytime.%uuid of loop-player%}
                if {fly-actionbar.%uuid of loop-player%} is true:
                    set action bar of loop-player to "잔여 플라이 시간: &a%floor({flytime.%uuid of loop-player%}/60)%&f분 &a%mod({flytime.%uuid of loop-player%},60)%&f초"
                if {flytime.%uuid of loop-player%} <= 0:
                    set loop-player's flight mode to false
                    send "{@f} 플라이 시간을 모두 사용하였습니다." to loop-player
                if {플라이가능월드목록::*} doesn't contain loop-player's world:
                    set loop-player's flight mode to false
                    send "{@f} 이 월드에서는 플라이를 사용할 수 없습니다." to loop-player
        else:
            if loop-player's flight mode is true:
                if {fly-actionbar.%uuid of loop-player%} is true:
                     set action bar of loop-player to "잔여 플라이 시간: &a무제한&f(OP)"

 

 

────────────────────────────────────────────

 

[ Skript with lore ]


options:
     f : &f[&bFly coupon&f]

        
command /플라이 [<text>] [<integer>]: # integer는 정수
    trigger:
        if arg 1 is not set:
            if player is not op:
                 if {플라이가능월드목록::*} doesn't contain player's world:

 # {변수이름::*} <- 이 형태의 변수는 배열변수입니다.
 # 여기선 {플라이가능월드목록::*}가 player's world값을 포함하고 있는지를 검사하고 있습니다.
  # 포함하고있지 않으면 true, 포함하고있으면 false

                    send "{@f} &c이 월드에서는 플라이를 사용할 수 없습니다."
                    stop
                 if {flytime.%uuid of player%} is not set:

 # uuid of player는 해당 플레이어의 uuid 값을 저장하고 있다.
  # 이 변수는 각 플레이어의 플라이 남은시간을 초 단위로 저장하는 기능을 합니다.

                    set {flytime.%uuid of player%} to 0
                if {flytime.%uuid of player%} <= 0: # '<='는 '이하'를 뜻하는 연산기호입니다.
                    send "{@f} &c플라이 시간이 부족합니다!"
                    stop
            if player's flight mode is true: # flight mode는 해당 플레이어가 날 수 있는 상태일 때 true를, 날 수 없는 상태일 때 false를 가집니다.
                set player's flight mode to false
                send "{@f} 플라이가 비활성화되었습니다."
            else if player's flight mode is false:
                set player's flight mode to true
                send "{@f} 플라이가 활성화되었습니다."
                
        else if arg 1 is "남은시간":
            if player is op:
                send "{@f} 잔여 플라이 시간: &a무제한&f(OP)"
                stop
             send "{@f} 잔여 플라이 시간: &a%floor({flytime.%uuid of player%}/60)%&f분 &a%mod({flytime.%uuid of player%},60)%&f초"

            stop

 # 이 줄에서 나오는 floor()와 mod(,)는 스크립트가 기본으로 제공하는 함수입니다. 
 # floor()는 괄호안에 입력된 수의 소수점을 반내림하여 값을 반환합니다. ex) floor(60.72) = 60
 # mod()는 mod(a,b)로 쓰이며 a를 b로 나눈 나머지를 반환합니다.    ex) mod(3,2) = 1
 # 이 줄에서는 floor로 시간(초)을 저장한 변수를 60으로 나눈 값을 소수점을 제거하여 '분'을 나타냈고, mod로 시간(초)을 저장한 변수를 60으로 나눈 나머지 값을 출력하여 '초'를 나타냈습니다, 
             

        else if arg 1 is "도움말":
            send ""
            send "&f[ &b플라이 명령어&f ]"
            send ""
            send "{@f} /플라이 &7- 플라이 On/Off"
            send "{@f} /플라이 남은시간 &7- 남은시간을 봅니다. (OP는 무제한)"
            send "{@f} /플라이 액션바 &7- 액션바에 뜨는 남은시간 On/Off"
            if player is op:
                send "{@f} /플라이 발급 <분> &7- 플라이쿠폰 발급"
                send "{@f} /플라이 월드추가  &7- 현재 자신이 서있는 월드를 플라이가 가능한 월드로 추가합니다."
                send "{@f} /플라이 월드초기화 &7- 플라이가 가능한 월드목록을 초기화시킵니다."
            send ""
            stop
            
        else if arg 1 is "액션바":
            if {fly-actionbar.%uuid of player%} is true: # 플라이중일 때 남은시간을 액션바에 표기할지 여부를 결정하는 변수
                set {fly-actionbar.%uuid of player%} to false
                send "{@f} 액션바 플라이 남은시간 표시 Off"
            else if {fly-actionbar.%uuid of player%} is false:
                set {fly-actionbar.%uuid of player%} to true
                send "{@f} 액션바 플라이 남은시간 표시 On"
        if player is op:
            if arg 1 is "발급":
                if arg 2 is not set:
                    send "&c발급할 플라이 추가권의 시간(분)를 입력해주세요."
                    stop
                give enchanted book named "{@f} &b%arg 2% &f분" with lore "&f└좌클릭으로 사용" and "&f└/플라이 남은시간 으로 확인" to player
                
 # give는 아래 방식으로 사용하면 된다.
 # give 아이템이름(아이템코드x) named "아이템이름" with lore "아이템설명1" and "아이템설명2" to player
 # 아이템 이름을 아는법은 아래 코드를 이용하여 손에 든 아이템의 이름을 쉽게 알아낼 수 있다.
 #command /itemname:
 #    trigger:
 #        send "%player's tool%"
  #

                
                send "{@f} &b%arg 2%&f 분 이 발급되었습니다."
                stop
            else if arg 1 is "월드추가":
                if {플라이가능월드목록::*} contain player's world:
                    send "{@f} &c%player's world% 월드는 이미 플라이를 사용할 수 있습니다."
                    stop
                add player's world to {플라이가능월드목록::*} # 여러개의 변수값을 저장할 수 있는 변수에 player's world 값을 추가시킴
                send "{@f} &a이제 %player's world% 월드에서도 플라이를 사용할 수 있습니다."
            else if arg 1 is "월드초기화":
                delete {플라이가능월드목록::*} # 변수에 저장된 값을 모두 삭제
                send "{@f} &a플라이가 가능한 월드목록을 모두 초기화하였습니다."
                 stop

on left click with enchanted book: # 인첸트된 책으로 좌클릭을 했을 때 발생하는 이벤트
    if name of tool of player contain "Fly coupon": # 플레이어의 도구의 이름이 "Fly coupon" 를 포함하고 있으면
        set {_itemname::*} to uncolored name of player's tool split by " " # A split by "B"는 A라는 문자열을 B라는 문자를 기준으로 나누어줍니다.
 # 보통 아래의 방식으로 나누어진 값이 배열변수에 차례대로 저장시킵니다.
 # set {배열변수::*} to A split by "B"
 # 나뉘어진 문자에는 {배열변수::1}, {배열변수::1}.. 과 같은 방식으로 접근할 수 있습니다.
                                                                           
  # uncolored 는 다음에 오는 문자열의 색코드의 발동을 막아줍니다.


 # 변수이름 앞에 {_변수이름} 이런식으로 언더바_를 붙이면 지역변수입니다.


        set player's tool to air # 플레이어의 도구를 air(아무것도 없음)로 설정합니다.
         add {_itemname::3} parsed as integer*60 to {flytime.%uuid of player%}

 # {_itemname::3}에는 나뉘어진 플라이쿠폰이름중에 시간(분) 정보가 문자타입으로 저장되어 있음.
 # 'A parsed as [타입]' 은 A라는 변수의 타입을 [타입]으로 인식시킵니다.
                                                                              
  # 이 줄에서는 {_itemname::3}에 저장된 시간(분)을 정수로 인식시키고 60을 곱하여 {flytime.%uuid of player%}에 저장합니다.

                                                                              
        send "{@f} 플라이 시간 &b%{_itemname::3}%&f분이 추가되었습니다. [&a%floor({flytime.%uuid of player%}/60)%&f분 &a%mod({flytime.%uuid of player%},60)%&f초]" # floor와 mod를 사용하여 남은시간을 분과 초로 출력

on join: # 플라이시간과 액션바 기본설정
    if {flytime.%uuid of player%} is not set:
        set {flytime.%uuid of player%} to 0
    if {fly-actionbar.%uuid of player%} is not set:
        set {fly-actionbar.%uuid of player%} to true
        
every 1 seconds: # 매초마다 발생하는 이벤트
    loop all players: # 모든 플레이어에 대하여 반복
        if loop-player is not op:
            if loop-player's flight mode is true:
                subtract 1 from {flytime.%uuid of loop-player%} # subtract는 사칙연산의 빼기입니다.
                if {fly-actionbar.%uuid of loop-player%} is true:
                    set action bar of loop-player to "잔여 플라이 시간: &a%floor({flytime.%uuid of loop-player%}/60)%&f분 &a%mod({flytime.%uuid of loop-player%},60)%&f초"
                if {flytime.%uuid of loop-player%} <= 0:
                    set loop-player's flight mode to false
                    send "{@f} 플라이 시간을 모두 사용하였습니다." to loop-player
                if {플라이가능월드목록::*} doesn't contain loop-player's world:
                    set loop-player's flight mode to false
                    send "{@f} 이 월드에서는 플라이를 사용할 수 없습니다." to loop-player
        else:
            if loop-player's flight mode is true:
                if {fly-actionbar.%uuid of loop-player%} is true:
                     set action bar of loop-player to "잔여 플라이 시간: &a무제한&f(OP)"

 

 

────────────────────────────────────────────

 

*첨부파일에 기본코드와 주석이 달린 코드를 올려두었습니다!

*질문이나 특정한 시스템에 대한 강좌 요청 모두 환영합니다!




19개의 댓글

홀릭
2019.12.03

아니 이 익숙한 스크립트는?! ㅋㅋㅋㅋ

 

SpringOnionEgg
2019.12.03
@홀릭

ㅋㅋㅋㅋㅋㅋ

아이스틴
2019.12.03

마인팜서버에 유용하겠네요!

윈초
2019.12.04

서버.프로폴타이즈 에서 allow-플라이가 true여야하죠?

SpringOnionEgg
2019.12.05
@윈초

아니요 그건 상관 없습니다!

윈초
2019.12.05
@SpringOnionEgg

아 넵!

 

서버에서 활용해보겠습니다!

소행서버
2019.12.05

혹시 핫타임스크립트도 부탁드려도될까요? ㅠㅠ 1.14.4 인데 구글에쳐도 초크님께나오는데 그게 작동이 안되서 ㅠㅠ

소행서버
2019.12.05
@소행서버

추천누르고갑니다! 항상 잘보고있습니다!

SpringOnionEgg
2019.12.06
@소행서버

아하 좋은 아이디어 감사합니다

소행서버
2019.12.06
@SpringOnionEgg

앗감사합니당!__!

소행서버
2019.12.09

혹시 1.14.4에 정상적용이안되는데 무슨문제인지...ㅠㅠ 오류내용도안뜨고 답답합니다 ㅠㅠㅠㅠ 흑흑

SpringOnionEgg
2019.12.09
@소행서버

1강에 있는 에드온이 다 들어가있는지 확인해보시고 .sk를 붙이셨는지 확인해보세요 !

소행서버
2019.12.09
@SpringOnionEgg

애드온이 문제였네요 ㅠㅠ 애드온 설치하러갑니다!! 항상감사합니다

소행서버
2019.12.12

[18:57:31] [Server thread/ERROR]: There's no loop that matches 'loop-player to "잔여 플라이 시간: &a%floor({flytime.%uuid of loop-player%}/60)%&f분 &a%mod({flytime.%uuid of loop-player%},60)%&f초"' (플라이 - 4강.sk, line 94: set action bar of loop-player to "잔여 플라이 시간: &a%floor({flytime.%uuid of loop-player%}/60)%&f분 &a%mod({flytime.%uuid of loop-player%},60)%&f초"')

[18:57:31] [Server thread/ERROR]: There's no loop that matches 'loop-player to "잔여 플라이 시간: &a무제한&f(OP)"' (플라이 - 4강.sk, line 104: set action bar of loop-player to "잔여 플라이 시간: &a무제한&f(OP)"')

[18:57:36] [Server thread/INFO]: Loaded 7 scripts with a total of 28 triggers and 3 commands in 5.97 seconds

[18:57:36] [Server thread/INFO]: [Skript] Encountered 2 errors while reloading the config and all scripts!

 

이 오류가 뜨네용 ㅠ

플라이 남은시간에서 시간 분 초 로 어떻게 하나요?.... ㅠㅠ

 

미르르
2020.04.24

모든기능 정상작동하는데 플라이 액션바기능만 무반응이네요 혹시 이유가있을까요?? 구문오류 없었고 로드 정상으로됐습니다 버전 1.14.4 스크립트 최신입니다

명이
2020.08.29

[15:12:03 ERROR]: There's no loop that matches 'loop-player to "잔여 플라이 시간: &a%floor({flytime.%uuid of loop-player%}/60)%&f분 &a%mod({flytime.%uuid of loop-player%},60)%&f초"' (서버스크립트.sk, line 145: set action bar of loop-player to "잔여 플라이 시간: &a%floor({flytime.%uuid of loop-player%}/60)%&f분 &a%mod({flytime.%uuid of loop-player%},60)%&f초"')

[15:12:03 ERROR]: There's no loop that matches 'loop-player to "잔여 플라이 시간: &a무제한&f(OP)"' (서버스크립트.sk, line 155: set action bar of loop-player to "잔여 플라이 시간: &a무제한&f(OP)"')

 

이 오류가 뜹니다.

어떻게 해야 하나요?

에드온 모두 다운받았습니다.

ssinggu
2023.06.26

안녕하세요! 스크립트 왕초보라서 오픈소스 잘 써보려구 공부중인데.. 저희 서버가 전부 op라서 이럴경우에는 모두가 다 플라이 시간이 무제한이 되어버린느데 혹시 오피라도 시간제한이 가능하게 하려면 어떻게 바꿔 써야할까요?

뉴스 및 창작물
/files/thumbnails/115/774/003/262x150.crop.jpg?20240424234825

업데이트

마인크래프트 1.20.5 정식 업데이트

학교가기싫다

2024-04-24

0

/files/thumbnails/762/770/003/262x150.crop.jpg?20240418073724

레드스톤

T.B.H (고민중독) | 노트블럭 버전 | NoteBlock Cover [한국어 영어 중국어 가사 추가]

노트블럭전문가

2024-04-18

0

/files/thumbnails/218/767/003/262x150.crop.jpg?20240412130213

레드스톤

우리의 꿈 - 원피스 오프닝

노트블럭전문가

2024-04-12

0

/files/thumbnails/505/766/003/262x150.crop.jpg?20240411122306

레드스톤

기동전사 건담 수성의 마녀 | 노트블럭 커버 1

노트블럭전문가

2024-04-11

1

/files/thumbnails/932/765/003/262x150.crop.jpg?20240410124459

레드스톤

마인크래프트 노트블록으로 만든 『 밤양갱 (Bam Yang Gang) 』

노트블럭전문가

2024-04-10

0

/files/thumbnails/403/765/003/262x150.crop.jpg?20240409190538

레드스톤

마인크래프트 노트블록으로 만든 『 밤양갱 (Bam Yang Gang) 』

Sonttukk

2024-04-09

4

/files/thumbnails/161/758/003/262x150.crop.jpg?20240331105743

레드스톤

라마 침 분수대 1

GlassesFilm

2024-03-31

0