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.
(EntityId: s)getCurrentPlayerEid() // getCurrentPlayerEid__s
($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
."
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.