#teleport ugi
1 messages Β· Page 1 of 1 (latest)
waht
dont ping me
function createButton(player) {
const formData = new ModalFormData();
formData.title('Create Button');
formData.textField('Button Name', 'value');
formData.show(player).then(data => {
const buttonName = data.formValues[0];
// Save button location as dynamic property
let { x, y, z } = player.location;
x = Math.round(x).toFixed(0);
y = Math.round(y).toFixed(0);
z = Math.round(z).toFixed(0);
const buttonData = { x, y, z };
player.setDynamicProperty(`button_${buttonName}`, JSON.stringify(buttonData));
player.sendMessage(`Button "${buttonName}" created at ${x}, ${y}, ${z}`);
});
}
function teleportToButton(player) {
// Get all button names
const buttonNames = player.getDynamicPropertyIds()
.filter(propertyName => propertyName.startsWith('button_'))
.map(buttonProperty => buttonProperty.replace('button_', ''));
// Show buttons in the form
const formData = new ActionFormData()
formData.title('Teleport to Button');
buttonNames.forEach(buttonName => {
formData.button(buttonName);
});
formData.show(player).then(data => {
const selectedIndex = data.selection;
const selectedButton = buttonNames[selectedIndex]
if (selectedButton) {
const buttonDataString = player.getDynamicProperty(`button_${selectedButton}`);
if (buttonDataString) {
const buttonData = JSON.parse(buttonDataString);
const { x, y, z } = buttonData;
player.runCommandAsync(`tp ${x} ${y} ${z}`);
player.sendMessage(`Teleported to Button "${selectedButton}" at ${x}, ${y}, ${z}`);
} else {
player.sendMessage('Invalid selection');
}
} else {
player.sendMessage('Invalid selection');
}
});
}
@thorn veldt
here
should I add a function to remove locations?
function deleteButton(player) {
const buttonNames = player.getDynamicPropertyIds()
.filter(propertyName => propertyName.startsWith('button_'))
.map(buttonProperty => buttonProperty.replace('button_', ''));
const formData = new ActionFormData().title('Delete Button');
buttonNames.forEach(buttonName => {
formData.button(buttonName);
});
formData.show(player).then(data => {
const selectedIndex = data.selection;
const selectedButton = buttonNames[selectedIndex];
if (selectedButton) {
player.setDynamicProperty(`button_${selectedButton}`, null);
player.sendMessage(`Button "${selectedButton}" deleted.`);
} else {
player.sendMessage('Invalid selection');
}
});
}
```here
@thorn veldt
okay
function TPS(player) {
const form = new ActionFormData()
.title('MG_MENU')
.button('CREATE A BUTTON ')
.button('TELEPORT')
.button('delete');
form.show(player).then(r => {
const { selection, canceled } = r;
if (canceled) return;
switch (selection) {
case 0:
createButton(player);
break;
case 1:
teleportToButton(player);
break;
case 2:
deleteButton(player)
break;
}
});
}
for the first ui
πok
@gritty heart
yes
Yes, I fixed the problem of the buttons disappearing, but the delete button does not work
Its working for me
How did you write it? Maybe I wrote it wrong
I told you I wrote it wrong
This is my fault, I apologize
ππ
are you here
Listen, I previously made a mod that contained a list of increasing power through the Infinite Effects system
But the effect disappears quickly, even if you set the time to 100,000
You are really very expert in programming
teleport ugi