Plugin Help Randomizer

Discussion in 'Plugin Help/Development/Requests' started by Scorpionvssub, Nov 18, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    Scorpionvssub

    Any one know any good tutorials that really go into debt about randomizers like, some plugins allow 0.001 1 50 70 or even a regular 100% where 100% is always and 0.001 is extremely small in odds..

    I can make a randomizer that just goes btween 1-100 but i want 1% to act as rare and 100% to act as "always" cant find anything on this or have no clue how to do it..exacly
     
    Last edited: Nov 19, 2015
  2. Offline

    teej107

    @Scorpionvssub Have your debugged? Have you looked at the Bukkit JavaDocs?
     
  3. Offline

    Scorpionvssub

    bump
     
    Last edited: Nov 19, 2015
  4. Offline

    Mrs. bwfctower

    @Scorpionvssub Try something. If it doesn't work, post what you tried for help. Don't post asking for code.
     
  5. Offline

    Scorpionvssub

  6. Offline

    Mrs. bwfctower

    @Scorpionvssub Have you tried anything? We're not here to write code for you or to tell you how to do everything.

    Post what you've tried, and we'll help you with what's not working.
     
  7. Offline

    Scorpionvssub

    @teej107 I would if i could find any other than randomizer plugins and such
     
  8. Offline

    Scorpionvssub

    Code:
                    Random r = new Random();
                    int total;
                    total = getConfig().getInt("Settings.eggchance");
                    int outcome;
                    outcome = r.nextInt(100 - total);
                    if (outcome == total) {
                        ItemStack egg = new ItemStack(Material.DRAGON_EGG);
                        egg.setDurability((short) 3);
                        ItemMeta meta = egg.getItemMeta();
    
                        meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', getConfig().getString("Settings.eggname")));
                        List<String> lore = new ArrayList<>();
                        lore.add(ChatColor.translateAlternateColorCodes('&', getConfig().getString("Settings.egglore")));
                        meta.setLore(lore);
                        egg.setItemMeta(meta);
    
                        killer.getInventory().addItem(egg);
                        killer.updateInventory();
                    }
    The line for r.nextint gives errors sauing "must be positive"
     
    Last edited: Dec 2, 2015
  9. Offline

    Mrs. bwfctower

    @Scorpionvssub What is total? That's probably larger than larger than or equal to 100.
     
    Last edited: Dec 2, 2015
  10. Offline

    Scorpionvssub

    @Mrs. bwfctower first tried 30 then 100 just trying to create where 100% is always and 1% is rare,,
     
  11. Offline

    Mrs. bwfctower

  12. Offline

    Scorpionvssub

    yea i k so how do i fix it or whats the idea or suggestion 100-100+100?

    no clue instead of telling me what it would do rather then accually helping which is more usefull then this... cause i know it has to positive its what the error already said so thats pointing out the obvious...

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Dec 3, 2015
  13. Offline

    Mrs. bwfctower

    @Scorpionvssub Add one to outcome, because that way, as long as total is <= 100, outcome will always be positive. Or just change it to '101 - total'.
     
Thread Status:
Not open for further replies.

Share This Page