1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Tutorial Plugin Tutorials

Discussion in 'Resources' started by Junkdude, Nov 21, 2016.

?

Did This Help?

  1. Yes

    8 vote(s)
    33.3%
  2. No

    6 vote(s)
    25.0%
  3. Sorta

    10 vote(s)
    41.7%
  1. Junkdude

    Junkdude Zombie

    Messages:
    346
    GitHub:
    JunkDaCoder
    Today, I'm bringing a thread to help developers and future developers! I'm creating this thread so you all can get accustomed to plugin developing. Credits: Falk(PurePerms API)
    This one is very simple! So first, lets assume you have already defined $player, as that is what we will be using! Now first, lets check $player's balance. To do so use the code
    PHP:
    $this->getServer()->getPluginManager()->getPlugin("EconomyAPI")->myMoney($player);
    Simple and easy, right? Now lets take away money! Use the following code to do so.
    PHP:
    $this->getServer()->getPluginManager()->getPlugin("EconomyAPI")->reduceMoney($player10000);
    Note, the 10,000 is the money amount so be sure to change that! Now finally, lets add money with this line of code.
    PHP:
    $this->getServer()->getPluginManager()->getPlugin("EconomyAPI")->addMoney($player10000);
    Again the 10,000 can be changed to anything!
    Variables are some of the most common used "code" pieces in plugins! They help substitute big lines of code. Think of them as abrievations. Take a look at this one for example
    PHP:
    $item1 Item::get(Item::DIAMOND_SWORD01);
    Normally that would be a pain in the butt to rewrite over and over, so thats where variables come in! Defining a variable is simple, use the template I have created
    Code:
    $variable = code goes here;
    A variable is basically a shorter way of using code. Sort of like a definition.

    Feel free to add suggestions, tips, etc!
     
    Last edited by a moderator: Nov 29, 2016
  2. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    You should add a variable for the
    PHP:
     $this->getServer()->getPluginManager()->getPlugin("EconomyAPI")
    so people understand what you can do with variables. :)
     
  3. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    He should explain in theory what variables can do, not just practical. That's like reading code. And for newbies reading code is like reading chinese [if the newbie isn't chinese].
     
  4. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    As I said, 'so people understand what you can do with variables'. I did not mean removing the theory, but just add a small example to show what they can do.
     
  5. Tester_master

    Tester_master Silverfish

    Messages:
    19
    We need functions of what we could do so much more
     
  6. Junkdude

    Junkdude Zombie

    Messages:
    346
    GitHub:
    JunkDaCoder
    I know, I'm in the proccess of writing a huge Variables.PHP file with all that stuff and what it does, I've been adding stuff to it as I go and will be posting it. But tutorials will keep coming to, just give me time.
     
    OnTheVerge likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.