This is a multi-part message in MIME format.
--
[ Picked text/plain from multipart/alternative ]
// externals.h used in both mp.dll and client.dll
// resides in mp.dsw folder and added from thisd irectory to client.dll

struct SpecieWeaponInformation
{
public:
 char *PrimaryWeaponName[MAX_PRIMARY_WEAPONS];
 char *SecondaryWeaponName[MAX_SECONDARY_WEAPONS];
 char *CloseCombatWeaponName[MAX_CLOSECOMBAT_WEAPONS];

 int PrimaryWeaponCost[MAX_PRIMARY_WEAPONS];
 int SecondaryWeaponCost[MAX_SECONDARY_WEAPONS];
 int CloseCombatWeaponCost[MAX_CLOSECOMBAT_WEAPONS];
};

static SpecieWeaponInformation SpeciesWeapons[2] =
{
 // soliders
 {
  // primary weapon names
  {
   "Nothing",  // place holder
   "mp5",   // Mp5
   "shotgun",  // Shotgun
   "gauss",  // gauss
   "rpg",   // rpg
  },
  // secondary weapon names
  {
   "Nothing",  // place holder
   "Nothing",
   "Nothing",
   "Nothing",
   "Nothing",
  },
  // close combat weapon names
  {
   "Nothing",  // place holder
   "knife",  // solider knife
   "Nothing",
   "Nothing",
   "Nothing",
  },

  // primary weapon points costs
  {0, 3, 1, 10, 40},
  // secondary weapon points costs
  {0, 0, 0, 0, 0 },
  // close combat weapon points costs
  {0, 3, 0, 0, 0 }
 },

 // aliens
 {
  // primary weapon names
  {
   "Nothing",  // place holder
   "zapper",  // lightning gun
   "Nothing",
   "Nothing",
   "Nothing",
  },
  // secondary weapon names
  {
   "Nothing",  // place holder
   "Nothing",
   "Nothing",
   "Nothing",
   "Nothing",
  },
  // close combat weapon names
  {
   "Nothing",  // place holder
   "claws",  // claws
   "Nothing",
   "Nothing",
   "Nothing",
  },

  // primary weapon points cost
  {0, 0, 40, 0, 0},
  // secondary weapon points cost
  {0, 0, 0, 0, 0},
  // close combat weapon points cost
  {0, 2, 0, 0, 0}
 },
};
/////////////////////////////////////

// Then in multiplay gamerules where i give the weapons to the player
char fullWeapName[30];

// 0 = no change in vgui.. 99 = nothing
if(pPlayer->m_iPrimaryWeapon != 0 && pPlayer->m_iPrimaryWeapon != 99)
{
sprintf(fullWeapName,"weapon_%s",SpeciesWeapons[0].PrimaryWeaponName[pPlayer->m_iPrimaryWeapon]);
pPlayer->GiveNamedItem(fullWeapName);
}

if(pPlayer->m_iSecondaryWeapon != 0 && pPlayer->m_iSecondaryWeapon != 99)
{
sprintf(fullWeapName, 
"weapon_%s",SpeciesWeapons[0].SecondaryWeaponName[pPlayer->m_iSecondaryWeapon]);
pPlayer->GiveNamedItem(fullWeapName);
}

if(pPlayer->m_iCloseCombatWeapon != 0 && pPlayer->m_iCloseCombatWeapon != 99)
{
sprintf(fullWeapName, 
"weapon_%s",SpeciesWeapons[0].CloseCombatWeaponName[pPlayer->m_iCloseCombatWeapon]);
ALERT(at_console, "ccw name = %s\n", fullWeapName);
pPlayer->GiveNamedItem(fullWeapName);

ALERT(at_console, "give item is ""%s""\n", fullWeapName);

}
ALERT(at_console, "PriWep = %i\nSecWep = %i\nCloseWep = 
%i\n",pPlayer->m_iPrimaryWeapon, pPlayer->m_iSecondaryWeapon, 
pPlayer->m_iCloseCombatWeapon);

