#How to run a command at the first ever login and not every log in
28 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
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'
i tried both ways
but for some reason ${event.player.username}
doesnt really work
thats why i went with the @p
@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
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)
})
do these both do the same thing?
Backticks allow for functions and strings to be refranced in the script
In function no in practice mostly
Use event.player.username for this script
alright will give it a shot in a sec let you know
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.
My phone is about to die
Ticket closed!