Jump to content
  • 0

Can someone help me for this itemmap patch


Cyborg

Question


  • Group:  Members
  • Topic Count:  14
  • Topics Per Day:  0.01
  • Content Count:  54
  • Reputation:   1
  • Joined:  07/19/18
  • Last Seen:  

i have a error for recompile i do no why missing here a code o simbol

can you help me to fix it

edrSUEX.jpg

itemmap diff patch

Index: doc/sample/npc_getitem_map.txt
===================================================================
--- doc/sample/npc_getitem_map.txt	(revision 0)
+++ doc/sample/npc_getitem_map.txt	(working copy)
@@ -0,0 +1,24 @@
+// Sample NPC to test the custom getitem_map script command
+// Script and command created by Xantara
+prontera,156,170,3	script	getitem_map test	120,{
+	mes "input item id";
+	next;
+	input .@id;
+	mes "input item amount";
+	next;
+	input .@amt;
+	mes "input type:";
+	mes "0=everyone, 1=party, 2=guild 3=bg";
+	next;
+	input .@t;
+	//getitem_map .@id,.@amt,strcharinfo(3),.@t,((.@t==1) ? getcharid(1) : (.@t==2) ? getcharid(2) : getcharid(4));
+	switch(.@t)
+	{
+		case 1:	set .@type_id, getcharid(1);	break;
+		case 2:	set .@type_id, getcharid(2);	break;
+		case 3:	set .@type_id, getcharid(4);	break;
+	}
+	getitem_map .@id,.@amt,strcharinfo(3),.@t,.@type_id;
+	mes "done";
+	close;
+}
Index: doc/sample/npc_getitem_map.txt
===================================================================
--- doc/sample/npc_getitem_map.txt	(revision 0)
+++ doc/sample/npc_getitem_map.txt	(working copy)

Property changes on: doc/sample/npc_getitem_map.txt
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: doc/script_commands.txt
===================================================================
--- doc/script_commands.txt	(revision 17062)
+++ doc/script_commands.txt	(working copy)
@@ -4259,6 +4259,34 @@
 
 ---------------------------------------
 
+*getitem_map <item id>,<amount>,"<mapname>"{,<type>,<ID for Type>};
+
+This command will give a specific amount of specified items to the players on the specified map. 
+
+Works similarly to getitem but for multiple players on certain map.
+Negative ID numbers also apply. However item name is currently not supported.
+
+Those parameters that are different from 'getitem' are:
+	mapname     - Map name of the players to give the item(s) too
+	type        - Optional.
+				  Type	0 = everyone on the map (default) 
+						1 = specific party and their members on the map
+						2 = specific guild and their members on the map
+						3 = specific battleground team and their members on the map
+	ID for Type - Only needed if type is not 0
+				  If type = 1, ID is Party ID
+				  If type = 2, ID is Guild ID
+				  If type = 3, ID is Battleground ID
+
+If type is given, party members who are offline or are not on the specific map do not get the item.
+Same for guild members. If BG ID is not found, it will not give to any players.
+
+This transaction is logged if the log script generated transactions option is enabled.
+
+Created by Xantara
+
+---------------------------------------
+
 *getnameditem <item id>,<character name|character ID>;
 *getnameditem "<item name>",<character name|character ID>;
 
Index: src/map/atcommand.c
===================================================================
--- src/map/atcommand.c	(revision 17062)
+++ src/map/atcommand.c	(working copy)
@@ -1297,8 +1297,117 @@
 }
 
 /*==========================================
- *
+ * 0 = @itemmap <item id/name> {<amount>}
+ * 1 = @itemmap1 <item id/name> <amount>, <party name>
+ * 2 = @itemmap2 <item id/name> <amount>, <guild name>
+ * [Xantara]
  *------------------------------------------*/
