Comments (1)
Here is a little help(its from my bedwars team selection)
$arena = $player->getArena();
if (!$arena instanceof Arena) {
$player->sendMessage("message.notInGame");
return;
}
$buttons = $arr = [];
foreach ($arena->getTeams() as $team) {
$name = $team->getColor() . $team->getName() . " | " . count($team->getPlayers()) . "/" . $team->getMaxPlayers();
$buttons[] = new Button($name);
$arr[$name] = $team;
}
$player->sendForm(new MenuForm( //FORM BEGINS
"Teams",
"",
$buttons,
function (Player $player, Button $button) use ($arr): void{ //FORM RESPONSE BEGINS
if (!$player instanceof BWPlayer) {
return;
}
/** @var Team $selectedTeam */
$selectedTeam = $arr[$button->getText()];
$oldTeam = $player->getTeam();
if ($oldTeam->getName() == $selectedTeam->getName()) {
$player->sendMessage("message.alreadyInTeam");
return;
}
if (count($selectedTeam->getPlayers()) >= $selectedTeam->getMaxPlayers()) {
$player->sendMessage("message.teamIsFull");
return;
}
$oldTeam->removePlayer($player);
$selectedTeam->addPlayer($player);
$player->sendMessage("message.onTeamChoose", [$selectedTeam->getColor() . $player->translate($selectedTeam->getName())]);
} //FORM RESPONSE ENDS
)); //FORM ENDS
i hope this can help you.
from easyforms.
Related Issues (20)
- Translating & to color symbol
- Playars name in drop down HOT 3
- Special Symbols missing HOT 2
- Optimize plugin if you want to be better!
- Error. HOT 1
- ServerSettingsForm HOT 1
- error HOT 2
- Custom settings API HOT 3
- Add an API for adding elements after form creation HOT 2
- Add on readme.md a Tutorial HOT 1
- Изображения с сервера HOT 2
- What class to call? HOT 3
- How to download? HOT 3
- Downloadlink API 4.0.0 PLEASE HOT 2
- How to use? HOT 1
- NOT A GUI! HOT 3
- How to make multiple buttons in MenuForm? HOT 2
- Crash when click Settings HOT 1
- Get results easyly HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from easyforms.