Jump to content
  • 0

Get Memo data with a scripting command


Vach

Question


  • Group:  Members
  • Topic Count:  21
  • Topics Per Day:  0.01
  • Content Count:  326
  • Reputation:   19
  • Joined:  09/27/12
  • Last Seen:  

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.

Link to comment
Share on other sites

12 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  60
  • Topics Per Day:  0.01
  • Content Count:  562
  • Reputation:   217
  • Joined:  11/22/11
  • Last Seen:  

query_sql "your MySQL query", <array variable> {,<array variable>, ...};

SELECT map,x,y

FROM `memo`

WHERE char_id = getcharid(0)

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  21
  • Topics Per Day:  0.01
  • Content Count:  326
  • Reputation:   19
  • Joined:  09/27/12
  • Last Seen:  

Wait, I think I may not be understanding this:

So I would type "SELECT map,x,y" in the query command?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  21
  • Topics Per Day:  0.01
  • Content Count:  326
  • Reputation:   19
  • Joined:  09/27/12
  • Last Seen:  

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.

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:  

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
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  21
  • Topics Per Day:  0.01
  • Content Count:  326
  • Reputation:   19
  • Joined:  09/27/12
  • Last Seen:  

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.

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:  

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
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  21
  • Topics Per Day:  0.01
  • Content Count:  326
  • Reputation:   19
  • Joined:  09/27/12
  • Last Seen:  

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?

Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2345
  • Joined:  10/28/11
  • Last Seen:  

you can try this..

http://pastebin.com/raw.php?i=cCkyzKy2

dZycK.png

but i dont know which function can retrieve the map name ~

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  21
  • Topics Per Day:  0.01
  • Content Count:  326
  • Reputation:   19
  • Joined:  09/27/12
  • Last Seen:  

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.
Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2345
  • Joined:  10/28/11
  • Last Seen:  

you can try this..

http://pastebin.com/raw.php?i=eMH1W8WT

Note :

since i didnt add much restriction or checking condition in the source...it would not work under certain condition..

example...cant have duplicated same memo maps ...( need to remove the existing before the updated memo will shown )

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  21
  • Topics Per Day:  0.01
  • Content Count:  326
  • Reputation:   19
  • Joined:  09/27/12
  • Last Seen:  

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.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  21
  • Topics Per Day:  0.01
  • Content Count:  326
  • Reputation:   19
  • Joined:  09/27/12
  • Last Seen:  

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