本文整理汇总了PHP中onebone\economyapi\EconomyAPI::addMoney方法的典型用法代码示例。如果您正苦于以下问题:PHP EconomyAPI::addMoney方法的具体用法?PHP EconomyAPI::addMoney怎么用?PHP EconomyAPI::addMoney使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类onebone\economyapi\EconomyAPI
的用法示例。
在下文中一共展示了EconomyAPI::addMoney方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onTick
public function onTick()
{
if (--$this->tick > 0) {
if ($this->tick % 6 === 0) {
$this->getServer()->broadcastMessage(TextFormat::DARK_AQUA . self::tag . $this->getTimeText() . "lefts to result announcement!");
}
} else {
$count = count($this->box);
if ($count > 0) {
$winner = $this->box[array_rand($this->box)];
$winningAmount = $count * $this->price;
$this->economyAPI->addMoney($winner, $winningAmount);
$winnerInst = $this->getServer()->getPlayer($winner);
if ($winnerInst !== null) {
$winnerInst->sendMessage(TextFormat::GREEN . self::tag . " Congratulations! You've won the lottery!");
$winnerInst->sendMessage(TextFormat::GREEN . self::tag . " Please check your money :)");
}
$this->getServer()->broadcastMessage(TextFormat::DARK_AQUA . self::tag . " The winner is " . $winner . "! Congratulations!");
$this->getServer()->broadcastMessage(TextFormat::DARK_AQUA . self::tag . " Today's winning amount: " . $winningAmount);
}
$this->save();
$this->box = [];
$this->tick = self::interval;
}
}
示例2: 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"])) {
$this->api->addMoney($player, $job[$block->getID() . ":" . $block->getDamage() . ":place"]);
}
}
}
示例3: onDataPacketRecieve
public function onDataPacketRecieve(CustomPacketReceiveEvent $event)
{
$packet = $event->getPacket();
$array = json_decode($packet->data);
if ($array[0] != "MoneyTransfer") {
return;
}
$player = $array[1];
$amount = $array[2];
$this->economy->addMoney($player, $amount);
$this->getLogger()->info("플레이어 {$player}가 {$amount}원을 다른서버에서 옮겨왔습니다.");
}
示例4: 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;
}
示例5: 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;
}
}
}