Hi !
I try to find a plugin that can move a player in a specific group at the first connection so only once.
I want it because beginners will have to survive at least in a PVE mode until a certain level and then they will have access to PVP mode ( to help new Rust players to learn the game and prevent them to be killed by high lvl full stuff ) so I need to place them in a beginner group at the first connection to use others plugins, as you know I can't use default group to do it because all players are in this group ...
Do you know a plugin that can do it ?
Solved Move player in a group only at the first connection
Discussion in 'Plugin Requests' started by Pant0uflard, Jul 28, 2016.
-
You could do something like this:
Replace "yourgroupnamehere" with the group name you want to assign new players to.Code:namespace Oxide.Plugins { class GroupOnConnect : RustPlugin { string permissionName = "grouponconnect.hasjoinedbefore"; void Init() => permission.RegisterPermission(permissionName, this); void OnPlayerInit(BasePlayer player) { if (!(permission.UserHasPermission(player.UserIDString, permissionName))) { permission.GrantUserPermission(player.UserIDString, permissionName, this); permission.AddUserGroup(player.UserIDString, "yourgroupnamehere"); } } } }
EDIT: Please note that this hasn't been tested but will probably work.
Last edited by a moderator: Jul 28, 2016 -
Wulf Community Admin
You wouldn't even need a permission, just check if they are already in the desired group or not. -
I was thinking of doing that but maybe the higher-levelled players wouldn't be in that group anymore, you wouldn't want them getting bumped back down when they join.
-
Absolutely, higher-levelled player don't need to be in that group anymore once the player is in PVP mode so grant a permission on the player himself is necessary.
I had to change OnPlayerConnected by OnPlayerInit but anyway it work like a charm !
Thank you ! -
You're welcome.
-
Wulf Community Admin
OnPlayerConnected would work, or even OnUserApprove, but they don't accept BasePlayer as the argument, so you'd have to get the ID from what they use. -
Ha, woops.
-
So, OnPlayerInit is a good way to get it work with BasePlayer, no ? Or should I change it and get OnPlayerConnected working by getting the ID from what they use ? I mean, what's the best way ?
-
OnPlayerInit will do just fine. There's no need to assign the group before they've even loaded in, it won't make a difference.
-
Okay, nice !
-
Wulf Community Admin
The only time you'd need anything earlier is if you want to handle something before they spawn/are initialized. -
Didn't know that, thanks for the informations.
