Jump to content
  • 0

Convert atcommand addwarp to script function with additional parameter


Litro Endemic

Question


  • Group:  Members
  • Topic Count:  25
  • Topics Per Day:  0.01
  • Content Count:  283
  • Reputation:   76
  • Joined:  06/13/13
  • Last Seen:  

Can anyone help me to covert atcommand addwarp to script function with additional paramter, the parameter should look like below?

*addwarp("warpname","mapname",x,y,"mapname_target",x_destination,y_destination);

also can the warp added be deleted with unloadnpc? because atcommand addwarp is persist until reboot

 

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  351
  • Reputation:   263
  • Joined:  09/08/13
  • Last Seen:  

Open ../src/map/script.cpp and before:

/// script command definitions
/// for an explanation on args, see add_buildin_func
struct script_function buildin_func[] = {

add:

BUILDIN_FUNC(addwarp)
{
	struct npc_data *nd;
	const char *warpname;
	const char *mapname_src;
	const char *mapname_dst;
	unsigned short m_src, m_dst;
	int x_src, y_src, x_dst, y_dst;

	warpname = script_getstr(st,2);

	mapname_src = script_getstr(st,3);
	x_src  = script_getnum(st,4);
	y_src  = script_getnum(st,5);

	mapname_dst = script_getstr(st,6);
	x_dst  = script_getnum(st,7);
	y_dst  = script_getnum(st,8);

	if ((m_src = map_mapname2mapid(mapname_src)) < 0)
	{
		return SCRIPT_CMD_FAILURE;
	}

	if ((m_dst = mapindex_name2id(mapname_dst)) == 0)
	{
		return SCRIPT_CMD_FAILURE;
	}

	nd = npc_add_warp((char*)warpname, m_src, x_src, y_src, 2, 2, m_dst, x_dst, y_dst);

	if (nd == NULL)
	{
		return SCRIPT_CMD_FAILURE;
	}

	return SCRIPT_CMD_SUCCESS;
}

 

after:

/// script command definitions
/// for an explanation on args, see add_buildin_func
struct script_function buildin_func[] = {

add:

	BUILDIN_DEF(addwarp, "ssiisii"),

 

P.S. @unloadnpc works fine for me.

  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  25
  • Topics Per Day:  0.01
  • Content Count:  283
  • Reputation:   76
  • Joined:  06/13/13
  • Last Seen:  

thanks functor

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