Thread: Priced Command

Results 1 to 4 of 4
  1. #1
    cxydsaewq's Avatar
    Join Date
    Jan 2014
    Gender
    male
    Posts
    954
    Reputation
    25
    Thanks
    1,341
    My Mood
    Amazed

    Priced Command

    So I wanted to make my /max command cost 50 Gold but it didn't really work
    Any ideas why?

     
    Code:
    class Max : Command
        {
            public RealmManager Manager { get; private set; }
    
            public Max()
                : base("m", 2)
            {
            }
    
            protected override bool Process(Player player, RealmTime time, string args)
            {
                Account acc = player.Client.Account;
                
                    try
                    {
                      if (acc.Credits >= 50)
                        {
                        player.Stats[0] = player.ObjectDesc.MaxHitPoints;
                        player.Stats[1] = player.ObjectDesc.MaxMagicPoints;
                        player.Stats[2] = player.ObjectDesc.MaxAttack;
                        player.Stats[3] = player.ObjectDesc.MaxDefense;
                        player.Stats[4] = player.ObjectDesc.MaxSpeed;
                        player.Stats[5] = player.ObjectDesc.MaxHpRegen;
                        player.Stats[6] = player.ObjectDesc.MaxMpRegen;
                        player.Stats[7] = player.ObjectDesc.MaxDexterity;
                        player.Client.Save();
                        player.UpdateCount++;
                        Manager.GameDB.AddPendingAction(db =>
                        {
                            player.Credits = acc.Credits = db.UpdateCredit(acc, -50);
                            player.UpdateCount++;
                        });
                        player.SendInfo("Success");
                        }
                    }
                catch
                {
                    player.SendError("Unable to max!");
                    return false;
                }
                return true;
            }
        }

  2. #2
    Masternx's Avatar
    Join Date
    May 2016
    Gender
    male
    Posts
    48
    Reputation
    10
    Thanks
    16
    Here sir! First of all, add this to your Player.cs!
    Code:
      public void SaveToAcc()
            {
                var acc = Client.Account;
                acc.Credits = Credits;
              
            }
    The reason for this is that I could use the command even with negative gold, this ensures everything is good I guess, and since I'm dumb, I couldn't really figure out any other way to save the credits properly, so go ahead and add that.

    Now for the actual max command, I have used FSoD source so I cannot promise you it will not have any errors, if so, and you cannot fix them go ahead and post a picture and I will remake the command for what ever source you are using.
    Here is the command itself;
    Code:
     internal class Max : Command
        {
            public Max()
                : base("m", 1)
            {
            }
    
            protected override bool Process(Player player, RealmTime time, string[] args)
            {
                
                try
                {
                    var db = new Database();
                    Account acc = player.Client.Account;
    
                    if (acc.Credits < 50)
                    {
                        player.SendError("Unable to max!");
                        return false;
                    }
                    else if (acc.Credits >= 50)
                    {
                        player.Credits = db.UpdateCredit(acc, -50);
                        player.SaveToAcc();
                        player.Stats[0] = player.ObjectDesc.MaxHitPoints;
                        player.Stats[1] = player.ObjectDesc.MaxMagicPoints;
                        player.Stats[2] = player.ObjectDesc.MaxAttack;
                        player.Stats[3] = player.ObjectDesc.MaxDefense;
                        player.Stats[4] = player.ObjectDesc.MaxSpeed;
                        player.Stats[5] = player.ObjectDesc.MaxHpRegen;
                        player.Stats[6] = player.ObjectDesc.MaxMpRegen;
                        player.Stats[7] = player.ObjectDesc.MaxDexterity;
                        player.SaveToCharacter();
                        player.Client.Save();
                        player.SendInfo("Success");
                        player.UpdateCount++;
    
                    }
    
                }
                catch { }
                return true;
            }
        }

  3. The Following User Says Thank You to Masternx For This Useful Post:

    cxydsaewq (05-05-2016)

  4. #3

  5. #4
    Danny's Avatar
    Join Date
    Jun 2015
    Gender
    male
    Posts
    9,617
    Reputation
    2835
    Thanks
    3,002
    My Mood
    Aggressive
    /solved closed

    I am not a middleman nor do I buy/sell anything. If you are being contacted by someone off-site from MPGH then it's not me! Please report these to me via PM. Don't be stupid, think first.

Similar Threads

  1. supreme commander and command&conquer hacking
    By TheDisruptor in forum General Game Hacking
    Replies: 3
    Last Post: 11-26-2006, 10:50 PM
  2. Command & Conquer Generals
    By heero_yuy in forum General Game Hacking
    Replies: 2
    Last Post: 06-21-2006, 03:12 AM
  3. Warrock Command List
    By Dave84311 in forum WarRock - International Hacks
    Replies: 5
    Last Post: 05-26-2006, 11:03 PM
  4. Demon of some commands
    By HolyFate in forum Gunz Hacks
    Replies: 12
    Last Post: 02-21-2006, 01:43 PM