dotskills (02-06-2017)
lol at this conversation reading it baked af
dotskills (02-06-2017)
What Flutter posted is perfect for what you want. If you want Owner to be able to use it too, add a or ||.
this is what flutter meant
Code:internal class SetGoldCommand : Command { public SetGoldCommand() : base("setgold", 5) { } protected override bool Process(Player player, RealmTime time, string[] args) { if (string.IsNullOrEmpty(args[0])) { player.SendHelp("Usage: /setgold <gold>"); return false; } if (player.Client.Account.Rank != 5) || (player.Client.Account.Rank != 9) { player.SendError("This command is restricted to God rank only."); return false; } player.Manager.Database.DoActionAsync(db => { var cmd = db.CreateQuery(); cmd.CommandText = "UPDATE `stats` SET `credits`=@cre WHERE accId=@accId"; cmd.Parameters.AddWithValue("@cre", args[0]); cmd.Parameters.AddWithValue("@accId", player.AccountId); if (cmd.ExecuteNonQuery() == 0) { player.SendError("Error setting gold!"); } else { player.SendInfo("Success!"); } }); return true; } }
Problem still isnt fixed -_- I need rank 5 and rank 9 to be able to use it, no one else!
I get an error at the II thing and the } else {
if(x) || (y) doesn't work, if((x) || (y)) works, (autistic syntax, maybe some clarity i guess)
if(x || y) works.
please stop pasting the same solution (without clarifying it any further) if he said it didn't work.
fixed code, for the final time:
Code:internal class SetGoldCommand : Command { public SetGoldCommand() : base("setgold", 5) { } protected override bool Process(Player player, RealmTime time, string[] args) { if (string.IsNullOrEmpty(args[0])) { player.SendHelp("Usage: /setgold <gold>"); return false; } if (player.Client.Account.Rank != 5 || player.Client.Account.Rank != 9) { player.SendError("This command is restricted to God rank only."); return false; } else { player.Manager.Database.DoActionAsync(db => { var cmd = db.CreateQuery(); cmd.CommandText = "UPDATE `stats` SET `credits`=@cre WHERE accId=@accId"; cmd.Parameters.AddWithValue("@cre", args[0]); cmd.Parameters.AddWithValue("@accId", player.AccountId); if (cmd.ExecuteNonQuery() == 0) { player.SendError("Error setting gold!"); } else { player.SendInfo("Success!"); } }); return true; } } }
Jackaiken32 (02-06-2017)
Solved but can you do the same thing with a setFame command please
- - - Updated - - -
Solved but can you do the same thing with a setFame command please
Code:internal class SetFameCommand : Command { public SetFameCommand() : base("fame", Ranks.Owner) { } protected override bool Process(Player player, RealmTime time, string[] args) { if (string.IsNullOrEmpty(args[0])) { player.SendHelp("Usage: /fame <fame ammount>"); return false; } player.Manager.Database.DoActionAsync(db => { var cmd = db.CreateQuery(); cmd.CommandText = "UPDATE `stats` SET `fame`=@cre WHERE accId=@accId"; cmd.Parameters.AddWithValue("@cre", args[0]); cmd.Parameters.AddWithValue("@accId", player.AccountId); if (cmd.ExecuteNonQuery() == 0) { player.SendError("Error setting fame!"); } else { player.SendInfo("Success!"); } }); return true; } }
Code:internal class SetFameCommand : Command { public SetFameCommand() : base("setfame", 5) { } protected override bool Process(Player player, RealmTime time, string[] args) { if (string.IsNullOrEmpty(args[0])) { player.SendHelp("Usage: /setfame <fame>"); return false; } if (player.Client.Account.Rank != 5 || player.Client.Account.Rank != 9) { player.SendError("This command is restricted to God rank only."); return false; } else { player.Manager.Database.DoActionAsync(db => { var cmd = db.CreateQuery(); cmd.CommandText = "UPDATE `stats` SET `fame`=@fame WHERE accId=@accId"; cmd.Parameters.AddWithValue("@fame", args[0]); cmd.Parameters.AddWithValue("@accId", player.AccountId); if (cmd.ExecuteNonQuery() == 0) { player.SendError("Error setting fame!"); } else { player.SendInfo("Success!"); } }); return true; } } }
Jackaiken32 (02-06-2017)
Thanks, how did you learn to do all of this. Im new to the coding on rotmg but i absolutly LOVE coding.
this is just knowing what an if statement does and an or operator does, and knowing how to call the player's rank. however nilly elaborated on it quite well in a previous post, you either learn things as you move along (essentially wanting to code something, then google) or you just go down the route where you just flat out buy a book and learn it the normal way.