/////////////////////////////////////
now here is the really weird part m_iCloseCombatWeapon is set to 1 so in theory when i 
am a
soldier race i should get the knife and i do get it but its unselectable.... ie it 
appears in
the hud and i can go down the list to get to it BUT when i click on it to pull out it 
won't.
Its not a problem with slots etc cause in the impulse 101 case statement i have
GiveNamedItem("weapon_knife");
now if i impulse i get it and it selects and all is well :/ but if i give it to me 
through the
above system it won't work.
Primary works fine for only the mp5 :/ all others give me what i want but they are 
unselectable. I find this problem
very weird and disturbing but it doesn't stop here if i do the following

// primary weapon names
{
 "Nothing",  // place holder
 "weapon_mp5",   // Mp5
 "weapon_shotgun",  // Shotgun
 "weapon_gauss",  // gauss
 "weapon_rpg",   // rpg
},

// close combat weapon names
{
 "Nothing",  // place holder
 "weapon_knife",  // solider knife
 "Nothing",
 "Nothing",
 "Nothing",
},

then again in the multiplay game rules when i set them up i do this instead

// 0 = no change in vgui.. 99 = nothing
if(pPlayer->m_iPrimaryWeapon != 0 && pPlayer->m_iPrimaryWeapon != 99)
{
pPlayer->GiveNamedItem(SpeciesWeapons[0].PrimaryWeaponName[pPlayer->m_iPrimaryWeapon]);
}

if(pPlayer->m_iSecondaryWeapon != 0 && pPlayer->m_iSecondaryWeapon != 99)
{
pPlayer->GiveNamedItem(SpeciesWeapons[0].SecondaryWeaponName[pPlayer->m_iSecondaryWeapon]);
}

if(pPlayer->m_iCloseCombatWeapon != 0 && pPlayer->m_iCloseCombatWeapon != 99)
{
pPlayer->GiveNamedItem(SpeciesWeapons[0].CloseCombatWeaponName[pPlayer->m_iCloseCombatWeapon]);
}

it works 100% fine. Now i don't see how compacting into 1 string with using sprintf 
and prefixing
"weapon_" should hurt it or make it work any different???? Do i have to do something 
with the
string before passing it into givenamed item.... ie does it need buffering or 
something. I'm
stumped as to why it works for primary weapon with sprintf but not the close combat 
weapon which
is viewable in hud but not selectable.... But i would rather have it as the single 
word so i
can use the same structure elsewhere to print out text into panels etc in the vgui and 
not
have to bother stripping the "weapon_" part off it.

UPDATE
I tryed some other things after talking to randomnine on it with him suggesting i 
should
print the contents of the string character by character after doing so i get something 
like this

sprintf(fullWeapName, "weapon_%s", 
SpeciesWeapons[0].CloseCombatWeaponName[pPlayer->m_iCloseCombatWeapon]);

for(i= 0; i < 30; i++)
{
 ALERT(at_console, "%c", fullWeapName[i]);

 if(i == 29)
  ALERT(at_console, "\n");
}

to the console it prints
weapon_mp5Bj! and the close combat weapon contains
weapon_knifej!

i dunno what the j! is :/ or the Bj! and how it got there either.

/////////////////////////

I think it has something to do with the following because one method works yet the 
other
won't.... and i dunno why, maybe my compiler is on LSD or something.

char *fullWeapName = "weapon_claws";  // this works gives weapon and selectable

char fullWeapName[30];        // these two lines result in getting the weapon
strcpy(fullWeapName, "weapon_claws"); // amd seeing in hud but i can't select it :/

pPlayer->GiveNamedItem(fullWeapName);

So has anyone got an idea as to why its not working as it should???? valve? anyone?

I really need to fix this :/ its driving me crazy and i just can't put it down till it 
works
so if anybody could save my soul it'd be great.

thanks in advance
Christopher Long.

ps - sorry for the long post of which i'm sure your eyes are bleeding from but well i 
thought it better to post information on the entire problem so those that
wish to read it can analyze it further.
--

_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders

Reply via email to