#How to run a command at the first ever login and not every log in

28 messages · Page 1 of 1 (latest)

sudden jewel
#

pretty much the title

    event.server.runCommand('execute as @p run openguiscreen credits')
})```

i want to run this script but only at the first ever login and i dont it to appear ever again
cloud glenBOT
#

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

cunning oxide
#
PlayerEvents.loggedIn(event =>{
    if (!event.player.stages.has('first_login')) {
        event.player.stages.add('first_login')
        event.server.runCommand('execute as @p run openguiscreen credits')
    }
})
#

also you shouldn't use @p

#

use 'execute as ${event.player.username} run openguiscreen credits'

sudden jewel
#

but for some reason ${event.player.username}

#

doesnt really work

#

thats why i went with the @p

heady pecan
#

@p can error and use a different player rarely it’s better to use ${player.username} or ${event.player.username}

#
Event.server.runCommandSilent(‘execute as ${player.username} run openguiscreen credits’ ``` I wrote this on my phone so sry if there are errors
#

Also you need to use backticks for $ stuff to work

#

The same things as

split coralBOT
#

You can write your code in a codeblock by typing it between the codeblock delimiters:
Note that these are backticks, not apostrophes

```js :arrow_left:

ServerEvents.recipes(event => {
event.smelting('minecraft:glass', '#forge:sand').xp(.1)
})

``` :arrow_left:

This example will look like this:

ServerEvents.recipes(event => {
  event.smelting('minecraft:glass', '#forge:sand').xp(.1)
})
sudden jewel
#

ah i see

#

that makes sense

sudden jewel
heady pecan
#

Backticks allow for functions and strings to be refranced in the script

heady pecan
#

Use event.player.username for this script

sudden jewel
#

alright will give it a shot in a sec let you know

heady pecan
#

K if it works

#

??closeticket

split coralBOT
# heady pecan ??closeticket

Please close your ticket (with </ticket close:1054771505520717835> or the button atop this thread) once you resolved your issue! This also helps others that would like to help out, as they don't have to look into this thread to check if it has been resolved by now.

Do you have any other questions regarding your issue? Feel free to ask!
Note: You should generally create a new post for unrelated issues.

heady pecan
#

My phone is about to die

sudden jewel
#

okay it works

#

will close the ticket now thank you both for the help

cloud glenBOT
#

Ticket closed!