Function question

Started by Gepard, Sat 27/07/2013 14:05:05

Previous topic - Next topic

Gepard

Basically what I'm trying to do is to have a function that checks if a player has an inventory item, if not, than gives the player that item and than displays that item text property on a label. How can I do this?

Thanks!
Drink up me 'arties! Yo ho!

Crimson Wizard

Hey Gepard, long time no see :)

Code: ags

function GiveItemIfDoNotHaveOne(InventoryItem *item)
{
   if (!player.HasInventory(item))
   {
      player.AddInventory(item);
      // Set label text
      lblItemName.Text = item.Name; // or item.GetTextProperty("property_name");
   }
   // optionally do something if player already has one
   else
   {
      Display("I have it already");
   }
}


Gepard

Good to see you old friend and thanks for the help!
Drink up me 'arties! Yo ho!

SMF spam blocked by CleanTalk