개인 자료란 (JE)

  서버 커뮤니티

Profile 데빌하트 대표칭호 없음

D3VILH4RRT a4b5e1bfdef74b93af06cbd3c8b3f76b

Profile

질문하기 스크립트

상점 스크립트를 만드는데 도와주세요!!

2023.11.06 조회 수 434 추천 수 0
이해도 입문자 
게임버전 (JE) 1.20.1 
게임버전 (BE) 관련없음 
스크립트 버전 2.7.2 

상점 스크립트를 만드는데 구매를 못하고 판매만 가능하게 하고  싶고

판매되는 가격의 시세를 변동 하게 만들고 싶은데 어떻게 하나요?


#명령어로 여는 상점

command /광부상점:

    trigger:

        open chest with 6 row named "&1&l광부상점" to player

        set {_slot} to 0

        loop 54 times:

            set slot {_slot} of current inventory of player to black stained glass pane

            add 1 to {_slot}

        set slot 10 of current inventory of player to coal with lore "&b구매가격 : 구매불가" and "&c판매가격 : 100원" and "&e좌클릭 구매/우클릭 판매"

        set slot 11 of current inventory of player to raw copper with lore "&b구매가격 : 구매불가" and "&c판매가격 : 100원" and "&e좌클릭 구매/우클릭 판매"

        set slot 12 of current inventory of player to copper ingot with lore "&b구매가격 : 구매불가" and "&c판매가격 : 100원" and "&e좌클릭 구매/우클릭 판매"

        set slot 13 of current inventory of player to raw iron with lore "&b구매가격 : 구매불가" and "&c판매가격 : 100원" and "&e좌클릭 구매/우클릭 판매"

        set slot 14 of current inventory of player to iron ingot with lore "&b구매가격 : 구매불가" and "&c판매가격 : 100원" and "&e좌클릭 구매/우클릭 판매"

        set slot 15 of current inventory of player to raw gold with lore "&b구매가격 : 구매불가" and "&c판매가격 : 100원" and "&e좌클릭 구매/우클릭 판매"

        set slot 16 of current inventory of player to gold ingot with lore "&b구매가격 : 구매불가" and "&c판매가격 : 100원" and "&e좌클릭 구매/우클릭 판매"

        set slot 19 of current inventory of player to lapis lazuli with lore "&b구매가격 : 구매불가" and "&c판매가격 : 100원" and "&e좌클릭 구매/우클릭 판매"

        set slot 20 of current inventory of player to diamond with lore "&b구매가격 : 구매불가" and "&c판매가격 : 100원" and "&e좌클릭 구매/우클릭 판매"

        set slot 21 of current inventory of player to redstone with lore "&b구매가격 : 구매불가" and "&c판매가격 : 100원" and "&e좌클릭 구매/우클릭 판매"

        set slot 22 of current inventory of player to emerald with lore "&b구매가격 : 구매불가" and "&c판매가격 : 100원" and "&e좌클릭 구매/우클릭 판매"

        set slot 23 of current inventory of player to ancient debris with lore "&b구매가격 : 구매불가" and "&c판매가격 : 100원" and "&e좌클릭 구매/우클릭 판매"

        set slot 24 of current inventory of player to netherite ingot with lore "&b구매가격 : 구매불가" and "&c판매가격 : 100원" and "&e좌클릭 구매/우클릭 판매"

        set slot 25 of current inventory of player to coal block with lore "&b구매가격 : 구매불가" and "&c판매가격 : 100원" and "&e좌클릭 구매/우클릭 판매"

        set slot 28 of current inventory of player to copper block with lore "&b구매가격 : 구매불가" and "&c판매가격 : 100원" and "&e좌클릭 구매/우클릭 판매"

        set slot 29 of current inventory of player to iron block with lore "&b구매가격 : 구매불가" and "&c판매가격 : 100원" and "&e좌클릭 구매/우클릭 판매"

        set slot 30 of current inventory of player to gold block with lore "&b구매가격 : 구매불가" and "&c판매가격 : 100원" and "&e좌클릭 구매/우클릭 판매"

        set slot 31 of current inventory of player to diamond block with lore "&b구매가격 : 구매불가" and "&c판매가격 : 100원" and "&e좌클릭 구매/우클릭 판매"

        set slot 32 of current inventory of player to redstone block with lore "&b구매가격 : 구매불가" and "&c판매가격 : 100원" and "&e좌클릭 구매/우클릭 판매"

        set slot 33 of current inventory of player to lapis lazuli block with lore "&b구매가격 : 구매불가" and "&c판매가격 : 100원" and "&e좌클릭 구매/우클릭 판매"

        set slot 34 of current inventory of player to netherite block with lore "&b구매가격 : 구매불가" and "&c판매가격 : 100원" and "&e좌클릭 구매/우클릭 판매"

        set slot 39 of current inventory of player to quartz with lore "&b구매가격 : 구매불가" and "&c판매가격 : 100원" and "&e좌클릭 구매/우클릭 판매"

        set slot 40 of current inventory of player to iron nugget with lore "&b구매가격 : 구매불가" and "&c판매가격 : 100원" and "&e좌클릭 구매/우클릭 판매"

        set slot 41 of current inventory of player to gold nugget with lore "&b구매가격 : 구매불가" and "&c판매가격 : 100원" and "&e좌클릭 구매/우클릭 판매"

 

