Switel12 Posted August 31, 2019 Share Posted August 31, 2019 Hey everyone, I have a question how to make a list of online players on the server? Link to comment Share on other sites More sharing options...
Atesh Posted August 31, 2019 Share Posted August 31, 2019 (edited) I can give you an example of how to do this. If you have a MYSQL Connection, as soon as a player connects you can make his status in the mysql database 1 or true. Then you can make a page for example with PHP and MYSQL which is selecting all the players with that status equal to 1 or true(depends of the state you set when he connects). That will print that player list. As soon as you have this you can make more and more stuff with it. Edit: Also, when he disconnects set his status to 0 or false. This online variable in the database needs to be rebooted to 0 or false everytime the server restarts in order to set all the players offline, since if the server crashes for example it doesnt recive any player disconnects anymore! Edited August 31, 2019 by Atesh Link to comment Share on other sites More sharing options...
MrPancakers Posted August 31, 2019 Share Posted August 31, 2019 To create a list in-game, all you have to do is just loop through the players pool and this gets every player on the server. mp.players.forEach(function(user){ console.log(`Player: ${user.name}`); }); Instead of a console.log, you'd do whatever you wanna do to display the users. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now