#How do I run a command upon a client logging into a world?
20 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
is it something you need to run once, or every time someone logs in?
youd just replace whats inside the parenthases with your pekui command
if (!event.player.stages.has('new_join')) {
event.player.stages.add('new_join');
event.server.runCommandSilent('give @s diamond_block');
}
});```
if its only for the first time ^
PlayerEvents.loggedIn(e => {
if (e.player.stages.has('new_join')) return
e.player.stages.add('new_join')
e.server.runCommandSilent('command here')
})
with some color uwu
if you need it for every time a player logs in, remove the stage parts of the script
I am unsure if pehkui resets upon leaving the server so i will do a little more work but this is exactly what i needed than kyou :)

shes outdone me, this is like the difference between sams club and walmart D; nice tho
its basically the same D:
i just didnt put it yet because i wanted to help them figure it out rather than just giving them the solution~
would @s work?
i wasnt sure because it's the server not a player executing a command
it was more for examples sake tbh, you could do this execute as ${e.entity.username} run
executing as the player who triggered the event
if you dont need the player to be OP you can do
e.player.runCommandSilent('<command>')
if you need to run it as if the player is OP, then you need the execute as
e.server.runCommandSilent(`execute as ${e.player.username} run <command>`)