Jump to content
  • 0

@itemmap error when compiling


xJhay

Question


  • Group:  Members
  • Topic Count:  14
  • Topics Per Day:  0.01
  • Content Count:  38
  • Reputation:   0
  • Joined:  11/22/16
  • Last Seen:  

Quote

/*==========================================
* @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;
}

I get this error whenever i compile this code. Please help.

Spoiler

server\src\map\atcommand.c(8838): error C2059: syntax error : '^'
server\src\map\atcommand.c(8838): error C2001: newline in constant
server\src\map\atcommand.c(8844): error C2059: syntax error : 'if'
server\src\map\atcommand.c(8847): error C2059: syntax error : 'if'
server\src\map\atcommand.c(8854): error C2065: 'item_data' : undeclared identifier
server\src\map\atcommand.c(8854): error C2223: left of '->nameid' must point to struct/union
server\src\map\atcommand.c(8855): error C2065: 'number' : undeclared identifier
server\src\map\atcommand.c(8855): error C2099: initializer is not a constant
server\src\map\atcommand.c(8857): error C2059: syntax error : 'if'
server\src\map\atcommand.c(8860): error C2065: 'sd' : undeclared identifier
server\src\map\atcommand.c(8860): warning C4047: 'function' : 'map_session_data *' differs in levels of indirection from 'int'
server\src\map\atcommand.c(8860): warning C4024: 'pc_isGM' : different types for formal and actual parameter 1
server\src\map\atcommand.c(8860): error C2099: initializer is not a constant
server\src\map\atcommand.c(8862): error C2059: syntax error : 'if'
server\src\map\atcommand.c(8864): error C2059: syntax error : 'if'
server\src\map\atcommand.c(8867): error C2099: initializer is not a constant
server\src\map\atcommand.c(8868): error C2059: syntax error : 'for'
server\src\map\atcommand.c(8868): error C2371: 'mapit_exists' : redefinition; different basic types
server\src\map\map.h(672) : see declaration of 'mapit_exists'
server\src\map\atcommand.c(8868): warning C4047: 'function' : 's_mapiterator *' differs in levels of indirection from 'int'
server\src\map\atcommand.c(8868): warning C4024: 'mapit_next' : different types for formal and actual parameter 1
server\src\map\atcommand.c(8868): error C2059: syntax error : ')'
server\src\map\atcommand.c(8869): error C2099: initializer is not a constant
server\src\map\atcommand.c(8869): error C2143: syntax error : missing ';' before '{'
server\src\map\atcommand.c(8869): error C2449: found '{' at file scope (missing function header?)
server\src\map\atcommand.c(8892): error C2059: syntax error : '}'
server\src\map\atcommand.c(8897): error C2059: syntax error : 'return'
server\src\map\atcommand.c(8898): error C2059: syntax error : '}'
server\src\map\atcommand.c(9570): error C2065: 'atcommand_itemlist' : undeclared identifier
server\src\map\atcommand.c(9570): error C2099: initializer is not a constant
server\src\map\atcommand.c(9571): error C2065: 'atcommand_itemlist' : undeclared identifier
server\src\map\atcommand.c(9571): error C2099: initializer is not a constant
server\src\map\atcommand.c(9572): error C2065: 'atcommand_itemlist' : undeclared identifier
server\src\map\atcommand.c(9572): error C2099: initializer is not a constant

 

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

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...