Jump to content
  • 0

Get Memo data with a scripting command


Question

Posted

Is this possible? I want to link my checkpoint system with the warp portal skill.

This would also allow me to create a dynamic NPC dialogue in which players can pick which slot to make memos, so they can save important warps they don't want to go anywhere... and get rid of the "Save Point" one.

I'm assuming it can be done with some SQL queries but that stuff is beyond me at the moment.

12 answers to this question

Recommended Posts

Posted

My apologies for making another post, but I have tried a few things and still need a little help.

Can someone give me an example of putting the memo data into some variables, and then editing the memo data within the script as well? I'd like to be able to pull/edit memos whenever via a function.

Thank you everyone.

Posted (edited)

select * from memo

if you mean this, then you need to kick the character for doing like this

because the character data is being processed inside the server, while the sql table will only update in timely manner

it might be possible to change the memo point through source modification ... by introducing a new script command though

I suggest that you create a new item ... in item_db

doevent <npc>::<label>

- script <npc> -1,{

<label>:

select getstrlen(warp_portal1$)? warp_portal1$ : "empty",

getstrlen(warp_portal2$)? warp_portal2$ : "empty",

getstrlen(warp_portal3$)? warp_portal3$ : "empty",

getstrlen(warp_portal4$)? warp_portal4$ : "empty";

warp getd("warp_portal"+ @menu ), 0,0;

try doing that yourself ...

maybe doing like this is better in my opinion ... maybe

otherwise ... need to do some source modifications already

Edited by AnnieRuru
  • Upvote 1
Posted

Hmmm... I know how to make the script based warp points, using variables, but I want to be able to use the Warp Portal skill which requires the use and manipulation of the memo save data.

The first thing I want to do is give more control of creating memos, so you don't just replace the first, but this is just the beginning.

You're sure memos cants be modified while the player is connected? In that case I may want to move this to source support, because I would need help making a new script command... I'm hoping this isn't necessary, though.

Posted

move to source modification support

src\map\skill.c

    case AL_WARP:
       if(sd)
       {
           clif_skill_warppoint(sd, skillid, skilllv, sd->status.save_point.map,
               (skilllv >= 2) ? sd->status.memo_point[0].map : 0,
               (skilllv >= 3) ? sd->status.memo_point[1].map : 0,
               (skilllv >= 4) ? sd->status.memo_point[2].map : 0
           );
       }
       return 0; // not to consume item.

just one glance and you should figure out how to make a script command for it

anyway, I currently don't have enough time to do source modifications so I hope somebody there can do it for you

  • Upvote 2
Posted

Thanks Annie.

HEY EVERYBODY IN SOURCE SUPPORT! Anyone know how to do something like this?

I'm still learning the source and making new script commands is definitely something I'm a novice at.

The source that Annie introduced in skill.c seems like the point where the memos are called and used to warp to... I would need to edit them and keep this part of the function intact. However:

sd->status.memo_point[#].map

seems to point to the data stored with the map information. I would need a script command to edit that? What about the coordinates? Or is editing this going to blow up the server?

Posted (edited)

Wow thanks!

This totally put me on the right track, I ended up writing the following function:

//setmemo(i,s,i,i) - Changes memo 1,2,3 to the string indicated, at the coords indicated.
BUILDIN_FUNC(setmemo) {
TBL_PC *sd;// = script_rid2sd(st);
int memo;
int x,y;
const char* mapname; //mapindex_name2id(str)
sd = script_rid2sd(st);
if( sd == NULL ) {
 ShowError("setmemo: Error, function called with no player attached to script.\n");
 return 0;
}
memo = script_getnum(st,2);
mapname = script_getstr(st,3);
x = script_getnum(st,4);
y = script_getnum(st,5);
if( !script_getstr(st,3) == C_STR || !script_getstr(st,3) ==  C_CONSTSTR )
{
 ShowError("setmemo: mapname sent not a string!\n");
 script_pushint(st,0);
 return 0;// data type mismatch
}
if (memo > MAX_MEMOPOINTS || memo > 3) {
 ShowError("setmemo: Requested memo is higher than 3 or unavailable to player.");
 script_pushint(st,0);
 return 0; }
if (!x || !y) {
 ShowError("setmemo: map x and/or y coords set to 0 or less!\n");
 script_pushint(st,0);
 return 0; }
//All checks complete, commense process.
sd->status.memo_point[memo].map = mapindex_name2id(mapname);
sd->status.memo_point[memo].x = x;
sd->status.memo_point[memo].y = y;
script_pushint(st,1); // 1 is success.
return 0;
}

Unfortunately, when used properly in an NPC script it crashes the server. I know it gets to the point where the variables are overwritten and that's when the map crash occurs, so it at least gets to that point.

I was wondering if someone could point out the errors in there?

EDIT: OH MAN THAT'S UGLY PASTED! My apologies... >_<''

Edited by Emistry
Please use [CODEBOX] or Attachments for long contents.
Posted

What's the primary difference between this code and mine, at least in terms of functionality? The only main difference I see is setting the map index to a short and checking if the short is above 0 before setting the memo map.

Have you tested it? The function I used in my npc script was "getmapxy" to find the map name... That might be the issue.

Posted (edited)

Got it working, here is the updated function and the script I used, in case anyone wants to use it for their server.

I would vote that this be something added to the official stuff? Better written probably. It's a neat feature anyone could use for various reasons.


//setmemo(i,s,i,i) - Changes memo 1,2,3 to the string indicated, at the coords indicated.
BUILDIN_FUNC(setmemo) {

TBL_PC *sd;// = script_rid2sd(st);
int memo;
int x,y;
short mapid;
//const char* mapname; //mapindex_name2id(str)

sd = script_rid2sd(st);
if( sd == NULL ) {
ShowError("setmemo: Error, function called with no player attached to script.\n");
return 0;
}

memo = script_getnum(st,2);
//mapname = script_getstr(st,3);
mapid = mapindex_name2id(script_getstr(st,3));
x = script_getnum(st,4);
y = script_getnum(st,5);

if( !script_getstr(st,3) == C_STR || !script_getstr(st,3) ==  C_CONSTSTR )
{
ShowError("setmemo: mapname sent not a string!\n");
script_pushint(st,0);
return 0;// data type mismatch
}

if (!mapid) {
ShowError("setmemo: mapname sent is not in proper format (remove '.gat')");
script_pushint(st,0);
return 0; }

if (memo > MAX_MEMOPOINTS || memo > 3) {
ShowError("setmemo: Requested memo is higher than 3 or unavailable to player.");
script_pushint(st,0);
return 0; }

if (!x || !y) {
ShowError("setmemo: map x and/or y coords set to 0 or less!\n");
script_pushint(st,0);
return 0; }

//All checks complete, commense process.
sd->status.memo_point[memo].map = mapid;
sd->status.memo_point[memo].x = x;
sd->status.memo_point[memo].y = y;
script_pushint(st,1); // 1 is success.
return 0;

}

Script choice:


getmapxy(@mapname$,@mapx,@mapy,0);
if (setmemo(1,@mapname$,@mapx,@mapy) == 1) {
mes "...";
mes "Success!";
close; }

The problem was the use of the function embedded into setting .map, apparently it did not configure properly. I made an error report anyway.

Edited by Vach

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