I personally don't know much about coding, but I'm assuming the issue could possibly be from another code error elsewhere in the code.
Again, I don't know much about code, just suggesting
So I am honestly brand new to the entire ROTMG PSERVER and im curious as to how i can give myself admin commands and set different ranks for individuals as i please.
I used visual studio to implement the following line for code into player.cs and i set my rank to 10 in heidisql
switch(psr.Account.Rank)
{
case 0:
Name = "[Player]" + psr.Account.Name;
break;
case 1:
default:
Name = "[Admin]" + psr.Account.Name;
break;
}
My issue is that after I go to use admin commands or /admin it tells me i have no permissions. Im looking for some in depth help with other information as well if anyone is kind enough to take the time! Thank you!!!
I personally don't know much about coding, but I'm assuming the issue could possibly be from another code error elsewhere in the code.
Again, I don't know much about code, just suggesting
Not quite.
Also, can you please send me your commands.cs @UrbanNaga
I'll respond with an updated code that should work. Also did you rebuild your solution?
Try to change your rank to 3,it should work
# [Tutorial] Setting up different ranks to by-pass a command.
## Language used:
- C#.
## Software used:
#### Microsoft Visual Studio Community:
- [x] **Windows**: download link [**here**](https://go.microsof*****m/fwlink/?Lin...78&clcid=0x409).
## Game Source used:
#### Realm of the Mad God 27.3.2 Server:
- [x] Download link [**here**].
***
# Adding `public` variables to compare on another file.
### 1) Navigate on your server solution and go to "_wServer > Program.cs_";
### 2) At "_Program.cs_" bellow scope of static class add these public variables for reference:
> ...
> namespace wServer
> {
> internal static class Program
> {
> public const int server_Owner = 7;
> public const int server_Co_Owner = 6;
> public const int server_Admin = 5;
> public const int server_Dev = 4;
> public const int server_Yt = 3;
> public const int server_Vip = 2;
> public const int server_Player = 1;
> public const int server_Null = 0;
> public static readonly List<int> server_Ranks = new List<int> {
> server_Null, server_Player, server_Vip,
> server_Yt, server_Dev, server_Admin,
> server_Co_Owner, server_Owner
> };
> ...
### 3) At `region` scope import this library, `System.Collections.Generic`:
> ...
> using System.Collections.Generic;
> namespace wServer
> {
> internal static class Program
> {
> public const int server_Owner = 7;
> public const int server_Co_Owner = 6;
> public const int server_Admin = 5;
> public const int server_Dev = 4;
> public const int server_Yt = 3;
> public const int server_Vip = 2;
> public const int server_Player = 1;
> public const int server_Null = 0;
> public static readonly List<int> server_Ranks = new List<int> {
> server_Null, server_Player, server_Vip,
> server_Yt, server_Dev, server_Admin,
> server_Co_Owner, server_Owner
> };
> ...
### 4) Navigate on your server solution and go to "_wServer > realm > commands> WorldCommand.cs_";
### 5) At "_WorldCommand.cs_" bellow scope of static class add these internal functions:
> ...
> namespace wServer.realm.commands
> {
> //Unique command to do different actions for each rank.
> internal class Firstcommand : Command
> {
> public Firstcommand() : base("firstcommand") { }
> protected override bool Process(Player player, RealmTime time, string[] args)
> {
> int PlayerRank = player.Client.Account.Rank;
> switch(PlayerRank)
> {
> case Program.server_Owner:
> player.SendInfo("I'm an owner.");
> return true;
> case Program.server_Co_Owner:
> player.SendInfo("I'm a co-owner.");
> return true;
> case Program.server_Admin:
> player.SendInfo("I'm an administrator.");
> return true;
> case Program.server_Dev:
> player.SendInfo("I'm a developer.");
> return true;
> case Program.server_Yt:
> player.SendInfo("I'm a youtuber.");
> return true;
> case Program.server_Vip:
> player.SendInfo("I'm a very important person.");
> return true;
> case Program.server_Player:
> player.SendInfo("I'm a player.");
> return true;
> case Program.server_Null:
> player.SendInfo("I don't rank rank.");
> return true;
> default:
> player.SendError("An error occured, contact administrator.");
> return true;
> }
> }
> }
> //Unique command to by-pass rank greater than specific rank
> //You could adapt it to by-pass greater-equal than, lesser-equal than or whatever
> internal class SecondCommand : Command
> {
> public SecondCommand() : base("secondcommand") { }
> protected override bool Process(Player player, RealmTime time, string[] args)
> {
> int PlayerRank = player.Client.Account.Rank;
> if (PlayerRank > Program.server_Player)
> {
> player.SendInfo("Rank lesser than 'player' cannot use this command.");
> return true;
> } else
> {
> player.SendHelp("You don't have enough rights to use this command.");
> return true;
> }
> }
> }
> //Unique command to by-pass rank into between specific array values
> internal class ThirdCommand : Command
> {
> public ThirdCommand() : base("thirdcommand") { }
> protected override bool Process(Player player, RealmTime time, string[] args)
> {
> int PlayerRank = player.Client.Account.Rank;
> if ((Program.server_Ranks.Contains(PlayerRank))
> && (PlayerRank > Program.server_Ranks[Program.server_Player - 1])
> && (PlayerRank <= Program.server_Ranks[Program.server_Admin -1]))
> {
> player.SendInfo(@"Rank lesser than 'player' and greater than 'admin'
> cannot use this command.");
> return true;
> } else
> {
> player.SendHelp("You don't have enough rights to use this command.");
> return true;
> }
> }
> }
> ...
***
# Understanding by-pass and usages.
### Many alternative RotMG projects aim to have their own ranking differentiation mechanism and thus limit commands that only specific members will have access to. However, it's necessary to program this mechanism manually. As mentioned earlier, this by-pass system limits some ranks in having access to some commands or even a single command performing several different functions depending on the user rank.
### The examples shown above are 3 options to perform a by-pass per user rank, however you can adapt them the way you want. Functions such as `foreach` and `switch` can be used to customize a better by-pass verification mechanism too.
**Credits:**
- _@Devwarlt_ for tutorial;
- _@Fabian_ for Server source.
- - - Updated - - -
You could replace that Linq usage to enum list, similar as PacketIDs.
Last edited by Ahlwong; 08-04-2017 at 10:00 PM. Reason: removed GitHub links
Do you need help or support in your RotMG Private Server? I could help you, leave a private message to me, contact bellow:
https://******.com/Devwarlt