02.06.2015, 18:36
Yay
A nice script coming soon
A nice script coming soon
@Command public boolean house(Player player) { ListDialog.create(player, eventManager) .caption("Your house") .buttonCancel("Back") .buttonOk("Next") .item("Change house title", item -> { InputDialog.create(player, eventManager) .caption(item.getCurrentDialog().getCaption() + " - Change title") .message("Please enter the new house title:") .buttonCancel("Back") .buttonOk("Ok") .parentDialog(item.getCurrentDialog()) //set the parent dialog to the "Your House"-Dialog .onClickCancel(AbstractDialog::showParentDialog) //show parent dialog when he presses cancel .onClickOk((dialog, text) -> { if(text.length() > 0) { //Update house and database etc. dialog.showParentDialog(); //show the parent dialog when the text changed successfully } else { player.sendMessage(Color.RED, "* The name is not valid!"); dialog.show(); } }) .build() .show(); }) .item("Change rent price", item -> { //Implement }) .item("Sell house", item -> { player.sendMessage(Color.RED, "* You can't sell your house because there are still people in it."); item.getCurrentDialog().show(); //Reshow Dialog }) .onClickCancel(dialog -> { player.sendMessage(Color.GREEN, "* You canceled the house editing."); }) .build() .show(); return true; }
Collection<ListDialogItem> items = new ArrayList<ListDialogItem>(); // add some stuff to "items" dynamically(i do not know their values at compile time) ListDialog.create(player, eventManager) .caption("stuff") .item("Single action", item -> { // do things }) .items(items) .onClickOk((dialog, item) -> { // do something with items from "items" collection }) .build() .show();
Collection<Person> data = new ArrayList<>(); //data from dynamic source ListDialog listDialog = ListDialog.create(player, eventManager) .caption("My dialog with dynamic data") .buttonCancel("Cancel") .buttonOk("Ok") .build(); for(Person person : data) { listDialog.addItem(person.getName(), item -> { //Do things with the person object }); } // check if the listdialog contains data if(listDialog.getItems().size() > 0) listDialog.show(); else player.sendMessage(Color.RED, "* There is no data available!");
PageListDialog pageListDialog = PageListDialog.create(player, eventManager) .caption("Pagination") .prevPage("<< Previous Page <<") .nextPage(">> Next Page >>") .itemsPerPage(10) .build(); for(int i = 0; i < 50; i++) { pageListDialog.addItem("Item " + i); } pageListDialog.show();
native CallShoebillFunction(name[], {Float,_}:...);
eventManager.registerHandler(AmxLoadEvent.class, e -> {
e.getAmxInstance().registerFunction("GetPlayerFactionName", objects -> {
Player player = Player.get((Integer) objects[0]);
//Do something to get player's faction etc.
objects[1] = "Los Santos PoPo";
//Return value for pawn (not always needed)
return 1;
}, Integer.class, String.class);
});
eventManager.registerHandler(AmxUnloadEvent.class, e -> {
e.getAmxInstance().unregisterFunction("GetPlayerFactionName");
});
public OnPlayerConnect(playerid)
{
new factionName[] = "Unknown";
CallShoebillFunction("GetPlayerFactionName", playerid, factionName);
printf("Factionname: %s", factionName);
return 1;
}
Player.get()
Player.getHumans() // no bots
@BRICS:
You can take a look at my post #209 for player variables (http://forum.sa-mp.com/showpost.php?...&postcount=209). I don't know what you mean by global variables, you can just use Java like in any other project, and you can also declare variables like normal. You can get all players via Код:
Player.get() Код:
Player.getHumans() // no bots |
Iterator<Player> it = Player.getHumans().iterator(); Player p; while(it.hasNext()) { // get "Player" instance p = it.next(); }
for(Player player : Player.getHumans()) { ... }
@BRICS:
You can take a look at my post #209 for player variables (http://forum.sa-mp.com/showpost.php?...&postcount=209). I don't know what you mean by global variables, you can just use Java like in any other project, and you can also declare variables like normal. You can get all players via Код:
Player.get() Код:
Player.getHumans() // no bots |
Код:
Iterator<Player> it = Player.getHumans().iterator(); Player p; while(it.hasNext()) { // get "Player" instance p = it.next(); } http://docs.oracle.com/javase/7/docs.../Iterator.html |