The Botter
New member
Is there a way to send copies of a KMail to Multiple people and still have the option of including items and meat.
// This example will attempt to send 1000 meat and
// 11 batguts to each of the players listed in "recipients".
// copy the kmail functions here
string recipients = "Zarqon,Kaluna,Macatoni,Uggh"; // commas, no spaces
string message = "Hello, here is a bit of meat and a ridiculous amount of batguts!";
int meattosend = 1000; // how much meat to send in each kmail
int[item] stufftosend;
stufftosend[$item[batgut]] = 11; // you can add items following this format
string[int] recipmap = split_string(recipients,",");
foreach r in recipmap
if (!kmail(recipmap[r],message,meattosend,stufftosend)) abort("Unable to send.");
boolean kmail(string to, string message, int meat, int[item] goodies) {
string itemstring = "";
int j = 0;
string[int] itemstrings;
if (count(goodies) > 0)
foreach i in goodies {
if (is_tradeable(i)) {
j = j+1;
itemstring = itemstring + "&howmany"+j+"="+goodies[i]+"&whichitem"+j+"="+to_int(i);
if (j > 10) {
itemstrings[count(itemstrings)] = itemstring;
itemstring = '';
j = 0;
}
}
}
if (itemstring != "") itemstrings[count(itemstrings)] = itemstring;
if (count(itemstrings) == 0) itemstrings[0] = "";
string msg;
foreach q in itemstrings {
if (q == 0) { msg = message; } else msg = 'Here are your remaining items that would not fit in the previous message.';
string url = visit_url("sendmessage.php?pwd=&action=send&towho="+url_encode(to)+"&message="+url_encode(msg)+"&sendmeat="+meat+itemstrings[q]);
if (contains_text(url,"That player cannot receive Meat or items"))
return send_gift(to, message, meat, goodies);
if (!contains_text(url,"Message sent.")) {
print("The message didn't send for some reason.","red");
return false;
}
}
return true;
{string recipients = "name,name";
string message = "Hey I am testing this out!";
int meattosend = 1;
int[item] stufftosend;
stufftosend[$item[batgut]] = 1;
string[int] recipmap = split_string(recipients,",");
foreach r in recipmap
if (!kmail(recipmap[r],message,meattosend,stufftosend)) abort("Unable to send.");
(Copied and pasted functions)
string recipients = "name,name2";
string message = "This is my message";
int meattosend = 1;
int[item] stufftosend;
stufftosend[$item[batgut]] = 1;
string[int] recipmap = split_string(recipients,",");
foreach r in recipmap
if (!kmail(recipmap[r],message,meattosend,stufftosend)) abort("Unable to send.");
boolean send_gift(string to, string message, int meat, int[item] goodies) {
string itemstring = "";
int j = 0;
int[item] extra;
if (count(goodies) > 0)
foreach i in goodies {
if (is_tradeable(i)) {
j = j+1;
if (j < 4)
itemstring = itemstring + "&howmany"+j+"="+goodies[i]+"&whichitem"+j+"="+to_int(i);
else extra[i] = goodies[i];
}
}
int shipping = 200;
int pnum = 3;
if (count(goodies) < 3) {
shipping = 50*count(goodies);
pnum = count(goodies);
}
if (my_meat() < meat+shipping) {
print("Not enough meat to send the package.","red");
return false;
}
string url = visit_url("town_sendgift.php?pwd=&towho="+to+"¬e="+message+"&insidenote=&whichpackage="+pnum+"&fromwhere=0&sendmeat="+meat+"&action=Yep."+itemstring);
if (!contains_text(url,"Package sent.")) {
print("The message didn't send for some reason.","red");
return false;
}
if (count(extra) > 0) return send_gift(to,"Here are your remaining items that would not fit in the previous message.",0,extra);
return true;
}
boolean kmail(string to, string message, int meat, int[item] goodies) {
string itemstring = "";
int j = 0;
string[int] itemstrings;
if (count(goodies) > 0)
foreach i in goodies {
if (is_tradeable(i)) {
j = j+1;
itemstring = itemstring + "&howmany"+j+"="+goodies[i]+"&whichitem"+j+"="+to_int(i);
if (j > 10) {
itemstrings[count(itemstrings)] = itemstring;
itemstring = '';
j = 0;
}
}
}
if (itemstring != "") itemstrings[count(itemstrings)] = itemstring;
if (count(itemstrings) == 0) itemstrings[0] = "";
string msg;
foreach q in itemstrings {
if (q == 0) { msg = message; } else msg = 'Here are your remaining items that would not fit in the previous message.';
string url = visit_url("sendmessage.php?pwd=&action=send&towho="+url_encode(to)+"&message="+url_encode(msg)+"&sendmeat="+meat+itemstrings[q]);
if (contains_text(url,"That player cannot receive Meat or items"))
return send_gift(to, message, meat, goodies);
if (!contains_text(url,"Message sent.")) {
print("The message didn't send for some reason.","red");
return false;
}
}
return true;
}
string recipients = "name1,name2";
string message = "Hey I am testing this out!";
int meattosend = 0;
int[item] stufftosend;
stufftosend[$item[batgut]] = 0;
string[int] recipmap = split_string(recipients,",");
foreach r in recipmap
if (!kmail(recipmap[r],message,meattosend,stufftosend)) abort("Unable to send.");