Ash Propose Trade

Sputnik1

Member
I was wondering why there is not a propose trade syntax in ash. It's interesting that there is not a lot of talk about it except for recently in Bale's OCD script. And yes, I understand Bale why you don't want to add it to your script. I just don't understand why someone hasn't added that feature.

That is all.
 

Bale

Minion
I guess there aren't many people who want to write trading scripts, except for those who are comfortable writing it with visit_url(). It's not a common thing to do after all. What it comes down to, really though, is that none of the mafia devs are interested in that. After all, there were no MMG commands until last year when Veracity got interested in that and suddenly we had a lot of MMG commands. Since the trade system requires you to propose a trade, answer a trade and confirm a trade, along with listeners to tell when these occur, it requires some attention and time on the part of the developer to make sure it gets done right.

tl;dr: It's a pain in the neck and there isn't an interested programmer.
 

Sputnik1

Member
Actually Bale, visit_url looks to be quite sufficient for my needs. Quite easy to change. Will make it easy to sell off my castle items above autosell.

EDIT

Ive been working on this and I'm having some notation errors.

string s_1 = "bob1";
int wm = item_amount($item[wolf mask]);
int wmsale = 250 * wm;
string wms = "This trade is worth "+wmsale+" meat.";

if ( wm > 0 )
visit_url("makeoffer.php?towho="+s_1+"&action=proposeoffer&pwd&howmany1="+wm+"&whichitem1=633&offermeat=&memo="+wms);

With this I have been trying to get the memo to show the string which mentions the total price of the trade. The problem is that I can only get the first part of the string to show up.

So it only says "This trade is worth".

I tried the other way of using a memo like this

visit_url("makeoffer.php?towho="+s_1+"&action=proposeoffer&pwd&howmany1="+wm+"&whichitem1=633&offermeat=&memo=This trade is worth "+wm+" meat");

But it works the same way as the previous. Why would the number not show up in the text box either way?
 
Last edited:
When working with urls the strings need to be url encoded. Try using the url_encode function:

Code:
visit_url("makeoffer.php?towho="+url_encode(s_1)+"&action=proposeoffer&pwd&howmany1="+wm+"&whichitem1=633&offermeat=&memo="+url_encode(wms));
 

Sputnik1

Member
I will try that out Ninja. When I was thinking about it I wondered if there was a problem with using strings in a url, since the code works perfectly when printing to the cli.
 

Veracity

Developer
Staff member
If you mean that it replaces spaces with + in the URL it submits, that is correct behavior.
If you mean that the recipient sees + instead of spaces in the received message, that indicates double URL-encoding.

visit_url( string ) is supposed to automatically url-encode its argument. If you have already url-encoded it, you have to call the 3-argument version of visit_url and tell it that: visit_url( url, true, true ); (the second argument says to use POST, which your probably want).

Now, since visit_url already url-encodes your argument, it's not clear why it's not working right for you without those calls - although if you are putting in arbitrary strings - which might include the "&" character, for example, you should do it that way. I'm unclear on what you mean by "Why would the number not show up in the text box either way?" Which text box? At the recipient, in the browser, or are you making a relay override of some sort?
 

Sputnik1

Member
Yeah I am talking about the memo that we both see on the trade screen. Earlier the memo would not include the price total, only the first part of the text. Now with url_encode the price is included but also gives you +'s in the memo.

This is what it looks like

Note:
This+trade+is+worth+ 255+meat.
 

Veracity

Developer
Staff member
So ... how about if you do what I told you to do to fix it? I diagnosed the problem and gave you the solution.
 

Sputnik1

Member
After changing the code to the additional form of visit_url, the output has the same effect as my original problem.

This...
Code:
int wmp = 255 * wm;
string wms = "This trade is worth "+wmp+" meat";
	visit_url("makeoffer.php?towho="+s_t+"&action=proposeoffer&pwd&howmany1="+wm+"&whichitem1=633&offermeat=&memo="+wms,true,true);
...gives...
This trade is worth

Interestingly this...
Code:
int wmp = 255 * wm;
string wms = "This_trade_is_worth _"+wmp+"_meat";
visit_url("makeoffer.php?towho="+s_t+"&action=proposeoffer&pwd&howmany1="+wm+"&whichitem1=633&offermeat=&memo="+wms);

...fixes the issue of the total not showing up. All the while not having to use url_encode() like I did before.
Note:
This_trade_is_worth _510_meat

So something between the first string and the second version is causing the issue? Because it looks like its not the url notation.
 

lostcalpolydude

Developer
Staff member
I believe that's KoL preventing you from scamming uninformed players by preventing a string with "X meat" from appearing in the message.
 

Sputnik1

Member
How is it scamming if I asked them for their price ahead of time? I am only trading to LaNz; one user.
 
Last edited:

Winterbay

Active member
It's not you... Because there was a situation a while ago when someone sent "You acquire X meat" to newbies and made them send items back despite them not getting anything so now that sort of message is disallowed (or something to that regard, I do not remember exactly)
 

Sputnik1

Member
Hmm, let me try rewording it then.

Yep, that worked!

Having X meat in the memo gets removed.
 
Last edited:
Top