#Shop
1 messages · Page 1 of 1 (latest)
<@&1201956957406109788>
💬 While you wait, take this time to provide more context and details.
✅ Once your question has been resolved (or you no longer need it), please click Resolve Question or run /resolve
Don't forget to close or resolve your old questions once you're done with them. It makes our lives much easier! :D
Open question: #1268222114406727740
I made a shop with the help of a book and when you press a certain block in the book a /function command is executed but I didn't consider that it wouldn't work on a server because not everyone there has an op
<@&1166082198152159386> <@&1202694677766348840>
Please note that you still might not immediately get a response since all helpers are human beings and volunteers (and also might be sleeping right now)
- Create a trigger scoreboard objective.
-# load.mcfunction
scoreboard objectives add mytrigger trigger
- Enable the objective for all players.
-# tick.mcfunction
scoreboard players enable @a mytrigger
- Execute as all players and check if a player has used it, then execute run your function.
-# tick.mcfunction
scoreboard players enable @a mytrigger
execute as @a[scores = {mytrigger = 1..}] run function mynamespace:myfunction
Remember to reset the trigger after running your function.
-# myfunction.mcfunction
scoreboard players reset @s mytrigger
# ...
I have to do the last thing in every function where you should have access
You're gonna need to make a new trigger for each function you want to be public.
You can also use set values for one trigger if you sacrifice readability.
i have 50 functions
^
So do I have to do each of these commands 50 times?
pretty much
execute if score @s Level matches 500.. run experience add @p -500 levels
execute if score @s Level matches 500.. run give @a enchanted_book[stored_enchantments={levels:{swift_sneak:3}}] is 1
- Create trigger scoreboard objectives.
-# load.mcfunction
scoreboard objectives add mytrigger1 trigger
scoreboard objectives add mytrigger2 trigger
scoreboard objectives add mytrigger3 trigger
# ...
- Enable the objectives for all players.
-# tick.mcfunction
scoreboard players enable @a mytrigger1
scoreboard players enable @a mytrigger2
scoreboard players enable @a mytrigger3
# ...
- Execute as all players and check if a player has used one of the triggers, then execute run your corresponding function.
-# tick.mcfunction
scoreboard players enable @a mytrigger1
scoreboard players enable @a mytrigger2
scoreboard players enable @a mytrigger3
# ...
execute as @a[scores = {mytrigger1 = 1..}] run function mynamespace:myfunction1
execute as @a[scores = {mytrigger2 = 1..}] run function mynamespace:myfunction2
execute as @a[scores = {mytrigger3 = 1..}] run function mynamespace:myfunction3
# ...
Do I also have to change the commands in the books?
this dosent work
To /trigger commands, yes.
thank you
Your question, #1268499302804881448 (Shop), was resolved!
#1268499302804881448 message
7h15m
Re-opened the channel. Make sure to close it again once you're done.
Your question, #1268499302804881448 (Shop), was resolved!
#1268499302804881448 message
10d8h35m