Jump to content
  • 0

looking for @itemmap command if anyone still has it


Question

21 answers to this question

Recommended Posts

Posted (edited)

If you can explain what it does, maybe someone can make it for you.

I need to look first on my backup archive if i still have it.. but anyway what it does is it's same with @item command and the syntax is something like this:

@itemmap <map name> <item id/name> <quantity> something like that if i remember it right, I have this on my previous Server got it from eAthena it was posted/modified by Rad Santos but was originally made by Cid *something* I don't remember lol and I'm not quite sure. so what it does is, it gives item to every Player who are on the Map.

well this is a nice Command for giving out Rewards/Gift for your beloved Players :)

Edited by ngek202
Posted (edited)
/*==========================================
* @itemmap
* A way of giving items to all players on a whole map
*------------------------------------------*/
ACMD_FUNC(itemmap)
{
struct map_session_data *pl_sd = NULL;
struct s_mapiterator* iter;
int j;
int pl_GM_level, GM_level;
int map_id = 0;
char map_name[MAP_NAME_LENGTH];
char item_name[100];
int number = 0, item_id, flag;
struct item item_tmp;
struct item_data *item_data;
int get_count, count=0;

memset(item_name, '0', sizeof(item_name));
memset(map_name, '0', sizeof(map_name));


nullpo_retr(-1, sd);


if (!message || !*message)
	return -1;
if(sscanf(message, "%15s "%99[^"]" %d", map_name, item_name, &number) != 3 &&
	sscanf(message, "%15s %99s %d", map_name, item_name, &number) != 3) {
	clif_displaymessage(fd, "Please, enter an item name/id (usage: @itemmap <mapname> <item name or ID> [quantity]).");
	return -1;
}


if (number <= 0)
	number = 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;
}

item_id = item_data->nameid;
get_count = number;
//Check if it's stackable.
if (!itemdb_isstackable2(item_data))
	get_count = 1;

GM_level = pc_isGM(sd);

	if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
		strcat(map_name, ".gat");
	if ((map_id = map_mapname2mapid(map_name)) < 0)
		map_id = sd->bl.m;

iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
{
if (pl_sd->fd != fd && pc_isGM(sd) >= pc_isGM(pl_sd))
{
pl_GM_level = pc_isGM(pl_sd);
		if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
			if (pl_sd->bl.m == map_id) {	// If the player is on the map

for (j = 0; j < number; j += get_count) {
		memset(&item_tmp, 0, sizeof(item_tmp));
		item_tmp.nameid = item_id;
		item_tmp.identify = 1;

		if ((flag = pc_additem(pl_sd, &item_tmp, get_count)))
			clif_additem(pl_sd, 0, 0, flag);

}


				count ++;
				  clif_displaymessage(pl_sd->fd, "Something is falling from the sky."); // Message for all players on the map (can't use "mercy.." because we can use a Support or a Attack skill with @skillmap)
			}
		}
	}
}


snprintf(atcmd_output, sizeof(atcmd_output) ,"You give the item to : %d players.", count);
clif_displaymessage(fd, atcmd_output);	
return 0;
}

Edited by Emistry
Codeboxed Content
  • Upvote 1
Posted (edited)

wow I will try and test this

Thanks Sanasol.

@Sanasol i tried though I end up with 1 error while compiling:

1>c:usersbeedesktopr15503srcmapatcommand.c(2391): error C2198: 'pc_additem' : too few arguments for call

Edited by ngek202
Posted (edited)

I will try it now Sanasol /no1 thanks

Update It's working now I missed a line lol..

I tried repasting it again and it worked

Thank you very much Sanasol.

Edited by ngek202
Posted (edited)

I think because on 3ceam it still use

pc_isGM and GM_level

while on rAthena's current version uses

pc_get_group_level and level

the one I posted is i modified it to work with rAthena's new gm command update.

ok here this should work Sanasol's version I just added the changes he did.

http://pastebin.com/raw.php?i=DYUAe6Ca

Edited by ngek202
Posted
still on your src/map/atcommand.c, find these def lines, and you must add itemmap there.

        ACMD_DEF(unloadnpcfile),
        ACMD_DEF(cart),
-        ACMD_DEF(mount2)
+        ACMD_DEF(mount2),
+        ACMD_DEF(itemmap),
    };
    AtCommandInfo* atcommand;
    int i;

also, check your group.conf's commands.
Posted

here the one I had done:

