Jump to content

Send mail via scriptcommand


clydelion

Recommended Posts


  • Group:  Members
  • Topic Count:  17
  • Topics Per Day:  0.00
  • Content Count:  754
  • Reputation:   186
  • Joined:  05/22/12
  • Last Seen:  

Mail via Scriptcommand

With this mod, you can do something like this..

(The sample code in the background is outdated)

douypu.jpg

This is a scriptcommand I wanted when I still had a server. It can be used in Achievement Systems, WoE prizes, and other events. This is better than getitem because the recipient doesn't need to be online.

Usage:

* sendmail <Recipient's Char ID>,"<Sender's Name>","<Title>","<Body>",<zeny>,<item_id>,<amount>{,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>};

Description:

Uses the same functions as the default mail system, but this time, it is done via script. All item, recipent, message, and title assignment are done in the background. Enjoy this free release. :)

PS: This have not been used on a live server, if you discover a bug (or if there's something wrong with my coding) let me know. :D

My sample script:

This code will give the player a +10 Knife and 10,000 zennies upon reaching job level 10.

-<tab>script<tab>Mail Test<tab>-1,{
OnPCJobLvUpEvent:
if(JobLevel != 9) end;
set .charid, getcharid(0);
set .sender$, "Achievement System";
set .title$, "Basic Skills";
set .itemid, 1201;
set .itemamount, 1;
set .zeny, 10000;
set .refine, 10;
set .body$, "You have successfully unlocked the achievement '"+.title$+"'. You have received "+.itemamount+" "+getitemname(.itemid)+"s and "+.zeny+" zennies.";
sendmail .charid,.sender$,.title$,.body$,.zeny,.itemid,.itemamount,.refine;
end;
}

PS: This wasn't used on a live server, please report any bugs you encounter.

DIFF LINK

Edited by clydelion
  • Upvote 7
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  117
  • Reputation:   18
  • Joined:  01/06/12
  • Last Seen:  

Nice mod, thanks! I'll be testing it out when I get the chance!

Link to comment
Share on other sites


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

Woah ... not bad..i like the idea of sending a Mail in game too....xD

but all Src mod release are not suppose to release using

 ...

should have using Attachment or alternet mirror link or etc..

if possible...i would love to see this idea added into official script command....

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  117
  • Reputation:   18
  • Joined:  01/06/12
  • Last Seen:  

if possible...i would love to see this idea added into official script command....

+1

It will open so many other possibilities like confirmation message on purchase in cashshop, announcement or any other kind of notices.

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:  

I prefer to have it something like this

*sendmail <Recipient Char ID>|"<Recipient name>", "<Sender's Name>", "<Title>", "<Body>", <zeny>, <item_id>, <amount>, {<refine>,<attribute>,<identify>,<card1>,<card2>,<card3>,<card4>};

most of the script commands are mostly dealing with account ID

although getpartyleader and getguildmasterid can return char ID, but the rest almost dealing with account ID

by using a character name, might be able to counter-use with rid2name( <recipient AID> ) without having to use attachrid

and the refine ... attribute, its quite normal sometimes they want to send a refined items, or a signed items

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.01
  • Content Count:  666
  • Reputation:   93
  • Joined:  04/27/12
  • Last Seen:  

I agree with Annieruru. I'd also prefer to have those additional parameters if needed. However as this is a command for npcs, I can see why it wasn't coded in the initial release. All things said, this is great, I'd also like to see this added to the svn.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  9
  • Reputation:   0
  • Joined:  10/23/12
  • Last Seen:  

+1 vote to be on official script! Thanks for this

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  19
  • Topics Per Day:  0.00
  • Content Count:  186
  • Reputation:   0
  • Joined:  01/08/12
  • Last Seen:  

Thank you!

Mail system is not bugged?

Like

Duping

or something else...

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  49
  • Reputation:   7
  • Joined:  05/24/12
  • Last Seen:  

Pretty Awesome~

:wub:

Nice!

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.01
  • Content Count:  666
  • Reputation:   93
  • Joined:  04/27/12
  • Last Seen:  

@Jelly - This wouldn't break the mail system. And it won't allow for duping, since it's script controlled. Meaning, that unless you or a scripter writes a script where users can send mail to players, involving items and zeny, without deleting the zeny, then it's safe.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  17
  • Topics Per Day:  0.00
  • Content Count:  754
  • Reputation:   186
  • Joined:  05/22/12
  • Last Seen:  

I prefer to have it something like this

*sendmail <Recipient Char ID>|"<Recipient name>", "<Sender's Name>", "<Title>", "<Body>", <zeny>, <item_id>, <amount>, {<refine>,<attribute>,<identify>,<card1>,<card2>,<card3>,<card4>};

most of the script commands are mostly dealing with account ID

although getpartyleader and getguildmasterid can return char ID, but the rest almost dealing with account ID

by using a character name, might be able to counter-use with rid2name( <recipient AID> ) without having to use attachrid

and the refine ... attribute, its quite normal sometimes they want to send a refined items, or a signed items

As of now, it detects the recipient's name automatically from the given charid.. and you can get anyone's charid using getcharid(0,"Rad").. And this doesnt need to use attachrid, as long as you have a charid you can use it (unless I didnt get what you're saying).

And the additional parameters, yes.. It would be nice to. I'll do it later. :)

@Emistry

Yes, I was wondering why I can't upload .diff or .patch files.. I guess ipb settings were changed.. I reported it already :]

Thanks everyone for feedback. :)

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  13
  • Topics Per Day:  0.00
  • Content Count:  74
  • Reputation:   16
  • Joined:  05/08/12
  • Last Seen:  

@topic: Looks great!

However, I can not seem to get this to work, If i am not mistaken "Script.C" is the only source file edit needed to get this working /?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  17
  • Topics Per Day:  0.00
  • Content Count:  754
  • Reputation:   186
  • Joined:  05/22/12
  • Last Seen:  

yes, only script.c file.

dont forget to define it in script reference list

BUILDIN_DEF(sendmail,"isssiii"),

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  13
  • Topics Per Day:  0.00
  • Content Count:  74
  • Reputation:   16
  • Joined:  05/08/12
  • Last Seen:  

Yeah I added that also, still on reaching job level 9 there is no mail sent. I am testing on a clean up to date revision and yes I recompiled

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  17
  • Topics Per Day:  0.00
  • Content Count:  754
  • Reputation:   186
  • Joined:  05/22/12
  • Last Seen:  

you reach joblevel 9 via killing a monster or via command? it should be via monster.. reach job level 8 first via command, then kill porings till you get to joblevel 9. :)

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  13
  • Topics Per Day:  0.00
  • Content Count:  74
  • Reputation:   16
  • Joined:  05/08/12
  • Last Seen:  

