User avatar
LeeIzaZombie
Military Zombie
Military Zombie
Donator ($13.24)
Posts: 165
Joined: Tue Apr 07, 2015 9:16 am
Location: Ireland
x 9
Website
Skype

[Tutorial] Get list of online players. v4.6.3.1

Sun Aug 09, 2015 8:54 pm

Hello,

To get a list of online players, we'll be using Provider which will contain the information of our players.
Here's a code snippet of getting our list of players:

Code: Select all

         string list = ""; int i = 0;
               foreach (SteamPlayer plr in Provider.Players)
               {
                   //So let's convert each SteamPlayer into an UnturnedPlayer
                     UnturnedPlayer unturnedPlayer = UnturnedPlayer.FromSteamPlayer(plr);
                     
                   //Now let's heal everyone!
                   unturnedPlayer.Heal(100, false, false);
                   
                   //Now let's keep a list of each player so we can say who's online!
                   i++;
                   if (i != Provider.Players.Count)
                          list += unturnedPlayer.CharacterName + ", ";
                      else
                          list += unturnedPlayer.CharacterName + ".";
               }
           
               //using Rocket.Unturned.Chat;
               UnturnedChat.Say("Players online: " + list, Color.yellow);
           
               //And why not show a status of players online from the max amount allowed online! :D
               UnturnedChat.Say(Provider.Players.Count + "/" + Provider.maxPlayers, Color.green);


Read the comments to hopefully get a better understanding of what's going on.
I hope this helped out, and if there's any tutorials needed, feel free to ask!

Kind regards - LeeIzaZombie.
Last edited by LeeIzaZombie on Sun Oct 11, 2015 7:49 pm, edited 1 time in total.
0 x
Image

If you think I was helpful then give me a positive rating! :D (Click the heart)

InvisibleGuy3
Civil Servant Zombie
Civil Servant Zombie
Posts: 26
Joined: Thu Aug 13, 2015 6:57 pm
x 1

Re: [Tutorial] Get list of online players. v4.6.0.0

Wed Sep 30, 2015 7:10 pm

How Do I Put It As A Plugin To My Server?
0 x
Owner Of A Serious Roleplay Server! ;)

Come and Join The WAR :!: :arrow:

https://unturned-servers.net/server/111664/

LinhyCZ
Civil Servant Zombie
Civil Servant Zombie
Posts: 16
Joined: Sun Sep 27, 2015 9:43 pm

Re: [Tutorial] Get list of online players. v4.6.0.0

Sun Oct 11, 2015 6:06 am

Hi, with the latest upgrade I get error message Couldn't load type 'SDG.Unturned.Steam from assembly 'Test'

Any idea how to fix it?
0 x

User avatar
fr34kyn01535
Core Developer
Core Developer
Posts: 410
Joined: Thu Mar 05, 2015 3:22 pm
Location: Germany
x 136
Website
Twitter

Re: [Tutorial] Get list of online players. v4.6.0.0

Sun Oct 11, 2015 10:12 am

The class Steam was renamed to Provider
1 x
RocketMod Core Developer, Community Manager

What we do in life echoes in eternity - Maximus, Gladiator

Other projects: UDonations - PayPal donation plugin | Rocket Observatory
Me on: Keybase | Twitter

User avatar
LeeIzaZombie
Military Zombie
Military Zombie
Donator ($13.24)
Posts: 165
Joined: Tue Apr 07, 2015 9:16 am
Location: Ireland
x 9
Website
Skype

Re: [Tutorial] Get list of online players. v4.6.3.1

Sun Oct 11, 2015 7:50 pm

Sorry about that! I updated the post now.
0 x
Image

If you think I was helpful then give me a positive rating! :D (Click the heart)

User avatar
fr34kyn01535
Core Developer
Core Developer
Posts: 410
Joined: Thu Mar 05, 2015 3:22 pm
Location: Germany
x 136
Website
Twitter

Re: RE: Re: [Tutorial] Get list of online players. v4.6.3.1

Sun Oct 11, 2015 8:03 pm

LeeIzaZombie wrote:Sorry about that! I updated the post now.

Haha, its not your fault :D
2 x
RocketMod Core Developer, Community Manager

What we do in life echoes in eternity - Maximus, Gladiator

Other projects: UDonations - PayPal donation plugin | Rocket Observatory
Me on: Keybase | Twitter

Return to “Development Tutorials & Guides”

Who is online

Users browsing this forum: No registered users and 1 guest

Advertisement