Returning error message as strings...

icon315

Member
After getting a message that my bot was not shooting someone, i saw that there had been an error:
Code:
Throwing snowball at <player>...
Can't use the item on that player at the moment.
and this was another one
Code:
Throwing time's arrow at <player>...
<player> evaded your thrown item by the unusual strategy of being nonexistent.

I was wondering if there was a way of somehow sending these error messages to the sender of a pm. In other words catching the error as a string and sending that to the sender.
 
Probably not through using cli_execute(), but if you use visit_url() you can save the results to a string, and check it for the various error messages using either contains_text() or regular expressions.
 
Alternatively, since it's a bot, it could check that if the item worked by using
string e=last_item_message();

If the message is anything other than the success string, then
chat_private(player, e);

Of course, you may want to alter the message, since they know their name already.
 
Items that use curse.php are handled by CurseRequest.java and not by UseItemRequest.java, so last_item_message() won't work.
 
Back
Top