I tried both ways from monsters and command , I think for whatever reason I may be placing the snippet incorrectly and that is what is causing this to not work for me.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  17
  • Topics Per Day:  0.00
  • Content Count:  754
  • Reputation:   186
  • Joined:  05/22/12
  • Last Seen:  

any errors in map server? are you sure you loaded the npc script i provided for testing?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.01
  • Content Count:  666
  • Reputation:   93
  • Joined:  04/27/12
  • Last Seen:  

Yea, I must say, your post does sound a little skeptical. To me it seems like you added the command, and just assumed it would do what he showed in. A picture.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  13
  • Topics Per Day:  0.00
  • Content Count:  74
  • Reputation:   16
  • Joined:  05/08/12
  • Last Seen:  

Yea, I must say, your post does sound a little skeptical. To me it seems like you added the command, and just assumed it would do what he showed in. A picture.

@GmOcean - I don't ask for help if I have not thuroughly sought a solution of my own and or reviewed similar issues.

http://img833.images.../7332/zzzpf.png

zzzpf.png

What I did:

1.) Added both BUILD_FUNC & _DEF to Script.C

2.) Added Custom Sample NPC script provided

3.) Recompiled using rAthena-10 using VS10 Windows - ( 4 succeeded 0 failed 0 Syntax errors )

4.) Using Clean revision

5.) Reloaded/Started Server

6.) Tested Multiple methods of leveling to Job level 9 (mob, command, quest, sql)

Not sure where I went wrong & any help is greatly appreciated, PM me if necessary /swt

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  17
  • Topics Per Day:  0.00
  • Content Count:  754
  • Reputation:   186
  • Joined:  05/22/12
  • Last Seen:  

Oh, fix the tabs on the npc header

