本文整理汇总了PHP中onebone\economyapi\EconomyAPI::reduceMoney方法的典型用法代码示例。如果您正苦于以下问题:PHP EconomyAPI::reduceMoney方法的具体用法?PHP EconomyAPI::reduceMoney怎么用?PHP EconomyAPI::reduceMoney使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类onebone\economyapi\EconomyAPI
的用法示例。
在下文中一共展示了EconomyAPI::reduceMoney方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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.");
}
}
}
示例2: onCommand
public function onCommand(CommandSender $sender, Command $command, $label, array $args)
{
if (strtolower($command) == '확성기') {
if (!isset($args[0])) {
return false;
}
if ($this->economy == null) {
$sender->sendMessage("EconomyAPI 플러그인이 없어서 이 명령어를 사용할 수 없습니다.");
return true;
}
if ($this->isMute() && !$sender->isOp()) {
$sender->sendMessage(TextFormat::RED . "현재 채팅을 할 수 없습니다.");
return true;
}
if ($this->economy->reduceMoney($sender, $this->config["speaker-cost"]) != EconomyAPI::RET_SUCCESS) {
$sender->sendMessage(TextFormat::RED . "확성기를 사용할 돈이 부족합니다. (비용: {$this->config["speaker-cost"]})");
return true;
}
$message = implode(" ", $args);
$this->getServer()->broadcastMessage(TextFormat::AQUA . "[확성기] " . $sender->getName() . " > " . $message);
$sender->sendMessage("{$this->config["speaker-cost"]}원을 내고 확성기를 사용하였습니다.");
} else {
if (strtolower($command) == 'mute') {
if ($this->isMute()) {
$this->setMute(false);
$this->getServer()->broadcastMessage(TextFormat::DARK_AQUA . "관리자가 채팅을 허용상태로 변경했습니다.");
} else {
$this->setMute(true);
$this->getServer()->broadcastMessage(TextFormat::DARK_AQUA . "관리자가 채팅을 비허용상태로 변경했습니다.");
}
}
}
return true;
}
示例3: 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!");
}
}
示例4: onBlockPlace
/**
* @priority LOWEST
* @ignoreCancelled true
* @param BlockPlaceEvent $event
*/
public function onBlockPlace(BlockPlaceEvent $event)
{
$player = $event->getPlayer();
$block = $event->getBlock();
$job = $this->jobs->get($this->player->get($player->getName()));
if ($job !== false) {
if (isset($job[$block->getID() . ":" . $block->getDamage() . ":place"])) {
$money = $job[$block->getID() . ":" . $block->getDamage() . ":place"];
if ($money > 0) {
$this->api->addMoney($player, $money);
} else {
$this->api->reduceMoney($player, $money);
}
}
}
}
示例5: makeClan
public function makeClan(CommandSender $maker, $name, $type = "talk")
{
$this->api->reduceMoney($maker->getName(), $this->setting["money"]);
$this->clanlist[$name] = $name;
$this->clandata[$name][$maker->getName()] = "admin";
$this->clandata[$name]["list"] = array();
array_push($this->clandata[$name]["list"], $maker->getName());
$this->playerclan[$maker->getName()] = $name;
if (!isset($this->type["type"][$type])) {
$maker->sendMessage($this->get("type-notFound") . " : " . $type);
$maker->sendMessage($this->get("clan-type"));
return;
} else {
$this->clandata[$name]["type"] = $type;
}
$this->message($maker, $this->get("PocketClan-ClanMade") . " [" . $name . "] [" . $type . "]");
}
示例6: 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;
}
示例7: onCommand
//.........这里部分代码省略.........
$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) {
$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}");
}
}
}
}
}
break;
default:
$sender->sendMessage("Usage: " . $command->getUsage());
}
break;
case "jackpot":
if (!$sender instanceof Player) {
$sender->sendMessage("Please run this command in-game.");
break;
}
$money = array_shift($params);
if (!is_numeric($money)) {
$sender->sendMessage("Usage: " . $command->getUsage());
break;
}
$money = (int) $money;
if ($this->api->myMoney($sender) < $money) {
$sender->sendMessage("You don't have money to jackpot " . $this->api->getMonetaryUnit() . "{$money}");
break;
}
$rand = rand(0, $this->config->get("jackpot-winning"));
if ($rand === 0) {
$this->api->addMoney($sender, $money);
$sender->sendMessage("You've wined jackpot! You've got " . $this->api->getMonetaryUnit() . "{$money}");
} else {
$this->api->reduceMoney($sender, $money);
$sender->sendMessage("You've failed your jackpot! You've lost " . $this->api->getMonetaryUnit() . "{$money}");
}
break;
}
return true;
}
示例8: 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;
}
}
}