I got it working by creating a non-pointer char variable and using Q_snprintf.
I needed a copy of the KV object because my list also has columns for other fields. HL2 now has a working inventory system (even removes the item from the map). Any physics object that can be picked up and thrown can also be added to inventory. I also use a naming scheme that can be model-based or ID-based (Hammer targetname). Works nicely. Alfred Reynolds wrote:
Try something simpler like this:while(pInventory) { const char *pToken = pInventory->GetString("name"); const char *pName = Items->GetInvItemName(pToken); DevMsg("name: %s\n", pName);KeyValues *pKV = new KeyValues( "entry" ); pKV->SetString( "localized", pName );m_pInventory->AddItem(pKV, 0, false, false);pKV->deleteThis();pInventory = pInventory->GetNextKey(); }Can you also send the code snippet for the construction of the listpanel. - Alfred ----Original Message---- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Kamran Sent: Wednesday, August 10, 2005 6:13 PM To: HLCoders Subject: [hlcoders] Updating KeyValues when iteratingI'm adding items to a ListPanel and I iterate through a KeyValues object. Works fine, except: while(pInventory) { const char *pToken = pInventory->GetString("name"); const char *pName = Items->GetInvItemName(pToken); DevMsg("name: %s\n", pName); // Set name pInventory->SetString("localized", pName); m_pInventory->AddItem(pInventory, 0, false, false); pInventory = pInventory->GetNextKey(); } When it displays it, it just has a "t" character. But the dev msg displays it fine. I've also tried creating a different KV object and assigning it, but that doesn't work either._______________________________________________ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders
-- Kamran A Get Firefox! Safer, Faster, Better. <http://www.spreadfirefox.com/?q=affiliates&id=0&t=85> Down with Internet Explorer! Say "NO!" to Spyware! Use Firefox _______________________________________________ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders

