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

Solved Player Reward System -code?

Discussion in 'Development' started by MC ATECH, Apr 20, 2017.

  1. MC ATECH

    MC ATECH Baby Zombie

    Messages:
    117
    GitHub:
    mcpeatech
    Hello!

    This is my first post and i need some help to integrate a fully functional player reward system into a mini game plugin. I want to know if it's possible to do it simply with a few lines of code or if i would need to remake the mini game code, having not much experience with php this would be hard to do.. This is why i came here :p

    For example if a player wins the game the game would pay them say 1000 coins or an item reward. The game already tells the player that they won if that helps. If someone could help or guide me with this i would really appreciate it. If you need the mini game code i will email it to you :3

    Thanks, MC ATECH.
     
    Last edited by a moderator: Apr 22, 2017
    Smarticles101 and rektpixel like this.
  2. Smarticles101

    Smarticles101 Silverfish

    Messages:
    22
    GitHub:
    Smarticles101
    That seems easily do-able. Is the plugin open source?
     
  3. MC ATECH

    MC ATECH Baby Zombie

    Messages:
    117
    GitHub:
    mcpeatech
    It used to be, however it no longer is. (I did not create the plugin). I can still send the files to you if you need them :p
     
  4. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    well that would meant not everyone could help you
     
  5. Primus

    Primus Zombie Pigman

    Messages:
    749
  6. MC ATECH

    MC ATECH Baby Zombie

    Messages:
    117
    GitHub:
    mcpeatech
    So could I use the code highlighted in the factionspe plugin simply by copying and pasting the code into the source code of the minigame plugin?
    Will that work for what I need it to do?
     
  7. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    No. Copying and Pasting will always cause more issues than it resolves, especially if you don't know what you are doing. I believe he was just giving an example for whoever wants to fill the request.
     
    jasonwynn10 likes this.
  8. rektpixel

    rektpixel Baby Zombie

    Messages:
    186
    ehh
     
    MC ATECH likes this.
  9. MC ATECH

    MC ATECH Baby Zombie

    Messages:
    117
    GitHub:
    mcpeatech
    So is this possible :3 I will give it a blast tomorrow I've just been too busy the past day with work :/
     
  10. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    It should be really easy if the plugin is structured okay.
     
    MC ATECH likes this.
  11. MC ATECH

    MC ATECH Baby Zombie

    Messages:
    117
    GitHub:
    mcpeatech
    Alright I believe it is! If I have any problems I will notify this thread!
     
  12. MC ATECH

    MC ATECH Baby Zombie

    Messages:
    117
    GitHub:
    mcpeatech
    I've managed to make the code to teleport a player back to the spawn and to clear there inventory but im struggling with adding in a reward system. code:
    PHP:
    $pl->sendMessage($this->prefix TextFormat::GREEN " You won!");
    $spawn $this->plugin->getServer()->getDefaultLevel()->getSafeSpawn();
    $this->plugin->getServer()->getDefaultLevel()->loadChunk($spawn->getX(), $spawn->getZ());
    if (
    $pl->isOnline()) {
        
    $pl->teleport($spawn00);
        
    $pl->getInventory()->clearAll();
     
    Last edited by a moderator: Apr 22, 2017
    rektpixel likes this.
  13. MC ATECH

    MC ATECH Baby Zombie

    Messages:
    117
    GitHub:
    mcpeatech
    Could I add in an edited version of for a winner? Maybe do this with another variable?
    if($cmd->getName() == "test"){ $sender->getInventory()->addItem(Item::get(364,0,2)); //364 = Item ID Value (in this case, 364 is steak) $sender->sendMessage(TextFormat::BOLD."You have just recieved 4 steak!"); } return true;
     
  14. MC ATECH

    MC ATECH Baby Zombie

    Messages:
    117
    GitHub:
    mcpeatech
    I managed to code it :3
    Even having little php experience I managed :p If i can do it you can!
     
    HimbeersaftLP likes this.
  15. rektpixel

    rektpixel Baby Zombie

    Messages:
    186
    boi,
    PHP:
    $pl->sendMessage(TextFormat::GRAY "==============================");
    $pl->sendMessage(TextFormat::GREEN "                              ");
    $pl->sendMessage(TextFormat::YELLOW TextFormat::BOLD "    You have won the match");
    $pl->sendMessage(TextFormat::AQUA "       100 coins reward!");
    $pl->sendMessage(TextFormat::GREEN "                              ");
    $pl->sendMessage(TextFormat::GRAY "==============================");
    $spawn $this->plugin->getServer()->getDefaultLevel()->getSafeSpawn();
    $this->plugin->getServer()->getDefaultLevel()->loadChunk($spawn->getX(), $spawn->getZ());
    if (
    $pl->isOnline()) {
        
    $pl->teleport($spawn00);
        
    $pl->getInventory()->clearAll();
        
    $this->getServer()->getPluginManager()->getPlugin("EconomyAPI")->addMoney($pl->("100"));
    sexy msg and reward XD
     
    Defications2po and MC ATECH like 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.