Jump to content
  • 0

recallmap command


kamoteka

Question


  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  31
  • Reputation:   0
  • Joined:  08/29/12
  • Last Seen:  

Does anyone know how to add a command wherein i can recall people on certain maps? Please help.

Bump!

Link to comment
Share on other sites

21 answers to this question

Recommended Posts

  • 1

  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  134
  • Reputation:   35
  • Joined:  02/27/12
  • Last Seen:  

Open: src/map/atcommand.c

Find:

/**
* Fills the reference of available commands in atcommand DBMap
**/

Replace with:

ACMD_FUNC(recallmap)
{
short mapindex;
struct map_session_data* pl_sd;
struct s_mapiterator* iter;
int count;

nullpo_retr(-1, sd);
if (!message || !*message){
 clif_displaymessage(fd, msg_txt(909)); // Please enter a map (usage: @recallmap <mapname>).
 return -1;
}

mapindex = map_mapname2mapid(message);

if (mapindex < 0) {
 clif_displaymessage(fd, msg_txt(1)); // Map not found.
 return -1;
}
count = 0;
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
{
 if(pl_sd->bl.m == mapindex)
 {
  if (sd->status.account_id != pl_sd->status.account_id && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  {
   if (map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
 count++;
   else
   {
 if (pc_isdead(pl_sd)) { //Wake them up
  pc_setstand(pl_sd);
  pc_setrestartvalue(pl_sd,1);
 }
  pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
   }
  }
 }
}

mapit_free(iter);
clif_displaymessage(fd, msg_txt(92)); // All characters recalled!
if (count){
 sprintf(atcmd_output, msg_txt(1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled.
 clif_displaymessage(fd, atcmd_output);
}
return 0;
}
/**
* Fills the reference of available commands in atcommand DBMap
**/

Find:

AtCommandInfo atcommand_base[] = {

Replace with:

AtCommandInfo atcommand_base[] = {
 ACMD_DEF(recallmap),

Recompile, you're done.

Edited by MarkZD
  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

dammit ... I totally forgotten there's difference with sd->mapindex and sd->bl.m

atcommand.c

ACMD_FUNC(recallmap) {
char aaa[255];
nullpo_retr(-1, sd);
if ( !message || !*message ) {
	clif_displaymessage( fd, "Please, enter a message (usage: @recallmap <map name>).");
	return -1;
}
if ( map_mapname2mapid(message) < 0 ) {
	clif_displaymessage( fd, "Please, enter a valid map name (usage: @recallmap <map name>).");
	return -1;
}
map_foreachinmap( buildin_recallmap_sub, map_mapname2mapid(message), BL_PC, sd->mapindex, sd->bl.x, sd->bl.y );
sprintf( aaa, "All players from %s has recall to your position", message );
clif_displaymessage( fd, aaa );
return 0;
}
static int buildin_recallmap_sub( struct block_list* bl, va_list ap ) {
struct map_session_data *sd = (struct map_session_data *)bl;
int m = va_arg(ap,int);
int x = va_arg(ap,int);
int y = va_arg(ap,int);
pc_setpos( sd, m, x, y, CLR_TELEPORT );
return 0;
}

ACMD_DEF(recallmap),

atcommand.h

static int buildin_recallmap_sub( struct block_list* bl, va_list ap );

Edited by AnnieRuru
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  31
  • Reputation:   0
  • Joined:  08/29/12
  • Last Seen:  

where should i put this all? is this the only script i need sir?

im having errors sir in atcommand.h

Edited by kamoteka
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

recallmap.diff

no comment ....

EDIT: forgot to remove the debugging message lol

Edited by AnnieRuru
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  134
  • Reputation:   35
  • Joined:  02/27/12
  • Last Seen:  

There's no need to put the atcommand.h part.

I believe the problem is because static functions are local and she is trying to put it global even it beeing local, wich doesn't make sense to the compiler.

Just remove it, and you'll be ok.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

if I remove the atcommand.h part

my visual express pop up this message ..

1>d:\eathena\rathena sql 16819\src\map\atcommand.c(8828): error C2065: 'buildin_recallmap_sub' : undeclared identifier
1>d:\eathena\rathena sql 16819\src\map\atcommand.c(8828): warning C4047: 'function' : 'int (__cdecl *)(block_list *,va_list)' differs in levels of indirection from 'int'
1>d:\eathena\rathena sql 16819\src\map\atcommand.c(8828): warning C4024: 'map_foreachinmap' : different types for formal and actual parameter 1

weird though, I've been doing like this for years

http://www.eathena.w...dpost&p=1500993

and somehow for some default function like buildin_areawarp_sub in script.c doesn't assign in script.h, I've no idea why

Edited by AnnieRuru
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  134
  • Reputation:   35
  • Joined:  02/27/12
  • Last Seen:  

I see, it's because you're using the function as a reference in map_foreachmap.

This struct conversion which may be causing the trouble.

kamoteka, if you still go on getting errors, you just need to change "static int" to "int".

But check again you did it all right, I compiled her code and it passed through VB 2010.(Maybe your compiler is more strict?)

Edited by MarkZD
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

I see, it's because you're using the function as a reference in map_foreachmap.
what is reference .. ? xD

sry but I'm noob in source coding, seriously -> ps . click here lol

what I did is just used my experience in eathena scripting and do cut-copy-paste and make it work /oops

seriously, I'm interested to know why these functions in script.c

buildin_areawarp_sub

buildin_areapercentheal_sub

buildin_announce_sub

and some others don't need to declare them inside script.h, but when I write my own I have to declare in script.h

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  31
  • Reputation:   0
  • Joined:  08/29/12
  • Last Seen:  

still having error

168673572aa20a04c64d9bef3a8239fc7c1f98c2.jpg

Edited by kamoteka
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  


  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  31
  • Reputation:   0
  • Joined:  08/29/12
  • Last Seen:  

still having the same error. i did edit it on notepad.

Edited by kamoteka
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  31
  • Reputation:   0
  • Joined:  08/29/12
  • Last Seen:  

tried it, but it recalled all players. not players on a certain map.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  134
  • Reputation:   35
  • Joined:  02/27/12
  • Last Seen:  

I have paste the wrong piece, I edited it, try again, please.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  31
  • Reputation:   0
  • Joined:  08/29/12
  • Last Seen:  

WORKS! THANK YOU SO MUCH!! /bo/no1/oops

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  134
  • Reputation:   35
  • Joined:  02/27/12
  • Last Seen:  

I edited it again.

It could give a message of users from others maps, not the one chosen, if the user doesn't have permission to recall from there.

Optimized the code, so it will avoid unnecessary checks.

Edited by MarkZD
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

I see, it's because you're using the function as a reference in map_foreachmap.

This struct conversion which may be causing the trouble.

now I'm interested to know what is this struct conversion...

how can his compiler throw error on static int in atcommand.h ... but ours doesn't ?

I just don't understand how kamoteka's compiler can be different from us

and I also know how to do that struct s_mapiterator* iter;

though I will try to avoid using that because it loop through all online users,

just, to me map_foreachinmap looks more optimized

@kamoteka,

can you tell what kind of compiler you are using ?

then I'll avoid writing this map_foreachinmap or map_foreachpc for future reference

Edited by AnnieRuru
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  134
  • Reputation:   35
  • Joined:  02/27/12
  • Last Seen:  

When I say struct conversion, I'm referring about this:

struct map_session_data *sd = (struct map_session_data *)bl;

bl is a block_list struct but you're saying you want it as a map_session_data struct, I don't know really what will happen, but if this works it should only if both structs are equal or they have same members used in the next steps.

and I also know how to do that struct s_mapiterator* iter;

though I will try to avoid using that because it loop through all online users,

just, to me map_foreachinmap looks more optimized

I knew it, but as I saw it was simpler to the moment, I used it and I give a little optimized by comparing as soon as possible the user_map with the said map to avoid unnecessary checks.

And with the current source, I think it's the only way to do it.

You don't have to worry so much, You can verify thousand of users(maybe millions or more, depends on PC) with this way in a second.

There's a lot of compilers, he's probably using GCC.

Edited by MarkZD
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

I'm noob in C, but from what I understand

sd->bl.m

bl means block list

since pc_setpos asked for sd, I called it back to the family

I copy-paste it from skill.c line 14165

int skill_frostjoke_scream (struct block_list *bl, va_list ap)
.......
if (bl->type == BL_PC) {
	struct map_session_data *sd = (struct map_session_data *)bl;
	if ( sd && sd->sc.option&(OPTION_INVISIBLE|OPTION_MADOGEAR) )
		return 0;//Frost Joke / Scream cannot target invisible or MADO Gear characters [ind]
}

There's a lot of compilers, he's probably using GCC.
thx, I'll keep that in mind :meow: Edited by AnnieRuru
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  75
  • Topics Per Day:  0.02
  • Content Count:  2223
  • Reputation:   593
  • Joined:  10/26/11
  • Last Seen:  

Here's another @maprecall: http://trac.assembla.../changeset/121/

4 years old ... it might have to be edited a little to work with the current rAthena.

seriously, I'm interested to know why these functions in script.c

buildin_areawarp_sub

buildin_areapercentheal_sub

buildin_announce_sub

and some others don't need to declare them inside script.h, but when I write my own I have to declare in script.h

Did you put your new @command or script command before those functions are declared in atcommand.c or script.c ?

If you try to use buildin_areawarp_sub before it's declared, that would cause an error.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

http://www.eathena.w...dpost&p=1459658

ROFL !!

now only I know THIS is already a famous modification ... I thought he was asking for something new .... lol

Did you put your new @command or script command before those functions are declared in atcommand.c or script.c ?

If you try to use buildin_areawarp_sub before it's declared, that would cause an error.

:ani_swt3: now I feel like a noob ... xD

int buildin_recallmap_sub( struct block_list* bl, va_list ap ) {
struct map_session_data *sd = (struct map_session_data *)bl;
int m = va_arg(ap,int);
int x = va_arg(ap,int);
int y = va_arg(ap,int);
pc_setpos( sd, m, x, y, CLR_TELEPORT );
return 0;
}
ACMD_FUNC(recallmap) {
int m; char aaa[255];
nullpo_retr(-1, sd);
if ( !message || !*message )
	m = sd->bl.m;
else if ( ( m = map_mapname2mapid(message) ) < 0 ) {
	clif_displaymessage( fd, "Please, enter a valid map name (usage: @recallmap <map name>).");
	return -1;
}
if ( map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE) ) {
	clif_displaymessage( fd, "You are not allow to use this command on this map" ); // somehow I feel this command should only be use by GMs
	return -1;
}
map_foreachinmap( buildin_recallmap_sub, m, BL_PC, sd->mapindex, sd->bl.x, sd->bl.y );
sprintf( aaa, "All players from %s has recall to your position", mapindex_id2name( map[m].index ) );
clif_displaymessage( fd, aaa );
return 0;
}

that wake them up is not needed because now pc_setpos will revive them automatically

http://www.eathena.ws/board/index.php?autocom=bugtracker&showbug=3227

Edited by AnnieRuru
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  134
  • Reputation:   35
  • Joined:  02/27/12
  • Last Seen:  

Did you put your new @command or script command before those functions are declared in atcommand.c or script.c ?

If you try to use buildin_areawarp_sub before it's declared, that would cause an error.

i'd say that, but as I tested it and it worked, and because of C language allowing it I discarded.

It's probably because his compiler is too old or because of the script engine?

But it's possible, it's the error cause though. ;D

Edited by MarkZD
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...