Where are my undies?

Howdy folks,
Yes, a very cheap way to garner attention, I’m afraid :blush:

I need to provide my PCs with custom underclothing items created in their inventories via the module’s OnClientEnter script.

However, while these lines work perfectly (creating the required item in the entering PC’s inventory…

if(!GetIsObjectValid(GetItemPossessedBy(oPC,"pc_clothing")))
   CreateItemOnObject("pc_clothing01",oPC);

…what I really want is to provide a random selection from three item blueprints for both sexes, and my attempt at doing this for male PCs does not work…

// Routine to give entering male PCs underclothing.
int nClothing = d3();
int iGender = GetGender(oPC);
if (iGender = GENDER_MALE)
{
   switch(nClothing)
   {
   case 1: if(!GetIsObjectValid(GetItemPossessedBy(oPC,"pc_clothing")))
   CreateItemOnObject("pc_clothing01", oPC);
   break;
   case 2: if(!GetIsObjectValid(GetItemPossessedBy(oPC,"pc_clothing")))
   CreateItemOnObject("pc_clothing02", oPC);
   break;
   case 3: if(!GetIsObjectValid(GetItemPossessedBy(oPC,"pc_clothing")))
   CreateItemOnObject("pc_clothing03", oPC);
   break;
   }
}

If any kind soul can point out where I’m going wrong, I would appreciate the help very much.
I should add that the script compiles successfully, but none of the items are created in the inventories of the male test PCs.
BTW, I use NWN 1.69 not EE.
Many thanks.

This should say

if (iGender == GENDER_MALE)

B

As Baireswolf said. And there is always somebody who knows it all better :innocent:

// Routine to give entering male PCs underclothing.
if(GetIsObjectValid(GetItemPossessedBy(oPC,"pc_clothing"))) return; // do nothing

int nClothing = d3();
if (GetGender(oPC) == GENDER_MALE)
  CreateItemOnObject("pc_clothing0" + IntToString (nClothing), oPC);
else
  CreateItemOnObject("pc_clothingf0" + IntToString (nClothing), oPC); //insert the name of the female blueprint

Thank you, Baireswolf. You were not wrong! :smile:

How true! Thank you, Mmat. Your code worked perfectly once I’d changed the resrefs of the female blueprints to 11, 12 & 13 and put a 1 instead of a 0 in the female line.

Cheers both, I wonder if you set a record between you for the fastest solution ever!!!