receive_mission_items - ryzom/ryzomcore GitHub Wiki


title: Receive Mission Items description: Request mission items from a player through an NPC contextual menu published: true date: 2026-03-14T00:00:00.000Z tags: editor: markdown dateCreated: 2023-03-16T22:26:48.497Z

receiveMissionItems

The receiveMissionItems native AI script function adds a contextual menu entry to an NPC that allows a player to give mission items to the NPC. EGS checks whether the player has the required items and triggers different user events depending on the outcome.

This function can only be called from a player_target_npc event handler. It only works on R2 shards for R2 plot items. {.is-warning}

Syntax

()receiveMissionItems(missionItems: s, missionText: s, groupToNotify: c)

Arguments

  • missionItems (string): The items to request, in the format "sheet_id:quantity;sheet_id:quantity;...". Example: "toto.sitem:2;tata.sitem:1"
  • missionText (string): The text that will appear in the NPC's contextual menu entry.
  • groupToNotify (context): The NPC group that will receive user events with the results.

Item Format

The missionItems string is a semicolon-separated list of item entries. Each entry is a sheet ID and quantity separated by a colon:

sheet_id_1:quantity_1;sheet_id_2:quantity_2;sheet_id_3:quantity_3

All sheet IDs must be valid .sitem sheet names and all quantities must be greater than 0.

Callback User Events

The following user events are triggered on groupToNotify:

Event When
user_event_1 The player has the requested items in their inventory
user_event_2 The player does not have the requested items
user_event_3 The player has given the items to the NPC (items transferred)

How It Works

  1. The NPC turns to face the player
  2. A CGiveItemRequestMsg is sent to EGS with the item list
  3. EGS checks the player's inventory for the requested items
  4. If the player has the items, user_event_1 is triggered and the menu entry is shown
  5. If the player doesn't have the items, user_event_2 is triggered
  6. When the player clicks the menu entry and confirms, items are transferred and user_event_3 is triggered

Example

// In a player_target_npc event handler:
(@myGroup)context();
()receiveMissionItems("quest_item_a.sitem:1;quest_item_b.sitem:3", "Give the quest items", @myGroup);

Handle the responses:

// user_event_1: player has the items
()npcSay(0, "say", "Ah, you have what I need!");

// user_event_2: player doesn't have the items
()npcSay(0, "say", "Come back when you have the items.");

// user_event_3: items were given
()npcSay(0, "say", "Thank you! Here is your reward.");
(@myGroup)context();
()giveReward("Reward!", "Rare!", "Full!", "No points!", @myGroup);

See also

Source: ryzom/server/src/ai_service/nf_grp_npc.cpp (receiveMissionItems_ssc_)

⚠️ **GitHub.com Fallback** ⚠️