#How do I run a command upon a client logging into a world?

20 messages · Page 1 of 1 (latest)

surreal solstice
#

I am trying to run a Pehkui command upon a client login so that the player logging in gets scaled to 0.5 size. I have been looking around the wiki and i guess I am just a little lost and i could use some direction :)

undone wigeonBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

true sand
#

is it something you need to run once, or every time someone logs in?

stray marsh
#

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');     
  }
});```
true sand
#

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

surreal solstice
#

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 :)

true sand
stray marsh
#

shes outdone me, this is like the difference between sams club and walmart D; nice tho

true sand
#

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~

surreal solstice
#

would @s work?

#

i wasnt sure because it's the server not a player executing a command

stray marsh
#

executing as the player who triggered the event

true sand
#

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>`)
surreal solstice
#

okay that's great thank you

#

this works :)