Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- prt_vilg01,98,76,5 script Mail NPC 4_F_KAFRA9,{
- doevent "mail_main::OnTalk";
- end;
- }
- - script mail_main -1,{
- function func_getitemname {
- .@refine = getarg(0,0);
- .@nameid = getarg(1,0);
- .@amount = getarg(2,0);
- if ( .@nameid >= 1 && .@amount >= 1 ) {
- .@name$ = getitemname( .@nameid );
- .@itemtype = getiteminfo( .@nameid,2 );
- if ( .@itemtype == IT_WEAPON || .@itemtype == IT_WEAPON ) {
- if ( .@refine )
- .@name$ = "+"+.@refine+" "+.@name$;
- .@name$ = .@name$+" ["+getitemslots( .@nameid )+"]";
- }
- }
- return .@name$;
- }
- OnTalk:
- switch( select(
- "Read mail",
- "Compose Mail",
- "Cancel"
- )) {
- case 1:
- .@sql$ = "SELECT `id`,`send_name`,`title`,`message`,`zeny`,`nameid`,`amount`,`refine`,`attribute`,`identify`,`card0`,`card1`,`card2`,`card3`"
- + "FROM `mail` "
- + "WHERE `dest_name` = '"+escape_sql( strcharinfo(0) )+"' "
- + "ORDER BY `time` DESC "
- + "LIMIT "+.max_size;
- query_sql( .@sql$,.@id,.@send_name$,.@title$,.@message$,.@zeny,.@nameid,.@amount,.@refine,.@attribute,.@identify,.@card0,.@card1,.@card2,.@card3 );
- .@id_size = getarraysize( .@id );
- if ( !.@id_size ) {
- mes "Didn't have any email.";
- }
- else {
- for ( .@i = 0; .@i < .@id_size; .@i++ )
- .@menu$ = .@menu$ + replacestr( .@title$[.@i], ":", " " ) + "by " + replacestr( .@send_name$[.@i], ":", " " ) + ":";
- .@i = select( .@menu$ ) - 1;
- mes "Sender: "+.@send_name$[.@i];
- mes "Title: "+.@title$[.@i];
- mes "Message: "+.@message$[.@i];
- if ( .@nameid[.@i] && .@amount[.@i] )
- mes "Item: "+func_getitemname( .@refine[.@i],.@nameid[.@i],.@amount[.@i] );
- if ( .@zeny[.@i] )
- mes "Zeny: "+F_InsertComma( .@zeny[.@i] )+"z";
- if ( select( (( .@nameid[.@i] && .@amount[.@i] ) || .@zeny[.@i] ) ? "Retrieve Item(s) & Delete Mail":"Delete Mail","Cancel" ) ) {
- mes "This action cant be undo, are you sure ?";
- if ( select( "Confirm","Cancel" ) == 1 ) {
- if ( .@nameid[.@i] && .@amount[.@i] ) {
- if ( !checkweight( .@nameid[.@i],.@amount[.@i] ) ) {
- mes "You're overweight.";
- break;
- }
- else {
- getitem2 .@nameid[.@i],.@amount[.@i],.@identify[.@i],.@refine[.@i],.@attribute[.@i],.@card0[.@i],.@card1[.@i],.@card2[.@i],.@card3[.@i];
- }
- }
- if ( .@zeny[.@i] )
- Zeny += .@zeny[.@i];
- query_sql( "DELETE FROM `mail` WHERE `id` = '"+.@id[.@i]+"' LIMIT 1" );
- }
- }
- }
- break;
- case 2:
- disable_items;
- do {
- .@is_complete = (
- .@dest_id != 0
- && .@dest_name$ != ""
- && .@title$ != ""
- && .@message$ != ""
- );
- mes "Receiver: "+.@dest_name$;
- mes "Title: "+.@title$;
- mes "Message: "+.@message$;
- if ( .@nameid && .@amount )
- mes "Item: "+func_getitemname( .@refine,.@nameid,.@amount );
- if ( .@zeny )
- mes "Zeny: "+F_InsertComma( .@zeny )+"z";
- next;
- switch ( select(
- "Edit Receiver",
- "Edit Title",
- "Edit Message",
- "Edit Item",
- "Edit Zeny",
- ( .@is_complete ) ? "Complete":""
- )) {
- case 1:
- mes "Enter Player Name";
- input .@input$;
- query_sql( "SELECT `account_id`,`name` FROM `char` WHERE `name` LIKE '"+escape_sql( .@input$ )+"' LIMIT 1",.@dest_id,.@dest_name$ );
- if ( !.@dest_id ) {
- mes "Char not found.";
- }
- break;
- case 2:
- mes "Enter Title";
- input .@title$,0,45;
- break;
- case 3:
- mes "Enter Message";
- input .@message$;
- break;
- break;
- case 4:
- .@temp_menu$ = "";
- .@temp_count = 0;
- getinventorylist;
- for ( .@i = 0; .@i < @inventorylist_count; .@i++ ) {
- if ( !@inventorylist_bound[.@i] && !@inventorylist_expire[.@i] && !@inventorylist_equip[.@i] && @inventorylist_amount[.@i] > 0 ) {
- .@temp_menu$ = .@temp_menu$ + func_getitemname( @inventorylist_refine[.@i],@inventorylist_id[.@i],@inventorylist_amount[.@i] );
- .@temp_count++;
- }
- .@temp_menu$ = .@temp_menu$ + ":";
- }
- if ( !.@temp_count ) {
- mes "Dont have available item(s) for mail.";
- }
- else {
- mes "Pick an item from your inventory.";
- .@i = select( .@temp_menu$+"None" ) - 1;
- if ( .@i < @inventorylist_count ) {
- .@nameid = @inventorylist_id[.@i];
- .@amount = @inventorylist_amount[.@i];
- .@refine = @inventorylist_refine[.@i];
- .@identify = @inventorylist_identify[.@i];
- .@attribute = @inventorylist_attribute[.@i];
- .@card0 = @inventorylist_card1[.@i];
- .@card1 = @inventorylist_card2[.@i];
- .@card2 = @inventorylist_card3[.@i];
- .@card3 = @inventorylist_card4[.@i];
- }
- else {
- .@nameid = 0;
- .@amount = 0;
- }
- }
- break;
- case 5:
- mes "Enter Zeny";
- input .@zeny,0,Zeny;
- break;
- case 6:
- mes "Confirm your action.";
- if ( select( "Confirm","Cancel" ) == 1 ) {
- if ( .@nameid && .@amount > 0 ) {
- delitem2 .@nameid,.@amount,.@identify,.@refine,.@attribute,.@card0,.@card1,.@card2,.@card3;
- }
- if ( .@zeny[.@i] )
- Zeny -= .@zeny;
- .@sql$ = sprintf( "INSERT INTO `mail` ( %s ) VALUES ( %s ) ",
- "`send_name`,`send_id`,`dest_name`,`dest_id`,`title`,`message`,`time`,`status`,`zeny`,`nameid`,`amount`,`refine`,`attribute`,`identify`,`card0`,`card1`,`card2`,`card3`",
- "'"+escape_sql( .@send_name$ )+"',"+getcharid(3)+",'"+escape_sql( .@dest_name$ )+"',"+.@dest_id+",'"+escape_sql( .@title$ )+"','"+escape_sql( .@message$ )+"',"+gettimetick(2)+",1,"+.@zeny+","+.@nameid+","+.@amount+","+.@refine+","+.@attribute+","+.@identify+","+.@card0+","+.@card1+","+.@card2+","+.@card3
- );
- query_sql( .@sql$ );
- mes "Done";
- close;
- }
- break;
- }
- next;
- } while ( 1 );
- break;
- default:
- break;
- }
- close;
- OnInit:
- .max_size = 30;
- end;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement