Actions

Difference between revisions of "GMCP Data"

From Iron Realms Nexus Client Documentation

 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
This sample code is called in the default onGMCP function in [[Reflexes]]. The onGMCP function is run every time the game receives a GMCP message from the server. This script has been added to that function.
This sample code is called in the default [[onGMCP|onGMCP function]] in [[Reflexes]]. The onGMCP function is run every time the game receives a [[GMCP]] message from the server. This script has been added to that function.


-------------
Here is the GMCP message received from the server to the Nexus client.


if (args.gmcp_method == "Char.Vitals")  
Char.Vitals { "hp": "818", "maxhp": "818", "mp": "986", "maxmp": "986", "nl": "58", "bal": "1", "eq": "1", "leftarm": "1", "rightarm": "1", "health": "1", "herb": "1", "salve": "1", "toadstool": "1", "pipe": "1", "tree": "1", "focus": "1", "purge": "1", "essence": "2000", "faith": "0", "health_reserve": "3", "mana_reserve": "34", "leftwield": "0", "leftwield_name": "", "rightwield": "0", "rightwield_name": "", "string": "H:818/818 M:986/986 NL:58/100 ", "charstats": [ "Level: 14  (58.10%)" ] }
{
 
 
Here is the code added to the [[onGMCP|onGMCP function]]. It finds the current health and mana of the character, as well as what items it has wielded in its left and right hands. It displays this data to the client window (see image below)  and then sets the data to a client [[variables|variable]] (see image below).
 
if (args.gmcp_method == "Char.Vitals")  
{
    health= args.gmcp_args.hp;
    mana = args.gmcp_args.mp;
     left = args.gmcp_args.leftwield;
     left = args.gmcp_args.leftwield;
     right = args.gmcp_args.rightwield;
     right = args.gmcp_args.rightwield;
      
      
     client.print("Right: " + right);
     client.print("Health: " + health + " Mana: " + mana + " Left: " + left + " Right: " + right);
     client.print("Left: " + left);
     client.set_variable('current-health', health);
    client.set_variable('current-mana', mana);
     client.set_variable('wielded-right', right);
     client.set_variable('wielded-right', right);
     client.set_variable('wielded-left', left);
     client.set_variable('wielded-left', left);
};
};
 
Here is a screenshot of the function in the [[reflexes]] settings window.
 
[[File:ongmcp-capture.png|800px]]
 
 
Here is a screenshot of the main output window displaying the information.
 
[[File:ongmcp-main-window.png|800px]]
 
 
Here is a screenshot of the data in the [[Variables]] settings window.


-------------
[[File:ongmcp-variables-window.png|800px]]

Latest revision as of 18:48, 11 February 2016

This sample code is called in the default onGMCP function in Reflexes. The onGMCP function is run every time the game receives a GMCP message from the server. This script has been added to that function.

Here is the GMCP message received from the server to the Nexus client.

Char.Vitals { "hp": "818", "maxhp": "818", "mp": "986", "maxmp": "986", "nl": "58", "bal": "1", "eq": "1", "leftarm": "1", "rightarm": "1", "health": "1", "herb": "1", "salve": "1", "toadstool": "1", "pipe": "1", "tree": "1", "focus": "1", "purge": "1", "essence": "2000", "faith": "0", "health_reserve": "3", "mana_reserve": "34", "leftwield": "0", "leftwield_name": "", "rightwield": "0", "rightwield_name": "", "string": "H:818/818 M:986/986 NL:58/100 ", "charstats": [ "Level: 14 (58.10%)" ] }


Here is the code added to the onGMCP function. It finds the current health and mana of the character, as well as what items it has wielded in its left and right hands. It displays this data to the client window (see image below) and then sets the data to a client variable (see image below).

if (args.gmcp_method == "Char.Vitals") 
{
   health= args.gmcp_args.hp;
   mana = args.gmcp_args.mp;
   left = args.gmcp_args.leftwield;
   right = args.gmcp_args.rightwield;
   
   client.print("Health: " + health + " Mana: " + mana + " Left: " + left + " Right: " + right);
   client.set_variable('current-health', health);
   client.set_variable('current-mana', mana);
   client.set_variable('wielded-right', right);
   client.set_variable('wielded-left', left);
};

Here is a screenshot of the function in the reflexes settings window.

Ongmcp-capture.png


Here is a screenshot of the main output window displaying the information.

Ongmcp-main-window.png


Here is a screenshot of the data in the Variables settings window.

Ongmcp-variables-window.png