This tutorial elaborates how to make blocks randomly give you random rewards when you break them.
These variables return the info of the block which the player breaks
This command makes %rnd% a random number between 1-1000
This command makes the chance of receiving a lucky reward 0.5% per block, you can alter it
But I highly recommend you not to make it very high as of it can cause spam if receiving a lucky block is too frequent
You can replace #5 & #6 with "If %id% = 1 then goto 8" to make the command run only when the player breaks a stone block
But beware that players can place stone blocks, so choose a block that drops nothing when mined such as a monster spawner
You can however put any other block and make it impossible to pick it up or place it using the "cancel" command in the break and trigger events
But adding it can cause problems in areas where you want people to be able to place/break that block such as outside mines if you have a prison server and can cause griefing problems if you add commands that break the block without making it drop itself
Therefore you need to add commands that check the location of the block if it's inside an array of the locations of each mine
It's slightly complicated to do and I didn't add it in the commands procedure as of 99.9% of people don't read so it could cause problems in their servers and blame me since I can't make it work in all servers as of the coordinates of buildings aren't the same in all servers.
This command will stop the commands procedure from running so that they don't get the rewards everytime they break a block
This command makes %rnd2% a random number between 1-8, to make the effect/reward random. The number "8" must be the same as the number of effects/rewards you have
These commands will make the command procedure skip to the specified effect/reward line
This is just a comment that shows up when you do /cmd list luckyblocks
All of the following commands are optional, you can replace them with the effects/rewards you want
These are the commands that alter what the player gets when s/he breaks a block after being %rnd% ≤ 0.5
This command says to all players that the player got a lucky block
This command gives the player a speed effect
This command shows a title and a subtitle in the player's screen
#24 /cmd add luckyblocks title %p% \"Unlucky Block\\nYou got Slowness I for 1m\"
#25 /cmd add luckyblocks exit
#26 /cmd add luckyblocks message onlineplayers() Very Lucky Blocks: %p% got Haste II for 5m!
#27 /cmd add luckyblocks ascon /effect %p% 3 300 1[/quote]
The rest of this tutorial is in the replies because of the stupid 10000 characters limit
Plugins you need:
- MadCommands
Command creation:
Start by creating the command by adding its name, adding its description and adding how to use it.
/cmd create luckyblocks Name says all | This command is not for manual use
Unregistering it:
You need to unregister the command to prevent using it by players
/cmd unregister luckyblocks
Commands procedure:
You must input all of the following commands except the optional ones for this to work, you can use one of the four ways to input them:- Write them character by character in your server - Approximate time to finish: 39 minutes and 30 seconds*
- Copy each one then send it in console - ATTF: 15 minutes*
- Download a Clipboard Keyboard then copy each one and send it in the server - ATTF: 5 minutes*
- Go to Pastebin then copy my code and input it in Multiple Commands on rcon.cf and don't leave the page until it finishes running - ATTF: 54 seconds*
The #Number is the command line, don't copy it, I put it just so it becomes easier for you to understand how this command works, especially the goto commands.
#1 /cmd add luckyblocks let %block% = blockinfo(%args%[3], %args%[4], %args%[5], %args%[6])
#2 /cmd add luckyblocks let %name% = %args%[2]
#3 /cmd add luckyblocks let %id% = %args%[7]
#4 /cmd add luckyblocks let %meta% = %args%[8]
#2 /cmd add luckyblocks let %name% = %args%[2]
#3 /cmd add luckyblocks let %id% = %args%[7]
#4 /cmd add luckyblocks let %meta% = %args%[8]
#5 /cmd add luckyblocks let %rnd% = random(1, 1000)
#6 /cmd add luckyblocks if %rnd% <= 5 then goto 8
But I highly recommend you not to make it very high as of it can cause spam if receiving a lucky block is too frequent
You can replace #5 & #6 with "If %id% = 1 then goto 8" to make the command run only when the player breaks a stone block
But beware that players can place stone blocks, so choose a block that drops nothing when mined such as a monster spawner
You can however put any other block and make it impossible to pick it up or place it using the "cancel" command in the break and trigger events
But adding it can cause problems in areas where you want people to be able to place/break that block such as outside mines if you have a prison server and can cause griefing problems if you add commands that break the block without making it drop itself
Therefore you need to add commands that check the location of the block if it's inside an array of the locations of each mine
It's slightly complicated to do and I didn't add it in the commands procedure as of 99.9% of people don't read so it could cause problems in their servers and blame me since I can't make it work in all servers as of the coordinates of buildings aren't the same in all servers.
#7 /cmd add luckyblocks exit
#8 /cmd add luckyblocks let %rnd2% = random(1, 8)
#9 /cmd add luckyblock if %rnd2% = 1 then goto 18
#10 /cmd add luckyblock if %rnd2% = 2 then goto 22
#11 /cmd add luckyblock if %rnd2% = 3 then goto 26
#12 /cmd add luckyblock if %rnd2% = 4 then goto 30
#13 /cmd add luckyblock if %rnd2% = 5 then goto 34
#14 /cmd add luckyblock if %rnd2% = 6 then goto 38
#15 /cmd add luckyblock if %rnd2% = 7 then goto 43
#16 /cmd add luckyblock if %rnd2% = 8 then goto 54
#10 /cmd add luckyblock if %rnd2% = 2 then goto 22
#11 /cmd add luckyblock if %rnd2% = 3 then goto 26
#12 /cmd add luckyblock if %rnd2% = 4 then goto 30
#13 /cmd add luckyblock if %rnd2% = 5 then goto 34
#14 /cmd add luckyblock if %rnd2% = 6 then goto 38
#15 /cmd add luckyblock if %rnd2% = 7 then goto 43
#16 /cmd add luckyblock if %rnd2% = 8 then goto 54
Code:
[COLOR=rgb(124, 112, 107)]#17[/COLOR] /cmd add luckyblocks #Effects
All of the following commands are optional, you can replace them with the effects/rewards you want
These are the commands that alter what the player gets when s/he breaks a block after being %rnd% ≤ 0.5
#18 /cmd add luckyblocks message onlineplayers() Lucky blocks: %p% got Speed II for 5m!
#19 /cmd add luckyblocks ascon /effect %p% 1 300 1
#20 /cmd add luckyblocks title %p% \"Lucky Block\\nYou got Speed II for 5m!\"
#21 /cmd add luckyblocks exit
This command will stop the commands procedure
This command will stop the commands procedure
#22 /cmd add luckyblocks message onlineplayers() Luckyblocks: %p% got Slowness I for 1m!
#23 /cmd add luckyblocks ascon /effect %p% 2 60
#23 /cmd add luckyblocks ascon /effect %p% 2 60
#25 /cmd add luckyblocks exit
#26 /cmd add luckyblocks message onlineplayers() Very Lucky Blocks: %p% got Haste II for 5m!
#27 /cmd add luckyblocks ascon /effect %p% 3 300 1[/quote]
The rest of this tutorial is in the replies because of the stupid 10000 characters limit