// TMW2 Script
//
// @grantpower <username>
// Grants a legendary weapon to <username>. Cannot be undone.
// Only way to bypass restrictions on legendary weapons.
- script @grantpower 32767,{
end;
OnCall:
.@request$ = "";
.@request$ += implode(.@atcmd_parameters$, " ");
// Player is not attached
.@id = getcharid(3, .@request$);
if (!.@id) {
Exception("Player not found.", RB_ISFATAL|RB_DISPBOTTOM);
}
mes ".:: " + l("Grant Power") + " ::.";
mesc l("You're about to transfer a legendary weapon to @@.", .@request$), 1;
mesc l("This action CANNOT BE UNDONE."), 1;
mes l("Are you sure?");
if (askyesno() == ASK_NO)
close;
mes "";
mes ".:: " + l("Grant Power") + " ::.";
mes l("Please select the weapon to transfer.");
mes "";
mesc l("* Options will be removed after transfer is done.");
mesc l("* Cards will be deleted after transfer is done.");
mesc l("* Refine will be lost after transfer is done.");
if (countitem(Lightbringer))
mesc l("* Lightbringer is self-aware and cannot be given."), 1;
mes "";
menuint
l("None"), 0,
rif(countitem(DemureAxe), l("Demure's Axe")), DemureAxe,
rif(countitem(Tyranny), l("Tyranny")), Tyranny,
rif(countitem(Runestaff), l("Runestaff")), Runestaff,
rif(countitem(AegisShield), l("Aegis Shield")), AegisShield,
l("Abort"), 0;
mes "";
.@ori=getcharid(3);
.@ite=@menuret;
if (!.@ite)
close;
// Transfer the weapon
if (attachrid(.@id)) {
getitembound .@ite, 1, 1; // Account bound or char bound? (1 or 4)
dispbottom l("You received the @@ from @@.", getitemlink(.@ite), strcharinfo(0, "someone", .@ori));
consoleinfo("%s is the new owner for the %s.", strcharinfo(0), getitemname(.@ite));
detachrid();
attachrid(.@ori);
delitem .@ite, 1;
switch (.@ite) {
case DemureAxe:
$DEMUR_HOLDER$ = .@request$; break;
case Tyranny:
$TYRAN_HOLDER$ = .@request$; break;
case Runestaff:
$RUNES_HOLDER$ = .@request$; break;
case AegisShield:
$AEGIS_HOLDER$ = .@request$; break;
default:
Exception("Invalid legendary item "+str(.@ite),
RB_DEFAULT|RB_IRCBROADCAST); break;
}
} else {
Exception("Player not found.", RB_ISFATAL|RB_SPEECH);
}
close;
OnInit:
bindatcmd "grantpower", "@grantpower::OnCall", 0, 100, 1;
end;
// Legendary Controls: Interact over legendary holders and determine their status
function legendaryAPIWarning {
.@aid=getarg(0);
.@nb = query_sql("SELECT email FROM `login` WHERE `account_id` = '"+.@aid+"' LIMIT 1", .@email$);
.@msg$=sprintf("[\"%s\", \"Good evening!\nYou have been inactive for a week on Moubootaur Legends.\n\nYou are currently possessing a Legendary Weapon.\nIf you do not login within seven days, your legendary weapon will be returned so the player community can obtain it again.\n\nYour TMW2 Team\", \"Legendary item expiration notice\"]", .@email$);
debugmes .@msg$;
consoleinfo("%d notified for Legendary weapon inactivity. (L:2)", .@aid);
api_send(API_SENDMAIL, .@msg$);
return;
}
function legendaryRodexWarning {
.@cid=getarg(0);
rodex_sendmail(.@cid, "Legendary Weapon", "Inactivity Warning", "You have not logged in the past 2 days. Shall you fail to login for 15 days, the weapon will be destroyed!");
consoleinfo("%d notified for Legendary weapon inactivity. (L:1)", .@cid);
return;
}
function legendaryTimeCheck {
.@min = getarg(1)-86400;
.@max = getarg(1)+86400;
// getarg(0) is last_login, and getarg(1) the tolerance
// if last_login < tolerance (older), then ban
// But we don't want this to repeat.
// Tolerance: day 10 -> min = 10-1=9; max=10+1=11
// Day 8: (8 < 11? yes; 8 > 9? no)
// Day 9: (9 < 11? yes; 9 > 9? no)
// Day 10: (10 < 11? yes; 10 > 9? yes) -> Message sent
// Day 11: (11 < 11? no; 11 > 9? yes)
// Day 12: (12 < 11? no; 12 > 9? yes)
if (getarg(0) < .@max && getarg(0) > .@min)
return true;
else
return false;
}
OnClock0238:
.@date=gettimetick(2);
.@warn=.@date-(86400*2);
.@kick=.@date-(86400*7);
.@kban=.@date-(86400*15);
//////////////////////////////////////////
if ($LIGHT_HOLDER$ != "") {
.@nb = query_sql("SELECT last_login, char_id, account_id FROM `char` WHERE `name` = '"+$LIGHT_HOLDER$+"' LIMIT 1", .@login, .@cid, .@aid);
if (.@login < .@kban) {
// Destroy the item by force
DelItemFromEveryPlayer(Lightbringer);
$LIGHT_HOLDER$="";
kamibroadcast("The Lightbringer has given up on its previous owner and is now available for someone worthier.");
} else if (legendaryTimeCheck(.@login, .@kick)) {
// Send warning via API
legendaryAPIWarning(.@aid);
} else if (legendaryTimeCheck(.@login, .@warn)) {
// Send warning ingame
legendaryRodexWarning(.@cid);
}
}
//////////////////////////////////////////
if ($DEMUR_HOLDER$ != "") {
.@nb = query_sql("SELECT last_login, char_id, account_id FROM `char` WHERE `name` = '"+$DEMUR_HOLDER$+"' LIMIT 1", .@login, .@cid, .@aid);
if (.@login < .@kban) {
// Destroy the item by force
DelItemFromEveryPlayer(DemureAxe);
$DEMUR_HOLDER$="";
kamibroadcast("The Demure Axe has given up on its previous owner and is now available for someone worthier.");
} else if (legendaryTimeCheck(.@login, .@kick)) {
// Send warning via API
legendaryAPIWarning(.@aid);
} else if (legendaryTimeCheck(.@login, .@warn)) {
// Send warning ingame
legendaryRodexWarning(.@cid);
}
}
//////////////////////////////////////////
if ($TYRAN_HOLDER$ != "") {
.@nb = query_sql("SELECT last_login, char_id, account_id FROM `char` WHERE `name` = '"+$TYRAN_HOLDER$+"' LIMIT 1", .@login, .@cid, .@aid);
if (.@login < .@kban) {
// Destroy the item by force
DelItemFromEveryPlayer(Tyranny);
$TYRAN_HOLDER$="";
kamibroadcast("The Tyranny has given up on its previous owner and is now available for someone worthier.");
} else if (legendaryTimeCheck(.@login, .@kick)) {
// Send warning via API
legendaryAPIWarning(.@aid);
} else if (legendaryTimeCheck(.@login, .@warn)) {
// Send warning ingame
legendaryRodexWarning(.@cid);
}
}
//////////////////////////////////////////
if ($RUNES_HOLDER$ != "") {
.@nb = query_sql("SELECT last_login, char_id, account_id FROM `char` WHERE `name` = '"+$RUNES_HOLDER$+"' LIMIT 1", .@login, .@cid, .@aid);
if (.@login < .@kban) {
// Destroy the item by force
DelItemFromEveryPlayer(Runestaff);
$RUNES_HOLDER$="";
kamibroadcast("The Runestaff has given up on its previous owner and is now available for someone worthier.");
} else if (legendaryTimeCheck(.@login, .@kick)) {
// Send warning via API
legendaryAPIWarning(.@aid);
} else if (legendaryTimeCheck(.@login, .@warn)) {
// Send warning ingame
legendaryRodexWarning(.@cid);
}
}
//////////////////////////////////////////
if ($AEGIS_HOLDER$ != "") {
.@nb = query_sql("SELECT last_login, char_id, account_id FROM `char` WHERE `name` = '"+$AEGIS_HOLDER$+"' LIMIT 1", .@login, .@cid, .@aid);
if (.@login < .@kban) {
// Destroy the item by force
DelItemFromEveryPlayer(AegisShield);
$AEGIS_HOLDER$="";
kamibroadcast("The Aegis Shield has given up on its previous owner and is now available for someone worthier.");
} else if (legendaryTimeCheck(.@login, .@kick)) {
// Send warning via API
legendaryAPIWarning(.@aid);
} else if (legendaryTimeCheck(.@login, .@warn)) {
// Send warning ingame
legendaryRodexWarning(.@cid);
}
}
//////////////////////////////////////////
end;
}