+ACMD_FUNC(itemmap)
+{
+	char item_name[100], party_name[NAME_LENGTH], guild_name[NAME_LENGTH];
+	int amount, get_type = 0, flag = 0, get_count, i, map;
+	struct item it;
+	struct item_data *item_data;
+	struct party_data *p;
+	struct guild *g;
+	struct s_mapiterator *iter = NULL;
+	struct map_session_data *pl_sd = NULL;
+
+	nullpo_retr(-1, sd);
+	
+	memset(item_name, '\0', sizeof(item_name));
+	memset(party_name, '\0', sizeof(party_name));
+	memset(guild_name, '\0', sizeof(guild_name));
+
+	if (strstr(command, "1") != NULL)
+		get_type = 1;
+	else if (strstr(command, "2") != NULL)
+		get_type = 2;
+
+	if (!message || !*message || 
+		get_type == 0 && sscanf(message, "\"%99[^\"]\" %d", item_name, &amount) < 1 
+					  && sscanf(message, "%99s %d", item_name, &amount) < 1 )
+	{
+		clif_displaymessage(fd, "Please, enter an item name/id (usage: @itemmap <item name or ID> {amount}).");
+		return -1;
+	}
+	if ( get_type == 1 && sscanf(message, "\"%99[^\"]\" %d, %23[^\n]", item_name, &amount, party_name) < 2 
+					   && sscanf(message, "%99s %d, %23[^\n]", item_name, &amount, party_name) < 2 )
+	{
+		clif_displaymessage(fd, "Please, enter an item name/id (usage: @itemmap1 <item id/name> <amount>, <party name>).");
+		return -1;
+	}
+	if ( get_type == 2 && sscanf(message, "\"%99[^\"]\" %d, %23[^\n]", item_name, &amount, guild_name) < 2 
+					   && sscanf(message, "%99s %d, %23[^\n]", item_name, &amount, guild_name) < 2 )
+	{
+		clif_displaymessage(fd, "Please, enter an item name/id (usage: @itemmap2 <item id/name> <amount>, <guild name>).");
+		return -1;
+	}
+
+	if ((item_data = itemdb_searchname(item_name)) == NULL &&
+	    (item_data = itemdb_exists(atoi(item_name))) == NULL)
+	{
+		clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
+		return -1;
+	}
+
+	if (amount <= 0)
+		amount = 1;	
+
+	map = sd->bl.m;
+	
+	memset(&it,0,sizeof(it));
+	it.nameid = item_data->nameid;
+	if(!flag)
+		it.identify = 1;
+	else
+		it.identify = itemdb_isidentified(item_data->nameid);
+
+	if (!itemdb_isstackable(item_data->nameid))
+		get_count = 1;
+	else
+		get_count = amount;
+
+	switch(get_type)
+	{
+		case 1:
+			if( (p = party_searchname(party_name)) == NULL )
+			{
+				clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
+				return -1;
+			}
+			for( i=0; i < MAX_PARTY; i++ )
+				if( p->data[i].sd && map == p->data[i].sd->bl.m )
+					pc_getitem_map(p->data[i].sd,it,amount,get_count,LOG_TYPE_COMMAND);
+			break;
+		case 2:
+			if( (g = guild_searchname(guild_name)) == NULL )
+			{
+				clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
+				return -1;
+			}
+			for( i=0; i < g->max_member; i++ )
+				if( g->member[i].sd && map == g->member[i].sd->bl.m )
+					pc_getitem_map(g->member[i].sd,it,amount,get_count,LOG_TYPE_COMMAND);
+			break;
+		default:
+			iter = mapit_getallusers();
+			for (pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter)) {
+				if( map != pl_sd->bl.m )
+					continue;
+				pc_getitem_map(pl_sd,it,amount,get_count,LOG_TYPE_COMMAND);
+			}
+			mapit_free(iter);
+			break;
+	}
+
+	clif_displaymessage(fd, msg_txt(18)); // Item created.
+	return 0;
+}
+
+/*==========================================
+ * itemreset
+ *------------------------------------------*/
 ACMD_FUNC(itemreset)
 {
 	int i;
@@ -8849,6 +8958,10 @@
 		ACMD_DEF(heal),
 		ACMD_DEF(item),
 		ACMD_DEF(item2),
+		ACMD_DEF(itemmap),
+		ACMD_DEF2("itemmap1", itemmap),
+		ACMD_DEF2("itemmap2", itemmap),
+		ACMD_DEF2("itemmap3", itemmap),
 		ACMD_DEF(itemreset),
 		ACMD_DEF(clearstorage),
 		ACMD_DEF(cleargstorage),
Index: src/map/pc.c
===================================================================
--- src/map/pc.c	(revision 17062)
+++ src/map/pc.c	(working copy)
@@ -4009,6 +4009,32 @@
 	return 1;
 }
 
