当前位置: 首页>>代码示例>>PHP>>正文


PHP EconomyAPI::myMoney方法代码示例

本文整理汇总了PHP中onebone\economyapi\EconomyAPI::myMoney方法的典型用法代码示例。如果您正苦于以下问题:PHP EconomyAPI::myMoney方法的具体用法?PHP EconomyAPI::myMoney怎么用?PHP EconomyAPI::myMoney使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在onebone\economyapi\EconomyAPI的用法示例。


在下文中一共展示了EconomyAPI::myMoney方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: payTax

 public function payTax()
 {
     if (($percent = $this->config->get("tax-as-percentage")) !== "") {
         $players = $this->getServer()->getOnlinePlayers();
         foreach ($players as $player) {
             if ($player->hasPermission("economytax.tax.avoid")) {
                 continue;
             }
             $money = $this->api->myMoney($player);
             $taking = $money * ($percent / 100);
             $this->api->reduceMoney($player, min($money, $taking), true, "EconomyTax");
             $player->sendMessage("Your " . EconomyAPI::getInstance()->getMonetaryUnit() . "{$taking} has taken by tax.");
         }
     } else {
         $money = $this->config->get("tax-as-money");
         $players = $this->getServer()->getOnlinePlayers();
         foreach ($players as $player) {
             if ($player->hasPermission("economytax.tax.avoid")) {
                 continue;
             }
             $this->api->reduceMoney($player, min($this->api->myMoney($player), $money), true, "EconomyTax");
             $player->sendMessage("Your " . EconomyAPI::getInstance()->getMonetaryUnit() . "{$money} has taken by tax.");
         }
     }
 }
开发者ID:Tolo0,项目名称:EconomyS,代码行数:25,代码来源:EconomyTax.php

示例2: onPlayerInteract

 public function onPlayerInteract(PlayerInteractEvent $event)
 {
     $key = $this->getAxisKey($event->getBlock(), self::axisToken);
     if (isset($this->shops[$key]) === false) {
         return;
     }
     $this->economyAPI = EconomyAPI::getInstance();
     $event->setCancelled(true);
     if ($event->getItem()->isPlaceable()) {
         $this->lastInteractedPlayer = $event->getPlayer();
     }
     if ($event->getBlock() instanceof SignPost === false) {
         unset($this->shops[$key]);
         $event->getPlayer()->sendMessage(TextFormat::DARK_RED . self::tag . " Shop has been removed - Shop must be a sign block!");
         return;
     }
     $player = $event->getPlayer();
     if ($this->economyAPI->myMoney($player) < $this->price) {
         $event->getPlayer()->sendMessage(TextFormat::DARK_RED . self::tag . "You don't have enough money to buy!");
         return;
     }
     $this->economyAPI->reduceMoney($player, $this->price);
     array_push($this->box, $player->getName());
     $this->getServer()->broadcastMessage(TextFormat::DARK_AQUA . self::tag . " " . $player->getName() . " bought a lotto ticket!");
     if (count($this->box) == 101) {
         $this->getServer()->broadcastMessage(TextFormat::DARK_AQUA . self::tag . "The winning amount exceeded " . $this->price * 100 . " - Hurry to buy a lotto ticket!");
     }
 }
开发者ID:nesgohood,项目名称:PMMP-Plugins,代码行数:28,代码来源:Lotto.php

示例3: onCommand

 public function onCommand(CommandSender $sp, Command $command, $label, array $args)
 {
     $p = $sp->getName();
     if (!$sp instanceof Player) {
         $sp->sendMessage($this->get("command-inConsole"));
     } else {
         switch ($command) {
             case $this->get("clan"):
                 if (!isset($args[0])) {
                     $this->message($sp, $this->get("clan-help"));
                     break;
                 }
                 switch ($args[0]) {
                     case $this->get("make"):
                         if (!isset($args[1])) {
                             $this->message($sp, $this->get("clan-create-help"));
                             $this->message($sp, $this->get("clan-type"));
                             break;
                         }
                         if ($this->api->myMoney($p) < $this->setting["money"]) {
                             $this->message($sp, $this->get("not-enough-money") . " " . $this->setting["money"] . "\$ " . $this->get("need-money"));
                         } else {
                             if (isset($args[1])) {
                                 if (isset($args[2])) {
                                     $type = $args[2];
                                 } else {
                                     $type = "talk";
                                 }
                                 $this->makeClan($sp, $args[1], $type);
                             }
                         }
                         return true;
                     case $this->get("join"):
                         if (!isset($args[1])) {
                             $this->message($sp, $this->get("clan-notInput"));
                             break;
                         }
                         if ($this->getClan($p) == $args[1]) {
                             $this->message($sp, $this->get("aleady-inClan") . " [" . $args[1] . "]");
                             break;
                         }
                         if ($this->getClan($p) != null) {
                             $this->message($sp, $this->get("aleady-inClan") . " [" . $this->getClan($p) . "]");
                             break;
                         }
                         foreach ($this->clanlist as $cl) {
                             if ($cl == $args[1]) {
                                 $this->clandata[$args[1]][$p] = "user";
                                 array_push($this->clandata[$args[1]]["list"], $p);
                                 $this->playerclan[$p] = $args[1];
                                 $this->message($sp, $this->get("success-joined") . "\"" . $args[1] . "\"");
                                 break;
                             } else {
                                 $this->message($sp, $this->get("PocketClan-cantfindclan"));
                             }
                         }
                         return true;
                     case $this->get("list"):
                         if (isset($args[1])) {
                             $list = "";
                             foreach ($this->clandata[$args[1]]["list"] as $cl) {
                                 $list .= $cl . ", ";
                             }
                             $this->message($sp, "[PocketClan] " . $args[1] . " " . $this->get("people") . " : " . sizeof($this->clandata[$args[1]]["list"]) . " " . $this->get("list") . " : " . $list);
                         } else {
                             $list = "";
                             foreach ($this->clanlist as $cl) {
                                 $list .= $cl . ", ";
                             }
                             $this->message($sp, $list);
                         }
                         return true;
                     case $this->get("leave"):
                         if ($this->getClan($p) != null) {
                             $this->clandata[$this->getClan($p)][$p] = "NotInClan";
                             $this->playerclan[$p] = null;
                             unset($this->clandata[$this->getClan($p)]["list"][array_search($p, $this->clandata[$this->getClan($p)]["list"])]);
                             $this->message($sp, $this->get("leave-clan") . " [" . $this->getClan($p) . "]");
                         } else {
                             $this->message($sp, $this->get("PocketClan-cantfindclan"));
                         }
                         break;
                     default:
                         $this->message($sp, $this->get("clan-help"));
                 }
                 break;
             case $this->get("clanManage"):
                 switch ($args[0]) {
                     case $this->get("delete"):
                         if ($this->clandata[$this->getClan($p)][$p] == "admin") {
                             foreach ($this->clandata[$this->getClan($p)]["list"] as $pl) {
                                 $this->playerclan[$pl] = null;
                             }
                             unset($this->clanlist[array_search($this->getClan($p), $this->clanlist)]);
                             unset($this->clandata[array_search($this->getClan($p), $this->clandata)]);
                         } else {
                             if (!isset($args[1])) {
                                 $this->message($sp, $this->get("delete-help"));
                             } else {
                                 if ($sp->isOP()) {
//.........这里部分代码省略.........
开发者ID:nesgohood,项目名称:PMMP-Plugins,代码行数:101,代码来源:PocketClan.php

示例4: onCommand

 public function onCommand(CommandSender $sender, Command $command, $label, array $args)
 {
     if (!isset($args[0])) {
         return false;
     }
     switch ($args[0]) {
         case '이동':
             if (!isset($args[1])) {
                 $sender->sendMessage("사용법: /돈이동 이동 <서버명> <액수>");
                 $sender->sendMessage("서버목록 보는법: /돈이동 서버목록");
                 break;
             }
             if (!isset($args[2])) {
                 $sender->sendMessage("사용법: /돈이동 이동 <서버명> <액수>");
                 break;
             }
             if (!isset($this->serverlist[$args[1]])) {
                 $sender->sendMessage("해당 서버를 찾을 수 없습니다.");
                 $sender->sendMessage("서버목록 보는법: /돈이동 서버목록");
                 break;
             }
             if (!is_numeric($amount = $args[2])) {
                 $sender->sendMessage(TextFormat::RED . '금액은 숫자만 입력 가능합니다.');
                 break;
             }
             if ($this->economy->reduceMoney($sender, $amount) !== EconomyAPI::RET_SUCCESS) {
                 $lackmoney = $amount - $this->economy->myMoney($sender);
                 $sender->sendMessage(TextFormat::RED . "당신의 돈이 {$lackmoney}원 부족합니다.");
                 break;
             }
             $data = json_encode(["MoneyTransfer", $sender->getName(), $amount]);
             $packet = new DataPacket($this->serverlist[$args[1]]['ip'], $this->serverlist[$args[1]]['port'], $data);
             CPAPI::sendPacket($packet);
             $sender->sendMessage("돈을 {$args[1]} 서버로 이동하였습니다.");
             break;
         case '서버추가':
             if (!$sender->hasPermission("moneytransfer.cmd.addserver")) {
                 $sender->sendMessage(TextFormat::RED . "당신은 이 명령어를 실행할 권한이 없습니다.");
                 break;
             }
             if (!isset($args[1]) || !isset($args[2])) {
                 $sender->sendMessage("사용법: /돈이동 서버추가 <서버명> <아이피[:포트]>");
                 break;
             }
             $iport = explode(":", $args[2]);
             $ip = $iport[0];
             isset($iport[1]) ? $port = $iport[1] : ($port = 19132);
             $this->serverlist[$args[1]]['ip'] = $ip;
             $this->serverlist[$args[1]]['port'] = $port;
             $sender->sendMessage("{$args[1]} 서버를 추가하였습니다.");
             break;
         case '서버목록':
             $count = 1;
             if (!is_array($this->serverlist)) {
                 $sender->sendMessage("설정된 서버 목록이 없습니다. 관리자에게 문의하세요.");
                 break;
             }
             $serverlist = "";
             foreach ($this->serverlist as $servername => $v1) {
                 $serverlist .= $servername . '    ';
                 if (++$count % 7 == 0) {
                     $serverlist .= "\n";
                 }
             }
             $sender->sendMessage("서버목록: ");
             $sender->sendMessage($serverlist);
             break;
         case '서버제거':
             if (!$sender->hasPermission("moneytransfer.cmd.deleteserver")) {
                 $sender->sendMessage(TextFormat::RED . "당신은 이 명령어를 실행할 권한이 없습니다.");
                 break;
             }
             if (!isset($args[1])) {
                 $sender->sendMessage("사용법: /돈이동 서버제거 <서버명>");
                 return true;
             }
             if (!isset($this->serverlist[$args[1]])) {
                 $sender->sendMessage("해당 서버가 목록에 존재하지 않습니다.");
                 return true;
             }
             unset($this->serverlist[$args[1]]);
             $sender->sendMessage("{$args[1]} 서버를 서버목록에서 제거했습니다.");
             break;
         default:
             return false;
     }
     return true;
 }
开发者ID:organization,项目名称:MoneyTransfer,代码行数:88,代码来源:MoneyTransfer.php

示例5: onCommand


//.........这里部分代码省略.........
                         list_general:
                         $output = "[EconomyCasino] Game list : \n";
                         foreach ($this->casino as $player => $casino) {
                             $output .= "{$player} : " . count($this->casino[$player]["players"]) . " \n";
                         }
                         $output = substr($output, 0, -2);
                         $sender->sendMessage($output);
                     } else {
                         if (isset($this->casino[$player])) {
                             $output = "[EconomyCasino] Player list of casino game by : {$player} \n";
                             foreach ($this->casino[$player]["players"] as $p) {
                                 $output .= "{$p}, ";
                             }
                             $output = substr($output, 0, -2);
                         } else {
                             goto list_general;
                         }
                     }
                     break;
                 case "gamble":
                     if (!$sender instanceof Player) {
                         $sender->sendMessage("Please run this command in-game.");
                         break;
                     }
                     if (!$sender->hasPermission("economycasino.command.casino.gamble")) {
                         return true;
                     }
                     $money = array_shift($params);
                     if (!is_numeric($money)) {
                         $sender->sendMessage("Usage: /casino gamble <money>");
                         break;
                     }
                     $money = (int) $money;
                     if ($this->api->myMoney($sender) < $money) {
                         $sender->sendMessage("You don't have money to gamble " . $this->api->getMonetaryUnit() . "{$money}");
                         break;
                     }
                     if (isset($this->casino[$sender->getName()])) {
                         $all = 0;
                         foreach ($this->casino[$sender->getName()]["players"] as $player => $v) {
                             $tmp = min($money, $this->api->myMoney($player));
                             $this->api->reduceMoney($player, $tmp);
                             $all += $tmp;
                         }
                         $got = array_rand($this->casino[$sender->getName()]["players"]);
                         $this->api->addMoney($got, $all, true, "EconomyCasino");
                         foreach ($this->casino[$sender->getName()]["players"] as $p => $v) {
                             if ($got === $p) {
                                 $this->getServer()->getPlayerExact($p)->sendMessage("You've win " . $this->api->getMonetaryUnit() . "{$all}!");
                             } else {
                                 $this->getServer()->getPlayerExact($p)->sendMessage("You've lost " . $this->api->getMonetaryUnit() . "{$money}");
                             }
                         }
                     } else {
                         foreach ($this->casino as $player => $casino) {
                             if (isset($casino["players"][$sender->getName()])) {
                                 $all = 0;
                                 foreach ($this->casino[$player]["players"] as $p => $true) {
                                     $tmp = min($this->api->myMoney($p), $money);
                                     $this->api->reduceMoney($p, $tmp);
                                     $all += $tmp;
                                 }
                                 $got = array_rand($this->casino[$player]["players"]);
                                 $this->api->addMoney($got, $all, true, "EconomyCasino");
                                 foreach ($this->casino[$player]["players"] as $p => $v) {
                                     if ($got === $p) {
开发者ID:dog194,项目名称:EconomyS,代码行数:67,代码来源:EconomyCasino.php

示例6: onPacketReceive

 public function onPacketReceive(CustomPacketReceiveEvent $ev)
 {
     $data = $ev->getPacket()->data;
     // json 화 필요할 수도 있음
     if (!is_array($data)) {
         echo "[테스트] 어레이가 아닌 정보 전달됨";
         return;
     }
     if ($data[0] != $this->db["passcode"]) {
         echo "[테스트] 패스코드가 다른 정보 전달됨";
         return;
     }
     if ($this->db["mode"] == "master") {
         // 마스터 서버 코딩
         switch ($data[1]) {
             case "createBank":
                 // slave->master = [0패스코드, 1createBank, 2계좌명, 3username, 4비용]
                 // master->slave = [0패스코드, 1createBank, 2계좌명, 3username, 4true:success|false:failed]
                 if (isset($this->db["bank"][$data[2]])) {
                     $data[4] = false;
                     CPAPI::sendPacket(new DataPacket($ev->getPacket()->address, $ev->getPacket()->port, $data));
                     break;
                 }
                 $this->db["bank"][$data[2]]["price"] = $data[4];
                 $this->db["bank"][$data[2]]["username"] = $data[3];
                 $data[4] = true;
                 CPAPI::sendPacket(new DataPacket($ev->getPacket()->address, $ev->getPacket()->port, $data));
                 break;
             case "useBank":
                 // slave->master = [0패스코드, 1useBank, 2계좌명, 3username]
                 // master->slave = [0패스코드, 1useBank, 2계좌명, 3username, 4true:success|false:failed]
                 if (!isset($this->db["bank"][$data[2]])) {
                     $data[4] = false;
                     CPAPI::sendPacket(new DataPacket($ev->getPacket()->address, $ev->getPacket()->port, $data));
                     break;
                 }
                 $price = $this->db["bank"][$data[2]]["price"];
                 $playerMoney = $this->economyAPI->myMoney($this->db["bank"][$data[2]]["username"]);
                 if ($playerMoney >= $price) {
                     // 해당계좌 돈뺏기
                     $this->economyAPI->reduceMoney($this->db["bank"][$data[2]]["username"], $price);
                     // 해당 돈 유저에게 지급하기
                     $this->economyAPI->addMoney($data[3], $price);
                     $data[4] = true;
                     CPAPI::sendPacket(new DataPacket($ev->getPacket()->address, $ev->getPacket()->port, $data));
                 } else {
                     $data[4] = false;
                     CPAPI::sendPacket(new DataPacket($ev->getPacket()->address, $ev->getPacket()->port, $data));
                 }
                 unset($this->db["bank"][$data[2]]);
                 break;
         }
     } else {
         // 슬레이브 서버 코딩
         $player = $this->getServer()->getPlayer($data[1]);
         if (!$player instanceof Player) {
             return;
         }
         switch ($data[1]) {
             case "createBank":
                 // master->slave = [0패스코드, 1createBank, 2계좌명, 3username, 4true:success|false:failed]
                 // failed-createBank
                 if ($data[4] == false) {
                     $this->message($player, $this->get("failed-createBank"));
                     break;
                 }
                 $this->db["bank"][$data[0]]["price"] = $data[1];
                 $this->db["bank"][$data[0]]["username"] = $player->getName();
                 $this->message($player, $this->get("passcode-created"));
                 break;
             case "useBank":
                 // slave->master = [0패스코드, 1useBank, 2계좌명, 3username]
                 // master->slave = [0패스코드, 1useBank, 2계좌명, 3username, 4true:success|false:failed]
                 break;
         }
     }
 }
开发者ID:nesgohood,项目名称:PMMP-Plugins,代码行数:77,代码来源:Main.php


注:本文中的onebone\economyapi\EconomyAPI::myMoney方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。