-<TAB>script<TAB>Mail Test<TAB>-1,{
OnPCJobLvUpEvent:
if(JobLevel != 9) end;
set .charid, getcharid(0);
set .sender$, "Achievement System";
set .title$, "Basic Skills";
set .itemid, 501;
set .itemamount, 50;
set .zeny, 1000;
set .body$, "You have successfully unlocked the achievement '"+.title$+"'. You have received "+.itemamount+" "+getitemname(.itemid)+"s and "+.zeny+" zennies.";
sendmail .charid,.sender$,.title$,.body$,.itemid,.itemamount,.zeny;
end;
}

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  13
  • Topics Per Day:  0.00
  • Content Count:  74
  • Reputation:   16
  • Joined:  05/08/12
  • Last Seen:  

@clydelion - Ahaaa! Success, your a gentleman and a scholar haha I can not believe I did not think to check something so simple +1 /no1

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:  

most of the script commands are mostly dealing with account ID

although getpartyleader and getguildmasterid can return char ID, but the rest almost dealing with account ID

by using a character name, might be able to counter-use with rid2name( <recipient AID> ) without having to use attachrid

As of now, it detects the recipient's name automatically from the given charid.. and you can get anyone's charid using getcharid(0,"Rad").. And this doesnt need to use attachrid, as long as you have a charid you can use it (unless I didnt get what you're saying).

ah damn .. I just say something stupid

actually, what I meant is

getcharid( 0, "Annieruru" )

will only return the result when the user is online

and if the user is offline, even there's no source command can get the user CharID <-- totally forgotten about this

the only way is use *query_sql in scripts or Sql_Query in source ... /oops

ok I'm wrong about this one

yeah ... in scripts if want to send a mail to an offline user, should've save the array of char_id first hand

so can forget about adding "<Recipient name>" optional field


EDIT:

in clif.c

	if (!intif_Mail_send(sd->status.account_id, &msg))
	mail_deliveryfail(sd, &msg);

I just read this part

perhaps your script command should also do something like

if ( sendmail(..... ) ) mes "mail sent successfully !";

else mes "mail sent failure !";

hmm ... let me check what are the conditions for mail sent to fail

EDIT2:

no.1 ... mail box is full ... -> #define MAIL_MAX_INBOX 30 .. in mmo.h

no.2 ... specify zeny in negative value ..

no.3. ... invalid item ID ...

no.4 ... gives zeny more than MAX_ZENY variable in mmo.h ...

no.5 ... MAIL_TITLE_LENGTH -> #define MAIL_TITLE_LENGTH 40

no.6 ... MAIL_BODY_LENGTH -> #define MAIL_BODY_LENGTH 200

I think that's all ... guess the rest about special attributes about items can refer to getitem2 script command

Edited by AnnieRuru
  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  17
  • Topics Per Day:  0.00
  • Content Count:  754
  • Reputation:   186
  • Joined:  05/22/12
  • Last Seen:  

I have uploaded a new version that supports the following..

sendmail <Recipient's Char ID>,"<Sender's Name>","<Title>","<Body>",<zeny>,<item_id>,<amount>{,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>};

As for the notification if the mail delivery failed, I'm thinking of displaying it in the map-server.. This command is meant to be used in the background, thus, no player is attached.. We'll have to think about it first..

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.01
  • Content Count:  666
  • Reputation:   93
  • Joined:  04/27/12
  • Last Seen:  

@Clydelion - Nice, re-release lol. However, again, I'm going to have to agree with annie on this one, perhaps an ingame error as well. Since this command can be used automatically or it can be used with GMs & Players as well... (Granted there is already a normal mail function lol).

@Annieruru - Right now it returns 0 upon success, perhaps we can simply have it return 1 and use it in an if() statement.. however, needing to use

if(sendmail .... ... ...){do this} else { do that }

will get repetetive.

But at the very least, it is a great src release. Now we just need to have it added to the svn, so when people ask for reward type npcs that involve an offline player, we can simply use this command, instead of a 2 sql_queries. 1. To get the information & 2. To place it. Also, we won't have to link this topic every time and say, add this command. It really is nice to have it existing in every future svn :D

Link to comment
Share on other sites

  • 2 months later...

  • Group:  Members
  • Topic Count:  209
  • Topics Per Day:  0.05
  • Content Count:  892
  • Reputation:   27
  • Joined:  12/09/11
  • Last Seen:  

I have uploaded a new version that supports the following..

 

sendmail <Recipient's Char ID>,"<Sender's Name>","<Title>","<Body>",<zeny>,<item_id>,<amount>{,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>};
As for the notification if the mail delivery failed, I'm thinking of displaying it in the map-server.. This command is meant to be used in the background, thus, no player is attached.. We'll have to think about it first..

@Clydelion

how about sending mail to all player's online?

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
Reply to this topic...

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