+/*------------------------------------------
+ * pc_getitem_map [Xantara]
+ *------------------------------------------*/
+int pc_getitem_map(struct map_session_data *sd,struct item it,int amt,int count,e_log_pick_type log_type)
+{
+	int i, flag;
+
+	nullpo_ret(sd);
+
+	for ( i = 0; i < amt; i += count )
+	{
+		if ( !pet_create_egg(sd,it.nameid) )
+		{ // if not pet egg
+			if ( flag = pc_additem(sd,&it,count,log_type) )
+			{
+				clif_additem(sd, 0, 0, flag);
+				if( pc_candrop(sd,&it) )
+					map_addflooritem(&it,count,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
+			}
+		}
+	}
+
+	log_pick_pc(sd, log_type, -amt, &sd->status.inventory[i]);
+	return 1;
+}
+
 /*==========================================
  * Check if item is usable.
  * Return:
  
Index: src/map/pc.h
===================================================================
--- src/map/pc.h	(revision 17062)
+++ src/map/pc.h	(working copy)
@@ -725,6 +725,7 @@
 int pc_putitemtocart(struct map_session_data *sd,int idx,int amount);
 int pc_getitemfromcart(struct map_session_data *sd,int idx,int amount);
 int pc_cartitem_amount(struct map_session_data *sd,int idx,int amount);
+int pc_getitem_map(struct map_session_data *sd,struct item it,int amt,int count,e_log_pick_type log_type); // [Xantara]
 
 int pc_takeitem(struct map_session_data*,struct flooritem_data*);
 int pc_dropitem(struct map_session_data*,int,int);
 
Index: src/map/script.c
===================================================================
--- src/map/script.c	(revision 17062)
+++ src/map/script.c	(working copy)
@@ -6474,6 +6474,122 @@
 	return 0;
 }
 
+/*====================================================================
+  [Xantara]
+     *getitem_map <item id>,<amount>,"<mapname>"{,<type>,<ID for Type>};
+       type: 0=everyone, 1=party, 2=guild, 3=bg
+ =====================================================================*/
+static int buildin_getitem_map_sub(struct block_list *bl,va_list ap)
+{
+	struct item it;
+	struct guild *g = NULL;
+	struct party_data *p = NULL;
+
+	int amt,count;
+	TBL_PC *sd = (TBL_PC *)bl;
+
+	it    = va_arg(ap,struct item);
+	amt   = va_arg(ap,int);
+	count = va_arg(ap,int);
+
+	pc_getitem_map(sd,it,amt,count,LOG_TYPE_SCRIPT);
+
+	return 0;
+}
+
+BUILDIN_FUNC(getitem_map)
+{
+	struct item it;
+	struct guild *g = NULL;
+	struct party_data *p = NULL;
+	struct battleground_data *bg = NULL;
+	struct script_data *data;
+
+	int m,i,get_count,nameid,amount,flag=0,type=0,type_id=0;
+	const char *mapname;
+
+	data = script_getdata(st,2);
+	get_val(st,data);
+	if( data_isstring(data) )
+	{
+		const char *name = conv_str(st,data);
+		struct item_data *item_data = itemdb_searchname(name);
+		if( item_data )
+			nameid = item_data->nameid;
+		else
+			nameid = UNKNOWN_ITEM_ID;
+	}
+	else
+		nameid = conv_num(st,data);
+
+	if( (amount = script_getnum(st,3)) <= 0 )
+		return 0;
+
+	mapname = script_getstr(st,4);
+	if( (m = map_mapname2mapid(mapname)) < 0 )
+		return 0;
+
+	if( script_hasdata(st,5) ){
+		type    = script_getnum(st,5);
+		type_id = script_getnum(st,6);
+	}
+
+	if(nameid < 0) {
+		nameid = itemdb_searchrandomid(-nameid);
+		flag = 1;
+	}
+	
+	if( nameid <= 0 || !itemdb_exists(nameid) ){
+		ShowError("buildin_getitem_map: Nonexistant item %d requested.\n", nameid);
+		return 1; //No item created.
+	}
+
+	memset(&it,0,sizeof(it));
+	it.nameid = nameid;
+	if(!flag)
+		it.identify = 1;
+	else
+		it.identify = itemdb_isidentified(nameid);
+
+	if (!itemdb_isstackable(nameid))
+		get_count = 1;
+	else
+		get_count = amount;
+
+	switch(type)
+	{
+		case 1:
+			if( (p = party_search(type_id)) != NULL )
+			{
+				for( i=0; i < MAX_PARTY; i++ )
+					if( p->data[i].sd && m == p->data[i].sd->bl.m )
+						pc_getitem_map(p->data[i].sd,it,amount,get_count,LOG_TYPE_SCRIPT);
+			}
+			break;
+		case 2:
+			if( (g = guild_search(type_id)) != NULL )
+			{
+				for( i=0; i < g->max_member; i++ )
+					if( g->member[i].sd && m == g->member[i].sd->bl.m )
+						pc_getitem_map(g->member[i].sd,it,amount,get_count,LOG_TYPE_SCRIPT);
+			}
+			break;
+		case 3:
+			if( (bg = bg_team_search(type_id)) != NULL )
+			{
+				for( i=0; i < MAX_BG_MEMBERS; i++ )
+					if( bg->members[i].sd && m == bg->members[i].sd->bl.m )
+						pc_getitem_map(bg->members[i].sd,it,amount,get_count,LOG_TYPE_SCRIPT);
+			}
+			break;
+		default:
+			map_foreachinmap(buildin_getitem_map_sub,m,BL_PC,it,amount,get_count);
+			break;
+	}
+
+	return 0;
+}
+
 /*==========================================
  * rentitem <item id>,<seconds>
  * rentitem "<item name>",<seconds>
@@ -17364,6 +17480,7 @@
 	BUILDIN_DEF(getitem,"vi?"),
 	BUILDIN_DEF(rentitem,"vi"),
 	BUILDIN_DEF(getitem2,"viiiiiiii?"),
+	BUILDIN_DEF(getitem_map,"iis??"),
 	BUILDIN_DEF(getnameditem,"vv"),
 	BUILDIN_DEF2(grouprandomitem,"groupranditem","i"),
 	BUILDIN_DEF(makeitem,"visii"),

 

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  49
  • Topics Per Day:  0.01
  • Content Count:  1540
  • Reputation:   238
  • Joined:  08/03/12
  • Last Seen:  

6 hours ago, Cyborg said:

i have a error for recompile i do no why missing here a code o simbol

can you help me to fix it

edrSUEX.jpg

itemmap diff patch

Index: doc/sample/npc_getitem_map.txt
===================================================================
--- doc/sample/npc_getitem_map.txt	(revision 0)
+++ doc/sample/npc_getitem_map.txt	(working copy)
@@ -0,0 +1,24 @@
+// Sample NPC to test the custom getitem_map script command
+// Script and command created by Xantara
+prontera,156,170,3	script	getitem_map test	120,{
+	mes "input item id";
+	next;
+	input .@id;
+	mes "input item amount";
+	next;
+	input .@amt;
+	mes "input type:";
+	mes "0=everyone, 1=party, 2=guild 3=bg";
+	next;
+	input .@t;
+	//getitem_map .@id,.@amt,strcharinfo(3),.@t,((.@t==1) ? getcharid(1) : (.@t==2) ? getcharid(2) : getcharid(4));
+	switch(.@t)
+	{
+		case 1:	set .@type_id, getcharid(1);	break;
+		case 2:	set .@type_id, getcharid(2);	break;
+		case 3:	set .@type_id, getcharid(4);	break;
+	}
+	getitem_map .@id,.@amt,strcharinfo(3),.@t,.@type_id;
+	mes "done";
+	close;
+}
Index: doc/sample/npc_getitem_map.txt
===================================================================
--- doc/sample/npc_getitem_map.txt	(revision 0)
+++ doc/sample/npc_getitem_map.txt	(working copy)

Property changes on: doc/sample/npc_getitem_map.txt
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: doc/script_commands.txt
===================================================================
--- doc/script_commands.txt	(revision 17062)
+++ doc/script_commands.txt	(working copy)
@@ -4259,6 +4259,34 @@
 
 ---------------------------------------
 
+*getitem_map <item id>,<amount>,"<mapname>"{,<type>,<ID for Type>};
+
+This command will give a specific amount of specified items to the players on the specified map. 
+
+Works similarly to getitem but for multiple players on certain map.
+Negative ID numbers also apply. However item name is currently not supported.
+
+Those parameters that are different from 'getitem' are:
+	mapname     - Map name of the players to give the item(s) too
+	type        - Optional.
+				  Type	0 = everyone on the map (default) 
+						1 = specific party and their members on the map
+						2 = specific guild and their members on the map
+						3 = specific battleground team and their members on the map
+	ID for Type - Only needed if type is not 0
+				  If type = 1, ID is Party ID
+				  If type = 2, ID is Guild ID
+				  If type = 3, ID is Battleground ID
+
+If type is given, party members who are offline or are not on the specific map do not get the item.
+Same for guild members. If BG ID is not found, it will not give to any players.
+
+This transaction is logged if the log script generated transactions option is enabled.
+
+Created by Xantara
+
+---------------------------------------
+
 *getnameditem <item id>,<character name|character ID>;
 *getnameditem "<item name>",<character name|character ID>;
 
Index: src/map/atcommand.c
===================================================================
--- src/map/atcommand.c	(revision 17062)
+++ src/map/atcommand.c	(working copy)
@@ -1297,8 +1297,117 @@
 }
 
 /*==========================================
- *
+ * 0 = @itemmap <item id/name> {<amount>}
+ * 1 = @itemmap1 <item id/name> <amount>, <party name>
+ * 2 = @itemmap2 <item id/name> <amount>, <guild name>
+ * [Xantara]
  *------------------------------------------*/
+ACMD_FUNC(itemmap)
+{
+	char item_name[100], party_name[NAME_LENGTH], guild_name[NAME_LENGTH];
+	int amount, get_type = 0, flag = 0, get_count, i, map;
+	struct item it;
+	struct item_data *item_data;
+	struct party_data *p;
+	struct guild *g;
+	struct s_mapiterator *iter = NULL;
+	struct map_session_data *pl_sd = NULL;
+
+	nullpo_retr(-1, sd);
+	
+	memset(item_name, '\0', sizeof(item_name));
+	memset(party_name, '\0', sizeof(party_name));
+	memset(guild_name, '\0', sizeof(guild_name));
+
+	if (strstr(command, "1") != NULL)
+		get_type = 1;
+	else if (strstr(command, "2") != NULL)
+		get_type = 2;
+
+	if (!message || !*message || 
+		get_type == 0 && sscanf(message, "\"%99[^\"]\" %d", item_name, &amount) < 1 
+					  && sscanf(message, "%99s %d", item_name, &amount) < 1 )
+	{
+		clif_displaymessage(fd, "Please, enter an item name/id (usage: @itemmap <item name or ID> {amount}).");
+		return -1;
+	}
+	if ( get_type == 1 && sscanf(message, "\"%99[^\"]\" %d, %23[^\n]", item_name, &amount, party_name) < 2 
+					   && sscanf(message, "%99s %d, %23[^\n]", item_name, &amount, party_name) < 2 )
+	{
+		clif_displaymessage(fd, "Please, enter an item name/id (usage: @itemmap1 <item id/name> <amount>, <party name>).");
+		return -1;
+	}
+	if ( get_type == 2 && sscanf(message, "\"%99[^\"]\" %d, %23[^\n]", item_name, &amount, guild_name) < 2 
+					   && sscanf(message, "%99s %d, %23[^\n]", item_name, &amount, guild_name) < 2 )
+	{
+		clif_displaymessage(fd, "Please, enter an item name/id (usage: @itemmap2 <item id/name> <amount>, <guild name>).");
+		return -1;
+	}
+
+	if ((item_data = itemdb_searchname(item_name)) == NULL &&
+	    (item_data = itemdb_exists(atoi(item_name))) == NULL)
+	{
+		clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
+		return -1;
+	}
+
+	if (amount <= 0)
+		amount = 1;	
+
+	map = sd->bl.m;
+	
+	memset(&it,0,sizeof(it));
+	it.nameid = item_data->nameid;
+	if(!flag)
+		it.identify = 1;
+	else
+		it.identify = itemdb_isidentified(item_data->nameid);
+
+	if (!itemdb_isstackable(item_data->nameid))
+		get_count = 1;
+	else
+		get_count = amount;
+
+	switch(get_type)
+	{
+		case 1:
+			if( (p = party_searchname(party_name)) == NULL )
+			{
+				clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
+				return -1;
+			}
+			for( i=0; i < MAX_PARTY; i++ )
+				if( p->data[i].sd && map == p->data[i].sd->bl.m )
+					pc_getitem_map(p->data[i].sd,it,amount,get_count,LOG_TYPE_COMMAND);
+			break;
+		case 2:
+			if( (g = guild_searchname(guild_name)) == NULL )
+			{
+				clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
+				return -1;
+			}
+			for( i=0; i < g->max_member; i++ )
+				if( g->member[i].sd && map == g->member[i].sd->bl.m )
+					pc_getitem_map(g->member[i].sd,it,amount,get_count,LOG_TYPE_COMMAND);
+			break;
+		default:
+			iter = mapit_getallusers();
+			for (pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter)) {
+				if( map != pl_sd->bl.m )
+					continue;
+				pc_getitem_map(pl_sd,it,amount,get_count,LOG_TYPE_COMMAND);
+			}
+			mapit_free(iter);
+			break;
+	}
+
+	clif_displaymessage(fd, msg_txt(18)); // Item created.
+	return 0;
+}
+
+/*==========================================
+ * itemreset
+ *------------------------------------------*/
 ACMD_FUNC(itemreset)
 {
 	int i;
@@ -8849,6 +8958,10 @@
 		ACMD_DEF(heal),
 		ACMD_DEF(item),
 		ACMD_DEF(item2),
+		ACMD_DEF(itemmap),
+		ACMD_DEF2("itemmap1", itemmap),
+		ACMD_DEF2("itemmap2", itemmap),
+		ACMD_DEF2("itemmap3", itemmap),
 		ACMD_DEF(itemreset),
 		ACMD_DEF(clearstorage),
 		ACMD_DEF(cleargstorage),
Index: src/map/pc.c
===================================================================
--- src/map/pc.c	(revision 17062)
+++ src/map/pc.c	(working copy)
@@ -4009,6 +4009,32 @@
 	return 1;
 }
 
