Jump to content
  • 0

Script from 2014


gekigengar

Question


  • Group:  Members
  • Topic Count:  49
  • Topics Per Day:  0.01
  • Content Count:  174
  • Reputation:   2
  • Joined:  08/30/13
  • Last Seen:  

Hello, I have a script by AnnieRuru from my 2013 - 2014 server.

It used to work perfectly, until I decided to update my rAthena to the latest (From 2013/2014)

BUILDIN_FUNC(setdir) {
	TBL_PC *sd;
	if ( script_hasdata(st,4) ) {
		if ( data_isstring( script_getdata(st,4) ) )
			sd = map_nick2sd( script_getstr(st,4),false );
		else
			sd = map_id2sd( script_getnum(st,4) );
	} else
		sd = script_rid2sd(st);
	if ( sd ) {
		int value = 0;
		if ( script_hasdata(st,3) ) {
			value = script_getnum(st,3);
			if ( value < 0 || value > 2 )
				value = 0;
		}
		pc_setdir( sd, script_getnum(st,2), value );
		clif_changed_dir( &sd->bl, AREA );
	}
	return SCRIPT_CMD_SUCCESS;
}

BUILDIN_FUNC(checkdir) {
	TBL_PC *sd;
	if ( script_hasdata(st,3) ) {
		if ( data_isstring( script_getdata(st,3) ) )
			sd = map_nick2sd( script_getstr(st,3),false );
		else
			sd = map_id2sd( script_getnum(st,3) );
	} else
		sd = script_rid2sd(st);
	if ( sd ) {
		int value = 0;
		if ( script_hasdata(st,2) )
			value = script_getnum(st,2);
		script_pushint( st, value > 0 ? sd->head_dir : sd->ud.dir );
	}
	return SCRIPT_CMD_SUCCESS;
}

First it gave me an error during compilation for map_nick2sd( script_getstr(st,4));

Looking into the changes, I noticed there is now a feature for incomplete map names, so I put in ", false" for the 2nd parameter.

The compiler no longer gave me an error, and mapserver runs well, until made an NPC use the script to set a character's direction.

setdir DIR_SOUTH;

The mapserver crashed immediately.

How do I get this to work?

Edited by gekigengar
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  

Replace

sd = script_rid2sd(st);

by

sd = map_id2sd(st->rid);

 

  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  49
  • Topics Per Day:  0.01
  • Content Count:  174
  • Reputation:   2
  • Joined:  08/30/13
  • Last Seen:  

All fixed, thanks!

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