Onplayerchat commands questionSolved

How to add more commands to this: if (message.Contains("!players, !online") -->When I add online it hits error

 

void OnPlayerChat(ConsoleSystem.Arg arg)
{
var message = arg.GetString(0);
if (message.Contains("!players"))
{
var playerCount = players.Connected.Count(p => !p.IsAdmin && !p.HasPermission(permHide));
if (playerCount > 1)
server.Broadcast($"There are currently {playerCount} players online.");
else
server.Broadcast("There is currently 1 player online.");
}
}

I'd suggest using the command registration, not OnPlayerChat. There are examples of command registration in plugins and the docs I believe.

The code you appear to have copied from the Player List plugin will not work the way you are doing it though, different types of plugins.

In general though, we do not support or encourage trying to make a modded server appear as vanilla, especially since that is grounds for blacklisting in Rust if you do more than admin tools.
Thanks and docs are where?
Okey, thanks.

Merged post

And how to change it to !players not /players ? 
In response to 5798 ():
Okey, thanks.

Merged post

And how to change it to !players not /players ? 
! is not natively supported for chat commands, so you'd have to do like you were above, but not with that code. I can't support that though, as it sounds like you are trying to make a modded server under community and do more than just admin tools.

Wait so with this my server would get blacklisted?

I saw many other server using !players in vanilla tab

In response to 5798 ():
Wait so with this my server would get blacklisted?I saw many other server using !players in vanilla...
Some are using RCON tools, but the others would be abusing that list as Facepunch only allows "admin tools", a player list command for players is not an admin tool.

Oh okey...

And what admin tool can I use or does RustAdmin works with that.


Merged post

Wulf? please? Do you know on rustadmin what is the playercount triggered command?

say There is currently online ${playerCount}. Doesnt work.

Why not just use the existing plugin instead of trying to fake it? I don't know how the Trigger Commands work in RustAdmin, just that I know people use it.
Yes, they work, but i can not find allplayers connected on the server.

Moderator edit: The forums are not for plugin releases.

Maybe this helps you. Using it over 4 moths now ;) 

Locked automatically