Quellcode durchsuchen

git-svn-id: https://svn.code.sf.net/p/rathena/svn/branches/stable@600 54d463be-8e91-2dee-dedb-b68131a5f0ec

mc_cameri vor 20 Jahren
Ursprung
Commit
ca2de30c5e
4 geänderte Dateien mit 83 neuen und 1 gelöschten Zeilen
  1. 1 0
      Changelog.txt
  2. 2 1
      conf-tmpl/charcommand_athena.conf
  3. 79 0
      src/map/charcommand.c
  4. 1 0
      src/map/charcommand.h

+ 1 - 0
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]

+ 2 - 1
conf-tmpl/charcommand_athena.conf

@@ -19,4 +19,5 @@ statsall: 40
 spiritball: 60
 itemlist: 40
 effect: 40
-storagelist: 40
+storagelist: 40
+item: 60

+ 79 - 0
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;
+}

+ 1 - 0
src/map/charcommand.h

@@ -15,6 +15,7 @@ enum CharCommandType {
 	CharCommandItemList,
 	CharCommandEffect,
 	CharCommandStorageList,
+	CharCommandItem, // by MC Cameri
 
 #ifdef TXT_ONLY
 /* TXT_ONLY */