#아이템을 구매 및 판매하는 구문      

on inventory click:

    if inventory name is "&1&l광부상점":

        cancel event

        if clicked item is black stained glass pane:

        else:

            if click type is left mouse button:

                if clicked raw slot is smaller than 54:

                    set {_lore} to uncolored line 0 of lore of clicked item

                    replace all "구매가격 " and ":" and " " and "구매불가" with "" in {_lore}

                    set {_lore} to {_lore} parsed as integer

                    if {%uuid of player%.돈} is smaller than {_lore}:

                        send "&c돈이 부족합니다" to player

                        play sound "entity.experience_orb.pickup" with volume 0.5 and pitch 1 to the player

                    else:

                        set {_item} to clicked item

                        delete lore of {_item}

                        if player has enough space for {_item}:

                            give {_item} to player

                            subtract {_lore} from {%uuid of player%.돈}

                            play sound "UI_BUTTON_CLICK" with volume 0.3 and pitch 3 to the player

                        else:

                            send "&c&l인벤토리에 충분한 공간이 없습니다!" to player

                                    

            else if click type is right mouse button:

                if clicked raw slot is smaller than 54:

                    set {_lore} to uncolored line 2 of lore of clicked item

                    replace all "판매가격 " and ":" and " " and "원" with "" in {_lore}

                    set {_lore} to {_lore} parsed as integer

                    set {_item} to clicked item

                    delete lore of {_item}

                    if player has 1 of {_item}:

                        remove 1 of {_item} from player's inventory

                        add {_lore} to {%uuid of player%.돈}

                        play sound "entity.experience_orb.pickup" with volume 0.5 and pitch 3 to the player

                    else:

                        send "&c현재 해당 아이템을 가지고 있지 않아 판매할 수 없습니다" to player

                        play sound "UI_BUTTON_CLICK" with volume 0.3 and pitch 3 to the player

on rightclick on entity:

    if entity's name is "광부":

        player command "광부상점"





7개의 댓글

코코냐
2023.11.06

고정으로 100원이 아니라 다른데서 값을 가져오면 됩니다.

데빌하트
2023.11.06
@코코냐

잘 이해를 못했는데

피코
2023.11.07
@데빌하트

set slot 10 of current inventory of player to coal with lore "&b구매가격 : 구매불가" and "&c판매가격 : 100원" and "&e좌클릭 구매/우클릭 판매" 과 같이 판매 가격 100원 이리 되어 있으니 이 부분을 예를들어 변수 a로 설정하면 판매되는 가격을 설정할 수 있기에 이리하시면 가격을 계속 바꾸실 수 있어 시세를 직접 설정 가능하지만 지금 질문하시는건 저의 생각으로는 자동적으로 오르고 내리고 하는거 같아서 추가적으로 말씀드리겠습니다.

