How can I get number of players online?

Hello guys!

How can I get the number of players online on my server into my mod?

Thx

Thx! So this one takes only the “currently online players”? Not “all the players which have a character on the server”? :slight_smile:

You’d have to query your database for that.

Tested and approuved. It works for the number online players.

Thx!

And how can you display it eg in a widget?

Nobody knows how to display it in a widget

Create a variable in your widget, then in whatever calls the widget:

Run the player count function
Create widget
Use return value to set value inside of widget
Add to viewport

Make sure in the widget your text box is promoted to a variable and there is a Get Text function for it.

Thanks for the reply, but could you please explain it somewhat, I am still a beginner.
I already have a widget that you can open with F1.

Only now I do not know exactly what you mean.

For the widget, click your textbox then on the right go down to Contents > Text and create a binding for it. It’ll pull up the graph. Just get the variable and return the node.

Thanks for the help, I can not go any further.

e38a4408c66e8c1ca276e040577f8a0a08429e2f.jpeg

This is my bind in the widget

60cf530e8a6c20284f5816a74fc7f780a3a9bedd.jpeg

3806100497c00ad62031cded36a55427c5de79ed.jpeg

Top left of picture #1, press “+Variable” and then in the details window at the bottom there, switch it to an integer or string.

How do I get the “set”?

The return value from Create Widget, the blue dot. Drag it out and it gives you access to all variables in the widget. Just type “Set output”

When I enter set output appears with me nothing

d5b00ee8ecb3940566225b9176d7bda6a0764475.jpeg

You have to create the variable Output inside the widget. I meant to say picture 3 of that post, the one of the Get Text function

Thanks, just now the widget does not open anymore

Did you remember to add to viewport?

Yes

You did forget to connect the arrows, though. The graph stops at create widget. You have to reattach it to set output