1. Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  2. LOOKING FOR A VERSION OF SKRIPT??:

    You can always check our our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved Random ID's generator

Discussion in 'Skript' started by Wolwer, Aug 12, 2019 at 8:22 PM.

Tags:
  1. Wolwer

    Wolwer Well-Known Member

    Joined:
    Feb 8, 2018
    Messages:
    47
    Likes Received:
    3
    Hi!
    I need to create a random ID's (numbers with letters value) generator.

    Smith like:
    Code (Text):
    1. set {_id} to "%random integer between 111111 and ZZZZZZ%"
    Please, help. <3

     
  2. Best Answer:
    Post #11 by Wolwer, Aug 14, 2019 at 6:34 PM
  3. malia

    malia Well-Known Member

    Joined:
    Jul 24, 2019
    Messages:
    164
    Likes Received:
    15
    You could sum strings (if that's possible in Skript)
     
  4. Wolwer

    Wolwer Well-Known Member

    Joined:
    Feb 8, 2018
    Messages:
    47
    Likes Received:
    3
    Idk if it possible in skript. But I need to create it ._.
     
  5. malia

    malia Well-Known Member

    Joined:
    Jul 24, 2019
    Messages:
    164
    Likes Received:
    15
    You could MD5 hash something and cut just some characters, or somehow print the value of a String as hex or something, most languages will return the pointer address to the memory.
     
    • Like Like x 1
  6. Wolwer

    Wolwer Well-Known Member

    Joined:
    Feb 8, 2018
    Messages:
    47
    Likes Received:
    3
    Some examples?

    I've read this in docs: https://docs.skunity.com/syntax/search/id:2203
    But I need to create a short id (6 CAPS-letters with numbers). I think, it can be created with more simple way...

    P.s. sorry for bad English
     
  7. malia

    malia Well-Known Member

    Joined:
    Jul 24, 2019
    Messages:
    164
    Likes Received:
    15
    With Skript? I'm not sure, MD5 a string and cut characters
     
    • Friendly Friendly x 1
  8. Wolwer

    Wolwer Well-Known Member

    Joined:
    Feb 8, 2018
    Messages:
    47
    Likes Received:
    3
    Hrm, I watched a thread on spigot and saw interesting skript:
    https://www.spigotmc.org/threads/skript-help-w-random-chars-letters.319994/

    Maybe we should create a list with chars and than randomize them. For example:
    Code (Text):
    1. command /abcd:
    2.     trigger:
    3.         set {id::*} to "A", "E", "Z", "O", "F", "P" and "L"
    4.         set {id1::*} to "A", "E", "Z", "O", "F", "P" and "L"
    5.         set {id2::*} to "A", "E", "Z", "O", "F", "P" and "L"
    6.  
    7.      
    8. command /genabcd:
    9.     trigger:
    10.         set {_gen} to random element out of {id::*}
    11.         set {_gen1} to random element out of {id1::*}
    12.         set {_gen2} to random element out of {id2::*}
    13.         send "%{_gen}%%{_gen1}%%{_gen2}%"
    It will generate 3 random chars from all objecrs list.
     
  9. malia

    malia Well-Known Member

    Joined:
    Jul 24, 2019
    Messages:
    164
    Likes Received:
    15
    Performance issues
     
    • Agree Agree x 1
  10. Wolwer

    Wolwer Well-Known Member

    Joined:
    Feb 8, 2018
    Messages:
    47
    Likes Received:
    3
    Why?
     
  11. malia

    malia Well-Known Member

    Joined:
    Jul 24, 2019
    Messages:
    164
    Likes Received:
    15
    Creating multiple variables and allocating them in memory (not static afaik) leads to performance issues.
     
  12. Wolwer

    Wolwer Well-Known Member

    Joined:
    Feb 8, 2018
    Messages:
    47
    Likes Received:
    3
    Ok, so if I will create those variables, than use it and after will remove them, will I get performance issues?
    Code (Text):
    1.  
    2.    
    3. command /genabcd:
    4.     trigger:
    5.         set {id::*} to "A", "E", "Z", "O", "F", "P" and "L"
    6.         set {id1::*} to "A", "E", "Z", "O", "F", "P" and "L"
    7.         set {id2::*} to "A", "E", "Z", "O", "F", "P" and "L"
    8.         set {_gen} to random element out of {id::*}
    9.         set {_gen1} to random element out of {id1::*}
    10.         set {_gen2} to random element out of {id2::*}
    11.         send "%{_gen}%%{_gen1}%%{_gen2}%"
    12.         delete {id::*}
    13.         delete {id1::*}
    14.         delete {id2::*}
     
  13. malia

    malia Well-Known Member

    Joined:
    Jul 24, 2019
    Messages:
    164
    Likes Received:
    15
    Can you not directly print the random element on the string? Also I have no idea on how they delete the variables from memory.
     
    • Informative Informative x 1
  14. Wolwer

    Wolwer Well-Known Member

    Joined:
    Feb 8, 2018
    Messages:
    47
    Likes Received:
    3
    Omg I used really SO many variables in memory, but the performance of my server isn't going down. I think, the performance issue isn't a big problem. Anyway, this code should work. Thank you for your reply.
     
  15. malia

    malia Well-Known Member

    Joined:
    Jul 24, 2019
    Messages:
    164
    Likes Received:
    15
    If you wanna do it the Ghetto way sure, go ahead it's your server not mine.

    "Bandaiding is never OK"
     
    • Agree Agree x 1
  16. MRS777

    MRS777 Member

    Joined:
    Feb 4, 2017
    Messages:
    5
    Likes Received:
    0
Loading...