시세가 30분 마다 바뀐다고 가정을 하고 판매된 수량을 변수 b라고 두고 짜보면

every 30 minute:

@set {_int} to {b}/30

@set {a} to 100-{_int}

이런식으로 짤 수 있는데 이리 된다면 아이템이 (기본 판매 가격 - 판매된 수량 ÷ 30 = 아이템 판매 가격) 이런식으로 설정 할 수 있습니다.

뭐 이것을 응용하면 올라 갈 수도 있지만 판매된다는것을 가정으로 한것이기 때문에 시세가 내려가는것만 설명 드린것 입니다

도움이 되셨길 바랍니다..ㅋㅋ

데빌하트
2023.11.10
@피코

command /광부상점:

trigger:

open chest with 6 row named "&1&1광부상점" to player

set {_slot} to 0

loop 54 times:

set slot {_slot} of current inventory of player to black stained glass pane

add 1 to {_slot}

set slot 10 of current inventory of player to coal with lore "&b구매가격 : 구매불가" and "&c판매가격 : 40원" and "&e좌클릭 구매/우클릭 판매"

set slot 11 of current inventory of player to raw copper with lore "&b구매가격 : 구매불가" and "&c판매가격 : 50원" and "&e좌클릭 구매/우클릭 판매"

set slot 12 of current inventory of player to copper ingot with lore "&b구매가격 : 구매불가" and "&c판매가격 : 100원" and "&e좌클릭 구매/우클릭 판매"

set slot 13 of current inventory of player to raw iron with lore "&b구매가격 : 구매불가" and "&c판매가격 : 100원" and "&e좌클릭 구매/우클릭 판매"

set slot 14 of current inventory of player to iron ingot with lore "&b구매가격 : 구매불가" and "&c판매가격 : 150원" and "&e좌클릭 구매/우클릭 판매"

set slot 15 of current inventory of player to raw gold with lore "&b구매가격 : 구매불가" and "&c판매가격 : 250원" and "&e좌클릭 구매/우클릭 판매"

set slot 16 of current inventory of player to gold ingot with lore "&b구매가격 : 구매불가" and "&c판매가격 : 300원" and "&e좌클릭 구매/우클릭 판매"

set slot 19 of current inventory of player to lapis lazuli with lore "&b구매가격 : 구매불가" and "&c판매가격 : 120원" and "&e좌클릭 구매/우클릭 판매"

set slot 20 of current inventory of player to diamond with lore "&b구매가격 : 구매불가" and "&c판매가격 : 3000원" and "&e좌클릭 구매/우클릭 판매"

set slot 21 of current inventory of player to redstone with lore "&b구매가격 : 구매불가" and "&c판매가격 : 30원" and "&e좌클릭 구매/우클릭 판매"

set slot 22 of current inventory of player to emerald with lore "&b구매가격 : 구매불가" and "&c판매가격 : 15000원" and "&e좌클릭 구매/우클릭 판매"

set slot 23 of current inventory of player to ancient debris with lore "&b구매가격 : 구매불가" and "&c판매가격 : 2000원" and "&e좌클릭 구매/우클릭 판매"

set slot 24 of current inventory of player to netherite ingot with lore "&b구매가격 : 구매불가" and "&c판매가격 : 10000원" and "&e좌클릭 구매/우클릭 판매"

set slot 25 of current inventory of player to coal block with lore "&b구매가격 : 구매불가" and "&c판매가격 : 360원" and "&e좌클릭 구매/우클릭 판매"

set slot 28 of current inventory of player to copper block with lore "&b구매가격 : 구매불가" and "&c판매가격 : 900원" and "&e좌클릭 구매/우클릭 판매"

set slot 29 of current inventory of player to iron block with lore "&b구매가격 : 구매불가" and "&c판매가격 : 1350원" and "&e좌클릭 구매/우클릭 판매"

set slot 30 of current inventory of player to gold block with lore "&b구매가격 : 구매불가" and "&c판매가격 : 2700원" and "&e좌클릭 구매/우클릭 판매"

