Propose a trade in a script...oh and sell me your sewer items!

TradeArray.ash is a set of functions which you use to build a list of items you wish to trade to another player, then propose the trade offer. The script is designed to be imported into another script.

ItemAdd(item toput, int QuantToSave)
call this function for each item you want to add to the list of items to be traded. QuantToSave is the amount of the item to keep.

The reason for using QuantToSave instead of QuantToTrade is that most of the time people (at least myself) know how many of an item they want to keep, and calculate how many to trade. The script does it for you. 0 to keep none.

ExecuteTrade(int Playernum, string message)
Call this function after building the list. Playernum is the players number you want to propose the trade to. message is the text in the trade message

About message text: this can be an empty string "" if you have any spaces in the message replace them with a + sign as demonstrated in Sewertrade.ash. any punctuation should be omitted (unless you know how to properly convert). Later I may add further instructions for use of punctuation. Now supports plain text messages per veracity's suggestion.
about playernum: it is the player number visible on a players profile by their name.

SewerTrade.ash
this script will build a list of tradeable sewer items which you have (except spices), and propose them in a trade offer to me (I collect them). For those who don't know I will reply with 75 meat per item.

SewerTrade.ash requires TradeArray.ash, however you may use tradearray.ash for other items/players as you see the need. I suggest looking at SewerTrade.ash if you plan to use TradeArray.ash because it is an example of how to use TradeArray.

Any Trades offered using this script must be accepted manually. There is no method of replying to a trade offer automattically that I see, or accepting them.


This script was written and posted at the request of another player who sells sewer items to me.
edit: forgot the files. How dumb of me :p
Now updated to use url_encode. Now supports plain text messages. I forgot the feature was added.
 

Attachments

  • SewerTrade.ash
    668 bytes · Views: 92
  • TradeArray.ash
    1.9 KB · Views: 92

Veracity

Developer
Staff member
[quote author=efilnikufecin link=topic=271.msg1399#msg1399 date=1152333978]
About message text: this can be an empty string "" if you have any spaces in the message replace them with a + sign as demonstrated in Sewertrade.ash. any punctuation should be omitted (unless you know how to properly convert). Later I may add further instructions for use of punctuation.[/quote]
Is there some reason you can't simply use:

string url_encode( string text );

to do the conversions you refer to?

- spaces go to +
- punction goes to <whatever is correct>
...and so on

That's the purpose of this ASH function.

The caller could use url_encode on the input string, but if you are providing a library function which takes a string and puts it into a URL, then the proper place to call the encoding function is your library function...
 
[quote author=Veracity link=topic=271.msg1401#msg1401 date=1152336588]
Is there some reason you can't simply use:

string url_encode( string text );

to do the conversions you refer to?

- spaces go to +
- punction goes to <whatever is correct>
...and so on

That's the purpose of this ASH function.

The caller could use url_encode on the input string, but if you are providing a library function which takes a string and puts it into a URL, then the proper place to call the encoding function is your library function...
[/quote]

Nope, I missed that and will update the script now. well as soon as I find out exactly how to use the function (find the message documenting the feature).

Edit: Found the post, and modified the script to use the feature. Thanks for reminding me the feature was available Veracity. Oh and if I had paid more attention to the post above I wouldn't have needed to find the original post. I need to lay off the caffeine
 
Top