get_current_player_eid - ryzom/ryzomcore GitHub Wiki


title: Get Current Player EId description: published: true date: 2023-03-14T13:53:50.222Z tags: editor: markdown dateCreated: 2023-03-13T00:52:56.500Z

getCurrentPlayerEid

The getCurrentPlayerEid native AI script function gets the entity id of the player that is clicking on a bot.

This function is only valid when called from a player_target_npc event. {.is-warning}

Syntax

(EntityId: s)getCurrentPlayerEid() // getCurrentPlayerEid__s

Return value

  • EntityId (string): The entity id as a string of the player clicking on a bot.

Example

($playerEid)getCurrentPlayerEid();
(index)getBotIndexByName("toto");
(distance)getPlayerDistance(index, $playerEid);

phrasePushString("player", $playerEid);
phrasePushValue("integer", distance);
phraseEndNpcMsg(index, "say", "MSG_BOT_B_SAYS_THE_PLAYER_P_IS_AT_DISTANCE_D");

This example code gets the entity id of the player clicking on the bot, gets the index of the bot named "toto", gets the distance between the bot and the player, and then displays a message to the bot saying "The player with entity id playerEid is at a distance of distance."

See also

  • getCurrentSpeakerEid: Gets the EntityId of the bot at which the player is clicking at.
  • isPlayerAlived: Check if a player is alive based on their entity ID.
  • getPlayerStat: Retrieve a specific player stat given a player EntityId and the stat name.
  • getPlayerDistance: Calculate the distance between a player and a bot in meters.
  • queryEgs: Sends a query message to EGS to get information about a player, triggering a user event in response.
  • getEventParam: Retrieves the content of a parameter received by an EGS ai_event message.
⚠️ **GitHub.com Fallback** ⚠️