adding item on char creation depending on race

CrafterEric

Citizen
I'm trying to setup Milva's beginner gargoyle quest and add the Letter of Gargoyle Apprenticeship to only gargoyle's backpack on character creation. I was hoping to be able to add the letter based on race, without messing with elves or allowing anyone to go on both quests. Here's the relevant part of what I have in CharacterCreation.cs:

Code:
private static void AddBackpack(Mobile m)
  {
  Container pack = m.Backpack;

  if (pack == null)
  {
  pack = new Backpack();
  pack.Movable = false;

  m.AddItem(pack);
  }

  PackItem(new Gold(25000)); // Starting gold can be customized here
  PackItem(new daat99.MasterStorage());
  PackItem(new StatBall());
  PackItem(new SkillBallPlus());
  PackItem(new Trash4TokensBackpack());
  //PackItem(new BankCrystal());
  //PackItem(new TravelAtlas());
  //PackItem(new GoldLedger());
  //PackItem(new LootBag());

  if (m.Race != Race.Gargoyle)
  PackItem(new Dagger());
  PackItem(new LetterofApprenticeship());
  else if (m.Race == Race.Gargoyle)
  PackItem(new GargishDagger());
  PackItem(new (LetterofGargoyleApprenticeship));
  }

The stuff I changed is at the bottom. I just changed a line or two from stock to the above, and I get the following errors:

Code:
Errors:
+ Misc/CharacterCreation.cs:
  CS1525: Line 60: Invalid expression term 'else'
  CS1002: Line 60: ; expected
  CS1031: Line 62: Type expected
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.

Lines 60-62 are actually lines 23-25 in the code at the beginning of this post, the 3 lines starting with else if (m.Race == Race.Gargoyle) listed above. I've included the entire CharacterCreation.cs file if it helps. I also tried simply else, but that would also give the gargoyle letter to elves. I'm sure this is simple formatting, but I'm still new. :) Please tell me what I did wrong so I can learn from it (I'll have this answer bookmarked).
 

Attachments

  • CharacterCreation.cs
    50.6 KB · Views: 0
Last edited:

CrafterEric

Citizen
Yay! I figured it out. It was simple formatting, plus a typo. For anyone looking in the future, what I should have had was this:
Code:
if (m.Race != Race.Gargoyle)
       {
         PackItem(new Dagger());
         PackItem(new LetterofApprenticeship());
       }
  else if (m.Race == Race.Gargoyle);
       {
	 PackItem(new GargishDagger());
         PackItem(new LetterofGargoyleApprenticeship());
       }

and now it compiles and runs fine, and the letter for gargoyles goes to them only. I learned by myself! :D
 

Milva

Paladin
Nice! :) Notepad++ or Visual Studio are great to load a script in- they will show the line where your error is-helps so much
 

CrafterEric

Citizen
I did not know that. I haven't been loading Visual Studio because it's such a beast, but maybe I should start. Thanks Milva.
 

PyrO

Moderator
you can also use visual studio code, or sublime text. both of these can handle c# if you install the c# module
 

CrafterEric

Citizen
I did, I just never open it due to 2 Ghz/4GB. I guess I just need to be willing to keep a copy open or something. Cool, thanks for all your help too, PyrO. Not just now, but over the years to everyone, I can still find your answers from years ago, and they're still useful. Thank you sir.

Also if you couldn't tell, I'm HAF right now on some Mr. Nice Guy, strong sativa stimulating creativity. :D