Jump to content
  • 0

Modifying @warp command


Meister

Question


  • Group:  Members
  • Topic Count:  280
  • Topics Per Day:  0.06
  • Content Count:  841
  • Reputation:   17
  • Joined:  04/16/12
  • Last Seen:  

Hi all,

 

How to modify @warp for normal players wherein they are not allowed to put coordinates.

 

Example:

 

@warp prontera 150 150 - They are just being warped randomly

 

Even they have specific coordinates that they want to go they will be warped randomly

 

Regards!

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  88
  • Reputation:   10
  • Joined:  01/15/16
  • Last Seen:  

¡Hi!
 
Well, at first, you need to locate this line in your atcommand.c file that its located in src/map/

 * @rura, @warp, @mapmove

scroll down a little...
and after this:

if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
{ //This is to prevent the pc_setpos call from printing an error.
clif_displaymessage(fd, msg_txt(sd,2));
if (!map_search_freecell(NULL, m, &x, &y, 10, 10, 1))
x = y = 0; //Invalid cell, use random spot.
}

 
you add the following:

if(pc_get_group_level(sd) == 0) x = y = 0;

and the entire command should be looking like this:
 

/*==========================================
 * @rura, @warp, @mapmove
 *------------------------------------------*/
ACMD_FUNC(mapmove)
{
char map_name[MAP_NAME_LENGTH_EXT];
unsigned short mapindex;
short x = 0, y = 0;
int16 m = -1;

nullpo_retr(-1, sd);

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

if (!message || !*message ||
(sscanf(message, "%15s %hd %hd", map_name, &x, &y) < 3 &&
sscanf(message, "%15[^,],%hd,%hd", map_name, &x, &y) < 1)) {
clif_displaymessage(fd, msg_txt(sd,909)); // Please enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).
return -1;
}

mapindex = mapindex_name2id(map_name);
if (mapindex)
m = map_mapindex2mapid(mapindex);

if (!mapindex) { // m < 0 means on different server! [Kevin]
clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.

if (battle_config.warp_suggestions_enabled)
warp_get_suggestions(sd, map_name);

return -1;
}

if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
{ //This is to prevent the pc_setpos call from printing an error.
clif_displaymessage(fd, msg_txt(sd,2));
if (!map_search_freecell(NULL, m, &x, &y, 10, 10, 1))
x = y = 0; //Invalid cell, use random spot.
}
if(pc_get_group_level(sd) == 0) x = y = 0;
if (map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
clif_displaymessage(fd, msg_txt(sd,247));
return -1;
}
if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
clif_displaymessage(fd, msg_txt(sd,248));
return -1;
}
if (pc_setpos(sd, mapindex, x, y, CLR_TELEPORT) != 0) {
clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
return -1;
}

clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
return 0;
} 
Edited by Emistry
  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Developer
  • Topic Count:  28
  • Topics Per Day:  0.01
  • Content Count:  547
  • Reputation:   270
  • Joined:  11/08/11
  • Last Seen:  

Dont forget that 0, 0 means random and that they might be able to reach places they shouldnt be able to reach.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  88
  • Reputation:   10
  • Joined:  01/15/16
  • Last Seen:  

Dont forget that 0, 0 means random and that they might be able to reach places they shouldnt be able to reach.

 

 

Dont true, if you see in the code that i posted in the spoiler, there is a if that say 

if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))

that check if the cell is walkeable, and if its not, it will try again to obtain a new walkeable cell.

And if you are saying that it might get their to a place that they should do a quest first o something like that, he asked for a random position

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