Script Request - Giving back to the community

dokel

New member
Hi,

a few years ago I had a script that allowed me to automate multiple sends of the same item to a list of recipients. I thought that it might be here somewhere but I have spent a fair while looking and can't find it. So I'm here requesting that some kind and generous soul reconstructs it for me :)

What it would do:

Allow input of the name of a single item.
Allow input of a comma separated list of recipients.
Send one of the item, from my inventory, to each name on the list (until item quantity hits zero).

IIRC the item was sent as a one-item gift package (brown paper parcel?).

Also, it would be cool if it was possible to add a note message.


So, yeah, it's really intended as a philanthropic way of offloading stuff that's filling up my inventory (useful stuff, not junk). I would mostly be sending stuff to people in the newbie chat channel.

I guess I could offer some sort of small reward. Maybe say 250,000 meat? I'm relying on the sense of community spirit here mostly ;)

Thanks in advance to anyone who is able to find the time to help.
 

Theraze

Active member
Some clarifications:
Are you wanting it to send exactly one item per recipient, or if you have 10 items and 5 recipients, do they each get 2?
If people do get multiple, are you wanting it to bundle the items and reduce packaging costs, or just sent lots of packages?
Is the list supposed to be randomized, or do we not really care and working through it in order is fine?
 

dokel

New member
Some clarifications:
Are you wanting it to send exactly one item per recipient, or if you have 10 items and 5 recipients, do they each get 2?
If people do get multiple, are you wanting it to bundle the items and reduce packaging costs, or just sent lots of packages?
Is the list supposed to be randomized, or do we not really care and working through it in order is fine?

Hi, thanks for the swift reply :)

To clarify:

Strictly one item per recipient.
I previously would take the list off the mafia chat relay. Basically do /whois on a chat channel then convert the resulting single-column list into a comma-separated list. Then I was able to simply cut and paste this list into the 'send to' input field.

Hope that helps.
 

digitrev

Member
This is incredibly rough, and you'll probably want to test this, but this might do what you want. It takes 3 arguments: an item, a list of users, and the message you'd like to send to them.

Code:
void main(string it, string userlist, string message) {
	for user in split_string(userlist, ","){
		if item_amount($item[it]) > 0{
			cli_execute("csend " + it + " to " + user + " || " + message);
		} else {
			break;
		}
	}
}
 

dokel

New member
Thanks digitrev, I'm currently in hc at the moment, but when I'm done I'll test it on my clannies and then report back :)
 

dokel

New member
This is incredibly rough, and you'll probably want to test this, but this might do what you want. It takes 3 arguments: an item, a list of users, and the message you'd like to send to them.

Quick question: does it take all three arguments as a single input? If so, how does it know the difference between commas separating recipients and commas separating arguments? Or do I not separate the arguments with commas? Apologies if this sounds a little dense :eek:
 

Theraze

Active member
When you run the script, it will ask for each of the 3 values, one at a time. So you save what digitrev posted into a file named something like "giftlist.ash" or something like that, and then just run giftlist.ash in the gCLI. When you do that, it will ask you for "it" in a popup box... that is your item. Then it will ask you for "userlist" which is your comma-separated list of users. And finally it will ask you for "message" which is the text that you want to send along with the item to each user.
 

dokel

New member
Hi,

Just reporting back from aftercore. I can't get the script to run :)

I get a message saying that there's a parsing error in line 1.

Oh well, thanks for trying.
 

Bale

Minion
I suspect you used the wrong sort of text editor. You need to save it with a non-formatting text editor, like notepad. If you use a text editor that can format, it will save extra characters for the formatting which produces parsing errors on line 1.
 

dokel

New member
Thanks for the tip Bale. I did originally use wordpad to save the script. Switched it to notepad.

Now I have a different error message: Expected from, found in (giftlist.ash, line 2)
 

dokel

New member
Hi folks,

So, I haven't been having much luck getting this script to work. I've been trying to teach myself scripting but it's (very) slow going.

So far, I have managed this...

void main ( string userlist ) {
string [int] username = split_string( userlist, "," );
}

Yep, that's it :eek: Basically it takes my comma-delimited user list and converts it into an array of individual usernames (as I'm sure you all appreciate).


I spotted this in zlib...

boolean send_gift( string recipient , string message , int meat , int [item] goodies )

This seems like it might fit my purposes and most of it I can figure out for myself - except for the item map 'goodies' - I really haven't been able to get my head around how maps work at all. Also, it's not at all clear to me how this handles package selection.

Any further help greatly appreciated - as an added incentive I'm offering one million meat to whoever helps me get this finished and working (the way I want it to).
 

Winterbay

Active member
The map int[item] goodies contains the item you want to send and the amount of it. So to create it you need to setup it like this:
Code:
int[item] stuff;
foreach it in $items[seal-clubbing club, seal tooth, antiantiantidote] {
   stuff[it] = 3;
}

That combined with the send_gift-function will send three of each of those items to the used player.
 

Theraze

Active member
So yeah... something like this:
Code:
import <zlib.ash>

main(string recipients, string message, string goodies) {
int [item] present;
present[to_item(goodies)] = 1;
string [int] users = split_string( recipients, "," );
foreach it in users {
if (item_amount(to_item(goodies)) == 0) abort("Ran out of "+to_item(goodies)+" so I am aborting.");
if (!send_gift( users[it], message , 0, present )) abort("Something went wrong sending the "+to_item(goodies)+" to "+users[it]+" so I am aborting.");
}
abort("Everyone got one!");
}
Untested, but should work. Save it to a file named randomgoodness.ash or something similar and run it. It should prompt you for the recipients, message, and goodies. Recipients takes a comma delineated list, message can be whatever you want, and goodies takes a single item name. It will send 1 of the item to each recipient and abort either when it runs out, if something fails in the sending (in which case it should tell you the item and who it was trying to send it to), or if it ran out of people to try, in which case you may want to send more. Or not.
 
Top