set slot 31 of current inventory of player to diamond block with lore "&b구매가격 : 구매불가" and "&c판매가격 : 27000원" and "&e좌클릭 구매/우클릭 판매"

set slot 32 of current inventory of player to emerald block with lore "&b구매가격 : 구매불가" and "&c판매가격 : 135000원" and "&e좌클릭 구매/우클릭 판매"

set slot 33 of current inventory of player to redstone block with lore "&b구매가격 : 구매불가" and "&c판매가격 : 750원" and "&e좌클릭 구매/우클릭 판매"

set slot 34 of current inventory of player to lapis lazuli block with lore "&b구매가격 : 구매불가" and "&c판매가격 : 1080원" and "&e좌클릭 구매/우클릭 판매"

set slot 38 of current inventory of player to netherite block with lore "&b구매가격 : 구매불가" and "&c판매가격 : 90000원" and "&e좌클릭 구매/우클릭 판매"

set slot 39 of current inventory of player to quartz with lore "&b구매가격 : 구매불가" and "&c판매가격 : 30원" and "&e좌클릭 구매/우클릭 판매"

set slot 41 of current inventory of player to iron nugget with lore "&b구매가격 : 구매불가" and "&c판매가격 : 13원" and "&e좌클릭 구매/우클릭 판매"

set slot 42 of current inventory of player to gold nugget with lore "&b구매가격 : 구매불가" and "&c판매가격 : 33원" and "&e좌클릭 구매/우클릭 판매"

 

on inventory click:

if inventory name is "&1&1광부상점":

cancel event

if clicked item is black stained glass pane:

every 30 minutes: # 시세가 30분마다 변동되도록 추가

@set {_int} to random integer between -30 and 30

@set {a} to 100 - {_int}

send "&e시세가 변동되었습니다!" to all players # 플레이어에게 변동 알림 전송

else:

if click type is right mouse button:

if clicked raw slot is smaller than 54:

set {_lore} to uncolored line 2 of lore of clicked item

replace all "판매가격 " and ":" and " " and "원" with "" in {_lore}

set {_lore} to {_lore} parsed as integer

set {_item} to clicked item

delete lore of {_item}

if player has 1 of {_item}:

remove 1 of {_item} from player's inventory

add {_lore} to {%uuid of player%.돈}

play sound "entity.experience_orb.pickup" with volume 0.5 and pitch 3 to the player

else:

send "&c현재 해당 아이템을 가지고 있지 않아 판매할 수 없습니다." to player

play sound "UI_BUTTON_CLICK" with volume 0.3 and pitch 3 to the player

if click type is right mouse button with shift:

if clicked raw slot is smaller than 54:

set {_lore} to uncolored line 2 of lore of clicked item

replace all "판매가격" and ":" and " " and "원" with "" in {_lore}

set {_lore} to {_lore} parsed as integer

set {_item} to clicked item

delete lore of {_item}

if player has 64 of {_item}:

remove 64 of {_item} from player's inventory

add {_lore}*64 to {%uuid of player%.돈}

play sound "entity.experience_orb.pickup" with volume 0.5 and pitch 3 to the player

else:

send "&c현재 해당 아이템을 가지고 있지 않아 판매할 수 없습니다." to player

play sound "UI_BUTTON_CLICK" with volume 0.3 and pitch 3 to the player

 

if click type is right mouse button:

 

on rightclick on entity:

if entity's name is "광부":

player command "광부상점"

 

이렇게 짜는게 맞나요?

피코
2023.11.12
@데빌하트

저가 설명이 너무 부족했나 봅니다. 이 스크립트에서 몇가지만 간단하게 만들어 봤습니다 blocks.sk  이 스크립트 이용 하셔서 좋은 스크립트 한번 만들어 보십세요 아이템마다 가격은 따로 설정해 주세요!

데빌하트
2023.11.14
@피코

감사합니다 아이템 가격은 on load 부분에서 하면 되는건가요?

 

피코
2023.11.26
@데빌하트

제일 기본적이긴 하나 노가다 입니당.