Jump to content
  • 0

R> getareauserid command


GmOcean

Question


  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.01
  • Content Count:  666
  • Reputation:   93
  • Joined:  04/27/12
  • Last Seen:  

Basically I need a command, that acts like the command, *getareausers("<map name>",<x1>,<y1>,<x2>,<y2>);

But instead of returning just the AMOUNT of players in the area, I need it to create an array, of those player's account ID's.

*getareauserid("<map name>",<x1>,<y1>,<x2>,<y2>)
Upon executing this command,

$@areauseraid[0] is a global temporary number array which contains the account id of all users found in the specified area.
$@areausercount is the number of users found in the specified area.

This is basically how it would turn out. (Yes I borrowed the layout used for getpartymember and getguildmember commands).

Edited by GmOcean
Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   381
  • Joined:  02/03/12
  • Last Seen:  

This is basically how it would turn out. (Yes I borrowed the layout used for getpartymember and getguildmember commands).

 

 

Personally I hate it when commands use global variables to store these types of things...

/*==========================================
 *------------------------------------------*/
static int buildin_getareausers_sub(struct block_list *bl,va_list ap)
{
	int *users=va_arg(ap,int *);
	struct map_session_data *sd = (TBL_PC *)bl;
	struct script_state* st;
	st=va_arg(ap,struct script_state*);
	if( *users < 128 )
		setd_sub(st, NULL, ".@account_ids", *users, (void *)__64BPRTSIZE(sd->status.account_id), NULL);
	(*users)++;
	return 0;
}
BUILDIN_FUNC(getareausers)
{
	const char *str;
	int16 m,x0,y0,x1,y1,users=0; //doubt we can have more then 32k users on
	str=script_getstr(st,2);
	x0=script_getnum(st,3);
	y0=script_getnum(st,4);
	x1=script_getnum(st,5);
	y1=script_getnum(st,6);
	if( (m=map_mapname2mapid(str))< 0){
		script_pushint(st,-1);
		return 0;
	}
	map_foreachinarea(buildin_getareausers_sub,
		m,x0,y0,x1,y1,BL_PC,&users,st);
	script_pushint(st,users);
	return 0;
}

NPC Example...

prontera,148,177,5	script	getareausers	100,{
	.@len = getareausers("prontera",148,175,163,164);
	for( .@a = 0; .@a < .@len; .@a++ )
		npctalk ""+.@account_ids[.@a];
	end;
}
  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.01
  • Content Count:  666
  • Reputation:   93
  • Joined:  04/27/12
  • Last Seen:  

Yea, I don't like the global vars either, but seeing as how most already used them, I figured might as well stick with the pattern.

But thanks, I'll try this out later when I get home. And of course I'll post back with my success chance lol.

 

Edit: This works perfectly. I believe with this, I can finally complete my script with a minimal annoyance of having to create duplicate NPCs, now just to figure out a decent algorithm to cycle through them all without getting lost on which one i'm on D:

Edited by GmOcean
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  187
  • Reputation:   7
  • Joined:  09/04/12
  • Last Seen:  

This is basically how it would turn out. (Yes I borrowed the layout used for getpartymember and getguildmember commands).

 

Personally I hate it when commands use global variables to store these types of things...

/*==========================================
 *------------------------------------------*/
static int buildin_getareausers_sub(struct block_list *bl,va_list ap)
{
	int *users=va_arg(ap,int *);
	struct map_session_data *sd = (TBL_PC *)bl;
	struct script_state* st;
	st=va_arg(ap,struct script_state*);
	if( *users < 128 )
		setd_sub(st, NULL, ".@account_ids", *users, (void *)__64BPRTSIZE(sd->status.account_id), NULL);
	(*users)++;
	return 0;
}
BUILDIN_FUNC(getareausers)
{
	const char *str;
	int16 m,x0,y0,x1,y1,users=0; //doubt we can have more then 32k users on
	str=script_getstr(st,2);
	x0=script_getnum(st,3);
	y0=script_getnum(st,4);
	x1=script_getnum(st,5);
	y1=script_getnum(st,6);
	if( (m=map_mapname2mapid(str))< 0){
		script_pushint(st,-1);
		return 0;
	}
	map_foreachinarea(buildin_getareausers_sub,
		m,x0,y0,x1,y1,BL_PC,&users,st);
	script_pushint(st,users);
	return 0;
}

NPC Example...

prontera,148,177,5	script	getareausers	100,{
	.@len = getareausers("prontera",148,175,163,164);
	for( .@a = 0; .@a < .@len; .@a++ )
		npctalk ""+.@account_ids[.@a];
	end;
}

Can you transfer this format let it suit for rathena??

http://hercules.ws/board/topic/4593-getmemberaid-checkmes/

I really want this command...

Link to comment
Share on other sites

  • 0

  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   381
  • Joined:  02/03/12
  • Last Seen:  

 

Can you transfer this format let it suit for rathena??

http://hercules.ws/board/topic/4593-getmemberaid-checkmes/

I really want this command...

 

 

Sorry I didn't get back to you sooner but that command is pretty much a replica of addrid... Except for the BG ability I think. So kinda pointless. x_x

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  141
  • Topics Per Day:  0.03
  • Content Count:  444
  • Reputation:   22
  • Joined:  06/18/12
  • Last Seen:  

Can anyone check this please? I tried to apply it and it doesn't return the account id's of the players. Thanks.

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