Give player an amount as an arg

Discussion in 'Plugin Development' started by Dirtcraft24, Feb 5, 2015.

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

    Dirtcraft24

    Im currently trying to make a function where /coins add {number} and it adds that amount. I already have a giveCoins function and im trying to use it in a command but it says it needs to be a int and its a string. Currently still learning so excuse me if its very simple but whats a way to fix this?

    Code:
    http://hastebin.com/ugututoheh.avrasm
     
  2. Offline

    CullanP

  3. Offline

    Dirtcraft24

    The onl
    The only problem is if its a String then it wont work because im in need of /coins add {number} and a string isnt that? Im probably just not understanding. Wouldnt it needs to be args[1] though?
     
  4. Offline

    CullanP

    Use int addcoins = Integer.parseInt(args[1]);
    Surround this with a try/catch for NumberFormatException - If the arg isn't a number it will throw numberformatexception and you can put a message such as "Error: That is not a number"
    Enough feeding from me. If you don't know what a try/catch block is, google is your best friend :O
     
    teej107 likes this.
  5. Offline

    Dirtcraft24

    Alright thank you for the fast reply and help. I will try now
     
    CullanP likes this.
Thread Status:
Not open for further replies.

Share This Page