summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changelog.txt1
-rw-r--r--conf-tmpl/charcommand_athena.conf3
-rw-r--r--src/map/charcommand.c79
-rw-r--r--src/map/charcommand.h1
4 files changed, 83 insertions, 1 deletions
diff --git a/Changelog.txt b/Changelog.txt
index 22ea619b4..53d018e1a 100644
--- a/Changelog.txt
+++ b/Changelog.txt
@@ -1,5 +1,6 @@
Date Added
12/17
+ * Added #item [MC Cameri]
* Added #storagelist, removed @charstoragelist [MC Cameri]
* db.c: Fixed probs with OnInit, OnTime, and etc NPC probs
Just reverted it back. [Lupus]
diff --git a/conf-tmpl/charcommand_athena.conf b/conf-tmpl/charcommand_athena.conf
index 4fd8a7c20..01c6d451d 100644
--- a/conf-tmpl/charcommand_athena.conf
+++ b/conf-tmpl/charcommand_athena.conf
@@ -19,4 +19,5 @@ statsall: 40
spiritball: 60
itemlist: 40
effect: 40
-storagelist: 40 \ No newline at end of file
+storagelist: 40
+item: 60 \ No newline at end of file
diff --git a/src/map/charcommand.c b/src/map/charcommand.c
index 9ae469b0d..2db2c8e84 100644
--- a/src/map/charcommand.c
+++ b/src/map/charcommand.c
@@ -46,6 +46,7 @@ CCMD_FUNC(spiritball);
CCMD_FUNC(itemlist);
CCMD_FUNC(effect);
CCMD_FUNC(storagelist);
+CCMD_FUNC(item);
#ifdef TXT_ONLY
/* TXT_ONLY */
@@ -78,6 +79,7 @@ static CharCommandInfo charcommand_info[] = {
{ CharCommandItemList, "#itemlist", 40, charcommand_itemlist },
{ CharCommandEffect, "#effect", 40, charcommand_effect },
{ CharCommandStorageList, "#storagelist", 40, charcommand_storagelist },
+ { CharCommandItem, "#item", 60, charcommand_item },
#ifdef TXT_ONLY
/* TXT_ONLY */
@@ -982,3 +984,80 @@ charcommand_storagelist(
return 0;
}
+
+/*==========================================
+ * #item command (usage: #item <name/id_of_item> <quantity> <player>)
+ * by MC Cameri
+ *------------------------------------------
+ */
+int charcommand_item(
+ const int fd, struct map_session_data* sd,
+ const char* command, const char* message)
+{
+ char item_name[100];
+ char character[100];
+ struct map_session_data *pl_sd;
+ int number = 0, item_id, flag;
+ struct item item_tmp;
+ struct item_data *item_data;
+ int get_count, i, pet_id;
+ nullpo_retr(-1, sd);
+
+ memset(item_name, '\0', sizeof(item_name));
+
+ if (!message || !*message || sscanf(message, "%99s %d %99[^\n]", item_name, &number, character) < 3) {
+ clif_displaymessage(fd, "Please, enter an item name/id (usage: #item <item name or ID> <quantity> <char name>).");
+ return -1;
+ }
+
+ if (number <= 0)
+ number = 1;
+
+ item_id = 0;
+ if ((item_data = itemdb_searchname(item_name)) != NULL ||
+ (item_data = itemdb_exists(atoi(item_name))) != NULL)
+ item_id = item_data->nameid;
+
+ if (item_id >= 500) {
+ get_count = number;
+ // check pet egg
+ pet_id = search_petDB_index(item_id, PET_EGG);
+ if (item_data->type == 4 || item_data->type == 5 ||
+ item_data->type == 7 || item_data->type == 8) {
+ get_count = 1;
+ }
+ if ((pl_sd = map_nick2sd(character)) != NULL) {
+ if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can look items only lower or same level
+ for (i = 0; i < number; i += get_count) {
+ // if pet egg
+ if (pet_id >= 0) {
+ sd->catch_target_class = pet_db[pet_id].class;
+ intif_create_pet(sd->status.account_id, sd->status.char_id,
+ pet_db[pet_id].class, mob_db[pet_db[pet_id].class].lv,
+ pet_db[pet_id].EggID, 0, pet_db[pet_id].intimate,
+ 100, 0, 1, pet_db[pet_id].jname);
+ // if not pet egg
+ } else {
+ memset(&item_tmp, 0, sizeof(item_tmp));
+ item_tmp.nameid = item_id;
+ item_tmp.identify = 1;
+ if ((flag = pc_additem((struct map_session_data*)sd, &item_tmp, get_count)))
+ clif_additem((struct map_session_data*)sd, 0, 0, flag);
+ }
+ }
+ clif_displaymessage(fd, msg_table[18]); // Item created.
+ } else {
+ clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
+ return -1;
+ }
+ } else {
+ clif_displaymessage(fd, msg_table[3]); // Character not found.
+ return -1;
+ }
+ } else {
+ clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/src/map/charcommand.h b/src/map/charcommand.h
index b83f2b6e6..0e4992c84 100644
--- a/src/map/charcommand.h
+++ b/src/map/charcommand.h
@@ -15,6 +15,7 @@ enum CharCommandType {
CharCommandItemList,
CharCommandEffect,
CharCommandStorageList,
+ CharCommandItem, // by MC Cameri
#ifdef TXT_ONLY
/* TXT_ONLY */