Random items

Discussion in 'Skript' started by Mattllama9877, Jun 22, 2018.

  1. Hi, I have a voteparty plugin and I need help with a skript on making it give a random key. So for a example I have test1 key, test2 and test3. Test3 is the best so pretty much I need a script to give keys but a small chance on giving a test3 key. I tried to make it and it kinda worked but it wasn't the best. So if anyone can help it will be appreciated!

    Thanks!
     
  2. Try this:
    Code (Text):
    command /giverandomkey <player>:
        permission: givekey
        trigger:
            add "Test3" to {_c::*}
            loop 2 times:
                loop 3 times:
                    add "Test%loop-number-1%" to {_c::*}
            set {_key} to random element out of {_c::*}
            make console execute command "/cratekey give %arg-1% %{_key}%"   # or whatever your command for that is
     
  3. Okay. either im not doing it right or im not sure? But I copied what you have and I reload the script and it works. But when I add the keys in it gives me everyone every time I enter the cmd. My key names are Votecrate,Epic and Ancient. Im trying to make it where you get a votecrate more then the other ones and the Ancient is rare. Im not sure how to configure what you made me? I thought I was doing it right but its not looking like I am. :/
     
  4. Okay, its working, But how can I change the rarity?
     
  5. Two

    Two

    You change the loop value in line 6, in the example, there is around 14% chance to get test3, and triple that to the other 2.
     
    • Agree Agree x 1
  6. Another thing is. When I enter the cmd it dosnt always work. I wont execute the command sometimes.
     
  7. Can you explain more? Does it give an error? What does and what doesn't it do?
     
  8. When I enter the command you set it to be, it doesn’t give me a random key every time. It shows that literally nothing is happening. And also I tried to add the other keys into it and change the perssentage but it’s acting weird. There are no errors when I reload the skript. But sometimes it will only give me the same key 4 times.
     
  9. Can you send the code?
     
  10. Code (Text):
    command /giverandomkey <player>:
        permission: givekey
        trigger:
            add "Votecrate" to {_c::*}
            add "Epic" to {_c::*}
            add "Ancient" to {_c::*}
            loop 2 times:
                loop 3 times:
                    add "Test%loop-number-1%" to {_c::*}
            set {_key} to random element out of {_c::*}
            make console execute command "/cr givekey %arg-1% %{_key}% 1"
     
     
  11. Yeah, when I type /giverandomkey it dosnt work every time.
     
  12. Look at console if you've executed a command. Also the loop part was only for the Test1 and Test2 part. You can remove that part
     
  13. So try this:
    Code (Text):
    command /giverandomkey <player>:
        permission: givekey
        trigger:
            loop 5 times:
                add "Votecrate" to {_c::*}
            loop 2 times:
                add "Epic" to {_c::*}
            add "Ancient" to {_c::*}
            set {_key} to random element out of {_c::*}
            make console execute command "/cr givekey %arg-1% %{_key}% 1"
     
  14. It works but can I do something like this to give you 4 keys? Also when I enter that cmd it gives me the same key 4 times? :/


    Code (Text):
    command /giverandomkey <player>:
        permission: givekey
        trigger:
            loop 5 times:
                add "Votecrate" to {_c::*}
            loop 2 times:
                add "Epic" to {_c::*}
            add "Ancient" to {_c::*}
            set {_key} to random element out of {_c::*}
            make console execute command "/cr givekey %arg-1% %{_key}% 1"
            wait 10 ticks
            make console execute command "/cr givekey %arg-1% %{_key}% 1"
            wait 10 ticks
            make console execute command "/cr givekey %arg-1% %{_key}% 1"
            wait 10 ticks
            make console execute command "/cr givekey %arg-1% %{_key}% 1"
     
  15. Two

    Two

    You can do it like
    Code (Text):
    command /giverandomkey <player>:
        permission: givekey
        trigger:
            loop 5 times:
                add "Votecrate" to {_c::*}
            loop 2 times:
                add "Epic" to {_c::*}
            add "Ancient" to {_c::*}
            set {_key} to random element out of {_c::*}
            set {_key2} to random element out of {_c::*}
            set {_key3} to random element out of {_c::*}
            set {_key4} to random element out of {_c::*}
            make console execute command "/cr givekey %arg-1% %{_key}% 1"
            wait 10 ticks
            make console execute command "/cr givekey %arg-1% %{_key2}% 1"
            wait 10 ticks
            make console execute command "/cr givekey %arg-1% %{_key3}% 1"
            wait 10 ticks
            make console execute command "/cr givekey %arg-1% %{_key4}% 1"
     
  16. Okay, its working now. Thank you guys for the help I appreciate it sooo much! :)
     
  17. You can also do this (a little bit less code):
    Code (Text):
    command /giverandomkey <player>:
        permission: givekey
        trigger:
            loop 5 times:
                add "Votecrate" to {_c::*}
            loop 2 times:
                add "Epic" to {_c::*}
            add "Ancient" to {_c::*}
            loop 4 times:
                set {_key} to random element out of {_c::*}
                make console execute command "/cr givekey %arg-1% %{_key}% 1"
     
    • Like Like x 1