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

Need Help With Code

Comments in 'Plugin Development' started by Adrian, Jun 28, 2014.

  1. RekkuzaRage
    Offline

    RekkuzaRage Active Member

    Joined:
    Apr 15, 2014
    Posts:
    251
    Minecraft User:
    RekkuzaRage
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    RekkuzaRage likes this.
  3. Darunia18
    Offline

    Darunia18 Staff Member Sectional Moderator

    Joined:
    Aug 23, 2013
    Posts:
    754
    Plugins:
    2
    Minecraft User:
    Darunia18
    You need to 1. Figure out your permission/rank plugin's API and 2. learn your economy plugin's API. A plugin like this is a bit more complicated than you think because it requires you to use other plugins. You can't just have it run commands, because not only could that be dangerous, but some plugins don't allow you to run commands from the console to do certain tasks.

    I actually planned to work on it since I already have some working code. I just need to make it so that the ranks and prices can be set in a config file, and then maybe add more rank and economy plugins that it can work with.
    RekkuzaRage and LDX like this.
  4. Adrian
    Offline

    Adrian Active Member

    Joined:
    Jun 26, 2014
    Posts:
    64
    Minecraft User:
    Adrian
    Yeah, I have all the plugins.
  5. Adrian
    Offline

    Adrian Active Member

    Joined:
    Jun 26, 2014
    Posts:
    64
    Minecraft User:
    Adrian
    Can someone please fix my sample.php, when it runs /pay bank 10000 they get the rank even if they don't have enough money. Can you also show me how to register multiple commands. such as $this->api->console->register("rankup","ranks you up",array($this, "rankup"));
    I can do this multiple times to register many of them. I want to know how I would run different commands for each one. Can you edit my plugin and fix my bug with the money, and also show me like an example code that would show me how I would run multiple commands for multiple plugin registered commands. Thank You!

    Here's an upgraded version:

    Attached Files:

  6. Darunia18
    Offline

    Darunia18 Staff Member Sectional Moderator

    Joined:
    Aug 23, 2013
    Posts:
    754
    Plugins:
    2
    Minecraft User:
    Darunia18
    No, I mean you have to add in functions in the code of RankUp to work with the plugins. Having them installed just doesn't do it.

    You're just running that command from the console, and not as the player. As I said, I'm already working on this plugin for the new API. Just wait a bit until then.
    Adrian likes this.
  7. Adrian
    Offline

    Adrian Active Member

    Joined:
    Jun 26, 2014
    Posts:
    64
    Minecraft User:
    Adrian
    You are working on it, well thank you very much! ! ! :D :D
    Darunia18 likes this.
  8. Adrian
    Offline

    Adrian Active Member

    Joined:
    Jun 26, 2014
    Posts:
    64
    Minecraft User:
    Adrian
    Will this line do the trick.

    $this->api->economy->takeMoney($player,$amount)
    Can you please do it for any player and amount as 10000, need a good example. Thanks.
  9. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    PHP:
    $this->api->console->run("pay EconServ $money"$player);
    maybe this?
    EconServ, which is inspired by ChanServ and NickServ on freenode :p

    Jokes aside, I mean:
    PHP:
    $this->api->console->run("any command"$player);
    where you don't have to run as console.
  10. iFootball
    Offline

    iFootball Active Member

    Joined:
    Jun 9, 2014
    Posts:
    84
    Minecraft User:
    iFootball
    I'm testing it... Sorry its taking so long
  11. Adrian
    Offline

    Adrian Active Member

    Joined:
    Jun 26, 2014
    Posts:
    64
    Minecraft User:
    Adrian
    So can it be like this,

    $this->api->console->run->("pay bank 10000", $player);

    Thank You very much!!!
  12. Darunia18
    Offline

    Darunia18 Staff Member Sectional Moderator

    Joined:
    Aug 23, 2013
    Posts:
    754
    Plugins:
    2
    Minecraft User:
    Darunia18
    The API is a bit confusing, and using takeMoney actually gives the player money XD It's kinda confusing.
  13. Adrian
    Offline

    Adrian Active Member

    Joined:
    Jun 26, 2014
    Posts:
    64
    Minecraft User:
    Adrian
    What about

    $this->api->economy->useMoney($player,$amount);
  14. Adrian
    Offline

    Adrian Active Member

    Joined:
    Jun 26, 2014
    Posts:
    64
    Minecraft User:
    Adrian
  15. Darunia18
    Offline

    Darunia18 Staff Member Sectional Moderator

    Joined:
    Aug 23, 2013
    Posts:
    754
    Plugins:
    2
    Minecraft User:
    Darunia18
    Yep that's it. It's really confusing, I know. Took me a few days to figure that one out :p
  16. Darunia18
    Offline

    Darunia18 Staff Member Sectional Moderator

    Joined:
    Aug 23, 2013
    Posts:
    754
    Plugins:
    2
    Minecraft User:
    Darunia18
    By the way if you wanted this to work for multiple ranks, you're going to have to add a switch function to test what rank each player is. You have to use the PermissionPlus API for this one. Once you use whatever that is (I forget it exactly), you have to have the switch function test each rank you have set up in your PermissionPlus configs. Then after that, in each case, you have to take whatever money it is, then rank them up to the next rank. Because of how PermissionPlus is made, there is some code that doesn't allow you to run commands to change a player's rank from the console. I had to take those lines of code out and then use $this->api->console->run() to run the command to rank them up. Trust me, it's a really, really long process XD
    Adrian likes this.
  17. Adrian
    Offline

    Adrian Active Member

    Joined:
    Jun 26, 2014
    Posts:
    64
    Minecraft User:
    Adrian
    So, XTIRANKMANAGER-Rankmanager won't work
  18. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Use NumericRanks! It has the best plugin API in the world! :p

    As a matter of fact, look at the documentation and find the many events.
    64FF00 and Darunia18 like this.
  19. Darunia18
    Offline

    Darunia18 Staff Member Sectional Moderator

    Joined:
    Aug 23, 2013
    Posts:
    754
    Plugins:
    2
    Minecraft User:
    Darunia18
    Oh you can use whatever plugin :p I made RankUp using PermissionPlus, kinda thought you would be too. Forgot XTiRankManager existed XD

    If you're making it for the new API, I'll have to look at some of the documentation. When I add configuration stuff to RankUp, I want it to work on all the economy and rank/permission plugins in the new API (so like Economys, PocketMoney, and xEcon, and then xPermsMgr, SimpleRanks, and NumericRanks).
    64FF00 likes this.
  20. Adrian
    Offline

    Adrian Active Member

    Joined:
    Jun 26, 2014
    Posts:
    64
    Minecraft User:
    Adrian
    So I can do it like

    $this->api->economy->useMoney($player,10000);

Share This Page

Advertisement