GiveItem2Character is just a function; you can place it anywhere as long as the reference passed to it, ch, points to the main character.
Actually, if you change it to GiveItem2Character(GetMainCharacter(), "itemid");
you can place it _anywhere at all_, as long as the block of code it's in executes on initialization.
So, you could put it in locations init, or in ships_init, or wherever. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid="
" border="0" alt="smile.gif" />
But, yes, what you're talking about works too, so good work figuring it out! <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/onya.gif" style="vertical-align:middle" emoid="
" border="0" alt="onya.gif" />
{There is one slight problem: that way, you address the items attribute directly; if we ever _change_ the way items are tracked, i.e. add multiple inventories as we've kicked around elsewhere here, you'll need to use a function "`front-end`" like giveitem2character.}
You see, items right now are tracked as character (in this case the reference variable ch).items.ITEMID where item id is the ID of the item.
So if you add the line
ch.items.pistol4 = 2, you are saying, make the quantity of item "pistol2" carried by character ch 2.
(No need to use string variables in () in this case)
The need for defines come if you add the + or -, as you can't have that "standing naked" in the attribute (i.e. you can't do ch.items.pistol4+2 = 2 because the program will interpret that as trying to add 2 to the _value_ of the attribute ch.items.pistol4).
Same as if you start an attribute name with a number, you need to set it to a string variable and then address the attribute as string somevar = "something+somethingelse"; object.(somevar) = x;, like you see there.
Hope that makes sense. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid="
" border="0" alt="smile.gif" />