Jump to content
  • 0

R> getareauserid command


Question

Posted (edited)

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

5 answers to this question

Recommended Posts

  • 0
Posted

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
  • 0
Posted (edited)

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
  • 0
Posted

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

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