Need help with recieve url script to recall stored values to player.

Users who are viewing this thread

Morbid

Banned
here is the script so far, not sure if it is correct yet but i feel like I am close.

Code:
   ("update_player_health_values",
   [(store_script_param, ":player_id", 1), # must be valid

    (try_begin),
      (player_is_active, ":player_id"),
      (store_agent_hit_points, reg1),
      (player_get_unique_id, ":player_unique_id", ":player_id"),
      (assign, reg0, ":player_unique_id"),
      (send_message_to_url, "@http://127.0.0.1/health.php?uid={reg0}&health={reg1}"),
    (try_end),


   ]),

Now here is what I did for the receive url script, I'm just not sure what to do for it. 

Code:
 (try_begin),  #health recall
 
         (eq, ":string_count", 22),
         (eq, ":integer_count", 23),
         (assign, ":player_id", reg0),
         (assign, ":unique_id", reg1),
         (assign, ":health", reg2),
		 (try_begin),
		 (gt, ":health", 0),
		 (assign, ":health", 0),
		 (try_end),
 
Morbid said:
Code:
   ("update_player_health_values",
   [(store_script_param, ":player_id", 1), # must be valid

    (try_begin),
      (player_is_active, ":player_id"),
The comment "must be valid" next to a script parameter in the PW module system means that the id is used without checking it is valid, to avoid repeatedly checking ids all through a long script chain. If you have a player_is_active check enclosed in a try block, the calling script can safely give any value for ":player_id" and the script will not cause an error; but if you only ever call this script from your own code where the player id was already checked or must be valid because it is directly from a game engine trigger, you can remove your check.
Morbid said:
Code:
      (store_agent_hit_points, reg1),
That makes no sense: get the hit points of which agent? You first need to get the player's agent, check it is valid, check it is alive, then pass to the store_agent_hit_points operation (player_get_agent_id, agent_is_active, agent_is_alive).
Morbid said:
Code:
         (eq, ":string_count", 22),
         (eq, ":integer_count", 23),
         (assign, ":player_id", reg0),
As I have said repeatedly, don't use this method to decide which message type was sent! Always use the first integer (reg0) as a message type number, then there will be no mix ups later on when you add more messages that happen to return the same number (count) of values. Also, 22 strings and 23 integers is a massive message, very wasteful if you just want to set hit points.
 
on the return i tried using ":health" which is not in the header operations to see how to use.  I tried using it int he script as well because it just made sense. 

I'm not sure how the return script knows what the store agent health is.  I assigned it to reg1 would i just assign reg1 to player_id for the receive script?
 
Sorry, I forgot to reply to this.
Morbid said:
on the return i tried using ":health" which is not in the header operations to see how to use.  I tried using it int he script as well because it just made sense.
The name of a local variable is up to you, and doesn't make any difference to how the code runs; you could rename all usages of it to ":flimflam" instead and the built module .txt files would be identical, with the only change being that your module system script would be harder to understand.
Morbid said:
I'm not sure how the return script knows what the store agent health is.  I assigned it to reg1 would i just assign reg1 to player_id for the receive script?
The relevant line from header_operations:
Code:
store_agent_hit_points                            = 1720 # (store_agent_hit_points,<destination>,<agent_id>,[absolute]),
                                                         # set absolute to 1 to retrieve actual hps, otherwise will return relative hp in range [0..100]
As you can see, the operation requires at least 2 parameters (the third one is optional - marked by the square brackets). The first parameter must be the destination variable, whether a local variable (":health") or a register (reg1), and the second parameter must be a valid agent id to get the hit points of. Any optional parameters that you don't specify will use the value "0", which is the default.
 
thanks vornne, I believe we got hp saving done and working for our new system coming out.  We need so make hunger saving script to go with it?
 
Back
Top Bottom