/*==========================================
* @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
*------------------------------------------*/
ACMD_FUNC(item) {
char item_name[100], string[30];
int number = 0, item_id, flag;
struct item item_tmp;
struct item_data *item_data;
int get_count, i;
int map_id = 0, guildid = 0, partyid = 0, type = 0;
struct s_mapiterator* iter;
TBL_PC *pl_sd;
nullpo_retr(-1, sd);

memset(item_name, '\0', sizeof (item_name));

if (strstr(command, "party") != NULL) { //polymorph [Lighta]
struct party_data *pd;
if (sscanf(message, "%30s %30s %d", string, item_name, &number) < 2) {
clif_displaymessage(fd, "Please, enter an item name/id (usage: @itemparty <partyname> <item name or ID> [quantity])");
return -1;
}
pd = party_searchname(string);
if (pd) partyid = pd->party.party_id;
else if (sd->status.party_id) partyid = sd->status.party_id;
if (!partyid) {
clif_displaymessage(fd, "Party not found!");
return -1;
}
type = 1;
} else if (strstr(command, "guild") != NULL) {
struct guild *g;
if (sscanf(message, "%30s %30s %d", string, item_name, &number) < 2) {
clif_displaymessage(fd, "Please, enter an item name/id (usage: @itemguild <guildname> <item name or ID> [quantity])");
return -1;
}
g = guild_searchname(string);
if (g) guildid = g->guild_id;
else if (sd->status.guild_id) guildid = sd->status.guild_id;
if (!guildid) {
clif_displaymessage(fd, "Guild not found!");
return -1;
}
type = 2;
} else if (strstr(command, "map") != NULL) {
if (sscanf(message, "%30s %30s %d", string, item_name, &number) < 2) {
clif_displaymessage(fd, "Please, enter an item name/id (usage: @itemmap <mapname> <item name or ID> [quantity])");
return -1;
}
if ((map_id = map_mapname2mapid(string)) <= 0) //if map not found take current one
map_id = sd->bl.m;
type = 3;
} else if (!message || !*message || (//normal command
sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1 &&
sscanf(message, "%99s %d", item_name, &number) < 1
)) {
clif_displaymessage(fd, msg_txt(983)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity>).
return -1;
}

if (number <= 0)
number = 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;
}

item_id = item_data->nameid;
get_count = number;
//Check if it's stackable.
if (!itemdb_isstackable2(item_data))
get_count = 1;

iter = mapit_getallusers();
for (pl_sd = (TBL_PC*) mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*) mapit_next(iter)) {
switch (type) {
case 1: //team limited
if (pl_sd->status.party_id != partyid) continue;
break;
case 2: //guild limited
if (pl_sd->status.guild_id != guildid) continue;
break;
case 3:
if (pl_sd->bl.m != map_id) continue;
break;
default:
pl_sd = sd;
}
for (i = 0; i < number; i += get_count) {
// if not pet egg
if (!pet_create_egg(pl_sd, item_id)) {
memset(&item_tmp, 0, sizeof (item_tmp));
item_tmp.nameid = item_id;
item_tmp.identify = 1;

if ((flag = pc_additem(pl_sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
clif_additem(pl_sd, 0, 0, flag);
}
}
if (!type) break; //backward
}
mapit_free(iter);

if (flag == 0)
clif_displaymessage(fd, msg_txt(18)); // Item created.
return 0;
}

There many iterator as you can see, you can use :
@itemmap <mapname> <nameid> <amount>
@itemguild <guildname> <nameid> <amount>
@itemparty <partyname> <nameid> <amount>
and ofc old one :
@item <nameid> <amount>
Posted (edited)

EDIT 2: error showing with the following

 

EDIT3: baaah silly mistake "struct s_map iterator* iter;" should actually be "struct s_mapiterator *iter;" .... >.< rebiuld succeeded 

 

"struct s_map iterator* iter;"


    1    IntelliSense: incomplete type is not allowed    d:\games\***\source\src\map\atcommand.c    1177    14    map-server_sql
    2    IntelliSense: expected a ';'    d:\games\***\source\src\map\atcommand.c    1177    22    map-server_sql
    3    IntelliSense: identifier "iter" is undefined    d:\games\***\source\src\map\atcommand.c    1243    1    map-server_sql

Edited by kamikaze666
Posted
1>d:\rathena\svn\src\map\atcommand.c(1154): warning C4003: not enough actual parameters for macro 'msg_txt'
1>d:\rathena\svn\src\map\atcommand.c(1154): warning C4047: 'function' : 'map_session_data *' differs in levels of indirection from 'int'
1>d:\rathena\svn\src\map\atcommand.c(1154): warning C4024: 'map_msg_txt' : different types for formal and actual parameter 1
1>d:\rathena\svn\src\map\atcommand.c(1154): error C2059: syntax error : ')'
 

Need help!

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...