summaryrefslogtreecommitdiff
path: root/npc
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2021-07-29 11:24:29 -0300
committerJesusaves <cpntb1@ymail.com>2021-07-29 11:24:29 -0300
commitc7e7ed20611e63b06dfb06340127d6ac9ddc9f78 (patch)
treed9f2fe2e8a9c3a45e7534e6b15bd536535731338 /npc
parentc901566df9aa4b0b23dace21bbaec52670c5ddf1 (diff)
downloadserverdata-c7e7ed20611e63b06dfb06340127d6ac9ddc9f78.tar.gz
serverdata-c7e7ed20611e63b06dfb06340127d6ac9ddc9f78.tar.bz2
serverdata-c7e7ed20611e63b06dfb06340127d6ac9ddc9f78.tar.xz
serverdata-c7e7ed20611e63b06dfb06340127d6ac9ddc9f78.zip
This not so pretty function is Moubootaur Legends Server Updater.
It is much simpler than Hercules version and does not require admin intervention. Although more dangerous and slower.
Diffstat (limited to 'npc')
-rw-r--r--npc/functions/clear_vars.txt17
-rw-r--r--npc/functions/global_event_handler.txt1
-rw-r--r--npc/functions/main.txt123
3 files changed, 141 insertions, 0 deletions
diff --git a/npc/functions/clear_vars.txt b/npc/functions/clear_vars.txt
index be895576..063feaec 100644
--- a/npc/functions/clear_vars.txt
+++ b/npc/functions/clear_vars.txt
@@ -142,3 +142,20 @@ function script ClearVariables {
}
+function script ServerUpdate {
+ if ($@STARTUP) {
+ debugmes "Cowardly refusing to update server outside startup";
+ return;
+ }
+
+ // Correct Mana Pearl ID
+ // qui jul 29 11:21:38 BRT 2021
+ if ($VERSION < 1627568498) {
+ ReplaceItemFromEveryPlayer(5270, 5272);
+ $VERSION = 1627568498;
+ }
+
+ $@STARTUP = true;
+ return;
+}
+
diff --git a/npc/functions/global_event_handler.txt b/npc/functions/global_event_handler.txt
index 8a9c4fd6..b63fb28f 100644
--- a/npc/functions/global_event_handler.txt
+++ b/npc/functions/global_event_handler.txt
@@ -45,6 +45,7 @@ OnClock1701:
end;
OnInit:
+ ServerUpdate(); // Update server if needed
MOTD(); // set the MOTD array
end;
diff --git a/npc/functions/main.txt b/npc/functions/main.txt
index abdaa5dd..6a19e3a7 100644
--- a/npc/functions/main.txt
+++ b/npc/functions/main.txt
@@ -790,3 +790,126 @@ function script spawndummy {
return .@u;
}
+/////////////////////////////////////////////////////////////////////////////////
+// Do not run this outside startup
+// Delete item ID on inventories, storages, guild storages and carts. Also affects mails.
+// WARNING, irreversible and dangerous!
+// DelItemFromEveryPlayer( ID )
+function script DelItemFromEveryPlayer {
+ if (getarg(0, -1) < 0)
+ return;
+
+ query_sql("DELETE FROM `inventory` WHERE `nameid`="+getarg(0));
+ query_sql("DELETE FROM `cart_inventory` WHERE `nameid`="+getarg(0));
+ query_sql("DELETE FROM `storage` WHERE `nameid`="+getarg(0));
+ query_sql("DELETE FROM `guild_storage` WHERE `nameid`="+getarg(0));
+ query_sql("DELETE FROM `rodex_items` WHERE `nameid`="+getarg(0));
+ query_sql("DELETE FROM `auction` WHERE `nameid`="+getarg(0));
+ debugmes "Deleting item %d", getarg(0);
+
+ // Del items which SQL can't reach
+ .@c = getunits(BL_PC, .@players, MAX_CYCLE_PC);
+ for (.@i = 0; .@i < .@c; .@i++) {
+ .@am=countitem(getarg(0), .@players[.@i]);
+ if (.@am) debugmes "DELETE %d items from ACC %d", .@am, .@players[.@i];
+ if (.@am)
+ delitem(getarg(0), .@am, .@players[.@i]);
+ }
+ return;
+}
+
+// Delete an acc_reg entry from all players. Full arrays only. Affect num and str db.
+// WARNING, irreversible and dangerous!
+// DelAccRegFromEveryPlayer( KEY )
+function script DelAccRegFromEveryPlayer {
+ if (getarg(0, "error") == "error")
+ return;
+
+ query_sql("DELETE FROM `acc_reg_num_db` WHERE `key`='"+getarg(0)+"'");
+ query_sql("DELETE FROM `acc_reg_str_db` WHERE `key`='"+getarg(0)+"'");
+
+ if (playerattached())
+ detachrid();
+
+ // Del variables which SQL can't reach
+ .@c = getunits(BL_PC, .@players, MAX_CYCLE_PC);
+ for (.@i = 0; .@i < .@c; .@i++) {
+ attachrid(.@players[.@i]);
+ if (compare(getarg(0), "$"))
+ setd(getarg(0), "");
+ else
+ setd(getarg(0), 0);
+ detachrid();
+ }
+ return;
+}
+
+// Delete an char_reg entry from all players. Full arrays only. Affect num and str db.
+// WARNING, irreversible and dangerous!
+// DelChrRegFromEveryPlayer( KEY )
+function script DelChrRegFromEveryPlayer {
+ if (getarg(0, "error") == "error")
+ return;
+
+ query_sql("DELETE FROM `char_reg_num_db` WHERE `key`='"+getarg(0)+"'");
+ query_sql("DELETE FROM `char_reg_str_db` WHERE `key`='"+getarg(0)+"'");
+
+ // Del variables which SQL can't reach
+ .@c = getunits(BL_PC, .@players, MAX_CYCLE_PC);
+ for (.@i = 0; .@i < .@c; .@i++) {
+ if (compare(getarg(0), "$"))
+ setd(getarg(0), "");
+ else
+ setd(getarg(0), 0);
+ }
+ return;
+}
+
+// Delete a quest entry from all players. This includes all counters. Use with caution.
+// WARNING, irreversible and dangerous!
+// DelQuestFromEveryPlayer( ID )
+function script DelQuestFromEveryPlayer {
+ if (getarg(0, -1) < 0)
+ return;
+
+ query_sql("DELETE FROM `quest` WHERE `quest_id`="+getarg(0));
+
+ // Del quests which SQL can't reach
+ .@a=playerattached();
+ if (.@a) detachrid();
+ .@c = getunits(BL_PC, .@players, MAX_CYCLE_PC);
+ for (.@i = 0; .@i < .@c; .@i++) {
+ attachrid(.@players[.@i]);
+ setq(getarg(0), 0, 0, 0, 0);
+ detachrid();
+ }
+ if (.@a) attachrid(.@a);
+ return;
+}
+
+// Transforms an item in something else.
+// ReplaceItemFromEveryPlayer( OldID, NewID )
+function script ReplaceItemFromEveryPlayer {
+ if (getarg(0, -1) < 0)
+ return;
+ debugmes("* Server update: %d item was replaced by %d", getarg(0), getarg(1));
+ query_sql("UPDATE `inventory` SET `nameid`='"+getarg(1)+"' WHERE `nameid`="+getarg(0));
+ query_sql("UPDATE `cart_inventory` SET `nameid`='"+getarg(1)+"' WHERE `nameid`="+getarg(0));
+ query_sql("UPDATE `storage` SET `nameid`='"+getarg(1)+"' WHERE `nameid`="+getarg(0));
+ query_sql("UPDATE `guild_storage` SET `nameid`='"+getarg(1)+"' WHERE `nameid`="+getarg(0));
+ query_sql("UPDATE `rodex_items` SET `nameid`='"+getarg(1)+"' WHERE `nameid`="+getarg(0));
+ query_sql("UPDATE `auction` SET `nameid`='"+getarg(1)+"' WHERE `nameid`="+getarg(0));
+ return;
+}
+
+// Replaces a skill with another ID.
+// ReplaceSkillFromEveryPlayer( OldID, NewID )
+function script ReplaceSkillFromEveryPlayer {
+ if (getarg(0, -1) < 0)
+ return;
+ debugmes("* Server update: skill %d was replaced by %d", getarg(0), getarg(1));
+ // If new ID already exists, it will skip
+ query_sql("UPDATE IGNORE `skill` SET `id`='"+getarg(1)+"' WHERE `id`="+getarg(0));
+ return;
+}
+