Solved How to get a number from a permission node?

Discussion in 'Plugin Development' started by MM1990d, Oct 28, 2012.

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

    MM1990d

    Hi, I want to make this work:
    Code:
                Player killed = event.getEntity();
                Player killer = event.getEntity().getKiller();
                if (perms.has(killer, "kfm.czarodziej"))
                {
                    if (perms.has(killed, "kfm.mage." + x))
                    {
                        int m = 10 * x;
                        EconomyResponse r = economy.depositPlayer(killer.getName(), m);
                        killer.sendMessage(String.format("You have killed " + killed.getName() + " and earned + " + m + "$"));
                    }
                }
    But I don't know how to do it.
    Can anyone help me, please?
     
  2. Offline

    Woobie

    MM1990d
    - So what is the problem?
    - Did you setup the economy
    - Any errors?
    Also, you are withdrawing money (taking money from the player)
    You should use economy.depositPlayer
     
  3. Offline

    MM1990d

    Yeah, sorry ;P

    But how to detect X?
     
  4. Offline

    Timr

    int x =0; m = 10 * x;

    0 * 10 = 0

    You're trying to give them 0?
     
  5. Offline

    the_merciless

    what exactly does this mean?

    if (perms.has(killed, "kfm.mage." + x))
     
  6. Offline

    MM1990d

    No, I'm trying to give them M. (x = multiplier)

    It means:
    If killed player has permission kfm.mage.x
    m = 10 * x
    Give M to the killer


    For example:
    If I have permission kfm.mage.5 and someone will kill me, he will earn 50 $

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 29, 2016
  7. Offline

    the_merciless

    Oh i see, i dont know how you would get a number from a permission. I guess you would have to hook into your permissions plugin
     
  8. Offline

    xXSniperzzXx_SD

    10*0=0 so.....
     
  9. Offline

    the_merciless

    he has set the variable as 0, but is trying to change it so it equals the number in the permission node

    MM1990d perhaps you should rename this thread to "How to get a number from a permission node?"
     
  10. Offline

    MM1990d

    What?
    If someone has permission kfm.mage.5:
    10 * 5 = 50

    Yeah, thanks

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 29, 2016
  11. Offline

    the_merciless

    this is your problem line. You are not getting the number from this

    if (perms.has(killed, "kfm.mage." + x))
     
  12. Offline

    MM1990d

    I know that I won't get the number from this. It's here only to show you what I'm trying to do.
     
  13. Offline

    the_merciless

    You will probably need a for loop of some sort.

    for (int x = 1; x <1000; x++){
    if (perms.has(killed, "kfm.mage." + x)){
    //do this
    }
    }Not sure if this will work but its got to be worth a try
     
    MM1990d likes this.
  14. Offline

    cman1885

    Loop through their perms, if it starts with kfm.mage. get a substring.
    EDIT: Mine is less resource intensive than the for loop.
     
    MM1990d likes this.
  15. Offline

    MM1990d

    Thanks, I'll try.
     
Thread Status:
Not open for further replies.

Share This Page