Hello,
So im trying to write a simple plugin that will change the players name color on chat to orange IF they belong to the "vip" groups. (groups being managed by oxide).
Before looking at the code remeber that the group "vip" already exists.
So im just missing the function that actually gets the groups that the player belongs to.Code:class vipColor : RustPlugin { //intercepts the chat message object OnPlayerChat(ConsoleSystem.Arg arg) { BasePlayer player = (BasePlayer)arg.Connection.player; string Message = arg.GetString(0); if (string.IsNullOrEmpty(Message)) return false; // place here the function to get the groups of player // Groups = getGroups(player) if (Groups.Contains("vip")) rust.BroadcastChat($"<color=#ffa500>{player.displayName}</color>", Message, player.UserIDString); Puts($"{player.displayName}: {Message}"); return true; } }
Im sorry idont know any C# and i dont have any experience working with oxide plugins, so maybe this is very simple and basic but i cant find any doc about working with groups and i cant find a plugin that solves this.
Regards.
Solved Checking if player is in a group?
Discussion in 'Rust Development' started by mikzael, Mar 24, 2018.
-
Hey,
You can go through existing groups
Code:foreach (var group in permission.GetGroups()) { }
Code:foreach (var user in permission.GetUsersInGroup("vip")) { }
Code:foreach (var group in permission.GetGroups()) { foreach (var user in permission.GetUsersInGroup("vip")) { } }
if (permission.GetUsersInGroup("vip").Contains(player));
but I haven't checked. -
Use better chat plugin
-
Hello,
Oxide provides his own Player's class for easily do what you want to.
Code:if (player.IPlayer.BelongsToGroup("vip")) rust.BroadcastChat($"<color=#ffa500>{player.displayName}</color>", Message, player.UserIDString);
-