+/*------------------------------------------
+ * pc_getitem_map [Xantara]
+ *------------------------------------------*/
+int pc_getitem_map(struct map_session_data *sd,struct item it,int amt,int count,e_log_pick_type log_type)
+{
+	int i, flag;
+
+	nullpo_ret(sd);
+
+	for ( i = 0; i < amt; i += count )
+	{
+		if ( !pet_create_egg(sd,it.nameid) )
+		{ // if not pet egg
+			if ( flag = pc_additem(sd,&it,count,log_type) )
+			{
+				clif_additem(sd, 0, 0, flag);
+				if( pc_candrop(sd,&it) )
+					map_addflooritem(&it,count,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
+			}
+		}
+	}
+
+	log_pick_pc(sd, log_type, -amt, &sd->status.inventory[i]);
+	return 1;
+}
+
 /*==========================================
  * Check if item is usable.
  * Return:
  
Index: src/map/pc.h
===================================================================
--- src/map/pc.h	(revision 17062)
+++ src/map/pc.h	(working copy)
@@ -725,6 +725,7 @@
 int pc_putitemtocart(struct map_session_data *sd,int idx,int amount);
 int pc_getitemfromcart(struct map_session_data *sd,int idx,int amount);
 int pc_cartitem_amount(struct map_session_data *sd,int idx,int amount);
+int pc_getitem_map(struct map_session_data *sd,struct item it,int amt,int count,e_log_pick_type log_type); // [Xantara]
 
 int pc_takeitem(struct map_session_data*,struct flooritem_data*);
 int pc_dropitem(struct map_session_data*,int,int);
 
Index: src/map/script.c
===================================================================
--- src/map/script.c	(revision 17062)
+++ src/map/script.c	(working copy)
@@ -6474,6 +6474,122 @@
 	return 0;
 }
 
+/*====================================================================
+  [Xantara]
+     *getitem_map <item id>,<amount>,"<mapname>"{,<type>,<ID for Type>};
+       type: 0=everyone, 1=party, 2=guild, 3=bg
+ =====================================================================*/
+static int buildin_getitem_map_sub(struct block_list *bl,va_list ap)
+{
+	struct item it;
+	struct guild *g = NULL;
+	struct party_data *p = NULL;
+
+	int amt,count;
+	TBL_PC *sd = (TBL_PC *)bl;
+
+	it    = va_arg(ap,struct item);
+	amt   = va_arg(ap,int);
+	count = va_arg(ap,int);
+
+	pc_getitem_map(sd,it,amt,count,LOG_TYPE_SCRIPT);
+
+	return 0;
+}
+
+BUILDIN_FUNC(getitem_map)
+{
+	struct item it;
+	struct guild *g = NULL;
+	struct party_data *p = NULL;
+	struct battleground_data *bg = NULL;
+	struct script_data *data;
+
+	int m,i,get_count,nameid,amount,flag=0,type=0,type_id=0;
+	const char *mapname;
+
+	data = script_getdata(st,2);
+	get_val(st,data);
+	if( data_isstring(data) )
+	{
+		const char *name = conv_str(st,data);
+		struct item_data *item_data = itemdb_searchname(name);
+		if( item_data )
+			nameid = item_data->nameid;
+		else
+			nameid = UNKNOWN_ITEM_ID;
+	}
+	else
+		nameid = conv_num(st,data);
+
+	if( (amount = script_getnum(st,3)) <= 0 )
+		return 0;
+
+	mapname = script_getstr(st,4);
+	if( (m = map_mapname2mapid(mapname)) < 0 )
+		return 0;
+
+	if( script_hasdata(st,5) ){
+		type    = script_getnum(st,5);
+		type_id = script_getnum(st,6);
+	}
+
+	if(nameid < 0) {
+		nameid = itemdb_searchrandomid(-nameid);
+		flag = 1;
+	}
+	
+	if( nameid <= 0 || !itemdb_exists(nameid) ){
+		ShowError("buildin_getitem_map: Nonexistant item %d requested.\n", nameid);
+		return 1; //No item created.
+	}
+
+	memset(&it,0,sizeof(it));
+	it.nameid = nameid;
+	if(!flag)
+		it.identify = 1;
+	else
+		it.identify = itemdb_isidentified(nameid);
+
+	if (!itemdb_isstackable(nameid))
+		get_count = 1;
+	else
+		get_count = amount;
+
+	switch(type)
+	{
+		case 1:
+			if( (p = party_search(type_id)) != NULL )
+			{
+				for( i=0; i < MAX_PARTY; i++ )
+					if( p->data[i].sd && m == p->data[i].sd->bl.m )
+						pc_getitem_map(p->data[i].sd,it,amount,get_count,LOG_TYPE_SCRIPT);
+			}
+			break;
+		case 2:
+			if( (g = guild_search(type_id)) != NULL )
+			{
+				for( i=0; i < g->max_member; i++ )
+					if( g->member[i].sd && m == g->member[i].sd->bl.m )
+						pc_getitem_map(g->member[i].sd,it,amount,get_count,LOG_TYPE_SCRIPT);
+			}
+			break;
+		case 3:
+			if( (bg = bg_team_search(type_id)) != NULL )
+			{
+				for( i=0; i < MAX_BG_MEMBERS; i++ )
+					if( bg->members[i].sd && m == bg->members[i].sd->bl.m )
+						pc_getitem_map(bg->members[i].sd,it,amount,get_count,LOG_TYPE_SCRIPT);
+			}
+			break;
+		default:
+			map_foreachinmap(buildin_getitem_map_sub,m,BL_PC,it,amount,get_count);
+			break;
+	}
+
+	return 0;
+}
+
 /*==========================================
  * rentitem <item id>,<seconds>
  * rentitem "<item name>",<seconds>
@@ -17364,6 +17480,7 @@
 	BUILDIN_DEF(getitem,"vi?"),
 	BUILDIN_DEF(rentitem,"vi"),
 	BUILDIN_DEF(getitem2,"viiiiiiii?"),
+	BUILDIN_DEF(getitem_map,"iis??"),
 	BUILDIN_DEF(getnameditem,"vv"),
 	BUILDIN_DEF2(grouprandomitem,"groupranditem","i"),
 	BUILDIN_DEF(makeitem,"visii"),

 

I think itemmap got some script that doesnt need to use src.

 

Ahh .. from my post 2015. Maybe can try but I think need some modification since its from 2015.
 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  14
  • Topics Per Day:  0.01
  • Content Count:  54
  • Reputation:   1
  • Joined:  07/19/18
  • Last Seen:  

9 hours ago, Chaos92 said:

I think itemmap got some script that doesnt need to use src.

 

Ahh .. from my post 2015. Maybe can try but I think need some modification since its from 2015.
 

thanks for help me but I need this in src because I have a script that needs this patch code

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...