i want to use this NPC i found on rathena on my server.
the use of this NPC is to transfer cash points or zeny to other players
prontera,45,99,2 script Transfer Angel 437,{
start:
mes "[Transfer Angel]";
mes "Hello " + strcharinfo(0) + ",";
mes "What can I do for you?";
next;
menu "Cash Transfer",cashi,"Zeny Transfer",zenyi,"Leave",L_Leave;
cashi:
mes "[Transfer Angel]";
if (#CASHPOINTS==0){
mes "Sorry but you don't have any Cash Points.";
next;
goto start;
}
mes "Please enter the char's name:";
mes "(You have " + #CASHPOINTS + " Cash Points)";
input .@name$;
query_sql "SELECT `account_id`,`name` FROM `char` WHERE `name` = '"+escape_sql(.@name$)+"'", .@account_id,.@name$;
next;
if (!.@account_id) {
mes "[Transfer Angel]";
mes "^FF0000Char name does not exist.^000000";
close;
} else if (.@account_id==getcharid(3)) {
mes "[Transfer Angel]";
mes "Why would you send points to yourself?";
next;
goto cashi;
}
cashsend:
mes "[Transfer Angel]";
mes "How many Cash Points to send?";
mes "You'r sending to: ^0000FF"+.@name$+"^000000";
mes "(You have: " + #CASHPOINTS + " Cash Points)";
mes "(Type 0 to cancel)";
input .@amt;
if (.@amt == 0) close;
next;
if (.@amt < 1) {
mes "[Transfer Angel]";
mes "^0000FFPlease enter a positive number^000000.";
next;
goto cashsend;
} else if (.@amt > #CASHPOINTS) {
mes "[Transfer Angel]";
mes "^0000FFYou do not have that many Cash Points.^000000 The max you can send is: "+#CASHPOINTS;
next;
goto cashsend;
}
mes "[Transfer Angel]";
mes "Send "+.@amt+" Cash Points to ^0000FF"+.@name$+"^000000?";
menu "Yes",yy,"Back to Menu",nn;
yy:
// save their Account ID and name
set .@AID, playerattached();
set .@send_name$, strcharinfo(0);
// subtract their Cash Points
set #CASHPOINTS, #CASHPOINTS - .@amt;
// transfer the Cash Points
if (attachrid(.@account_id)) {
// if they are logged in
set #CASHPOINTS, #CASHPOINTS + .@amt;
dispbottom .@send_name$ + " sent you " + .@amt + " Cash Points! Total = " + #CASHPOINTS;
} else {
// if they are offline, query_sql
if( query_sql("SELECT account_id FROM global_reg_value WHERE str='#CASHPOINTS' AND account_id="+.@account_id, .@account_id) )
query_sql "UPDATE global_reg_value SET `value`=`value`+"+.@amt+" WHERE str='#CASHPOINTS' AND account_id="+.@account_id;
else
query_sql "INSERT INTO global_reg_value (str,`value`,`type`,account_id) VALUES ('#CASHPOINTS',"+.@amt+",2,"+.@account_id+")";
}
attachrid(.@AID);
next;
mes "[Transfer Angel]";
mes "Transfer successful!";
next;
goto start;
L_Leave:
mes "[Transfer Angel]";
mes "Have a nice day";
close;
zenyi:
mes "[Transfer Angel]";
if (zeny==0){
mes "Sorry but you don't have any Zeny.";
next;
goto start;
}
mes "Please enter the char's name:";
input .@name$;
query_sql "SELECT `char_id`,`account_id`,`name` FROM `char` WHERE `name` = '"+escape_sql(.@name$)+"'", .@char_id,.@account_id,.@name$;
next;
if (!.@account_id) {
mes "[Transfer Angel]";
mes "^FF0000Char name does not exist.^000000";
close;
} else if (.@char_id==getcharid(0)) {
mes "[Transfer Angel]";
mes "Why would you send zeny to yourself?";
next;
goto zenyi;
}
zenysend:
mes "[Transfer Angel]";
mes "How much Zeny to send?";
mes "You'r sending to: ^0000FF"+.@name$+"^000000";
mes "(You have: "+Zeny+" Zeny)";
mes "(Type 0 to cancel)";
input .@amt;
if (.@amt == 0) close;
next;
if (.@amt < 1) {
mes "[Transfer Angel]";
mes "^0000FFPlease enter a positive number.^000000";
next;
goto zenysend;
} else if (.@amt > Zeny) {
mes "[Transfer Angel]";
mes "^0000FFYou do not have that much zeny.^000000 The max you can send is: "+Zeny;
next;
goto zenysend;
}
mes "[Transfer Angel]";
mes "Send "+.@amt+" Zeny to ^0000FF"+.@name$+"^000000?";
menu "Yes",yy2,"Back to Menu",nn;
nn:
next;
goto start;
yy2:
// save their Account ID and name
set .@AID, playerattached();
set .@send_name$, strcharinfo(0);
// subtract their zeny
set Zeny, Zeny - .@amt;
// transfer the money
if (attachrid(.@account_id)) {
if (getcharid(0)==.@char_id) {
// if they are logged in, on the right char
set Zeny, Zeny + .@amt;
dispbottom .@send_name$ + " sent you " + .@amt + " zeny!";
} else {
// logged in, but on wrong char
query_sql "UPDATE `char` SET `zeny`=`zeny`+'"+.@amt+"' WHERE `char_id`='"+.@char_id+"'";
}
} else {
// if they are offline, query_sql
query_sql "UPDATE `char` SET `zeny`=`zeny`+'"+.@amt+"' WHERE `char_id`='"+.@char_id+"'";
}
attachrid(.@AID);
next;
mes "[Transfer Angel]";
mes "Transfer successful!";
next;
goto start;
}
however this part is not working, when i send it to an offline player
Quote
} else {
// if they are offline, query_sql
if( query_sql("SELECT account_id FROM global_reg_value WHERE str='#CASHPOINTS' AND account_id="+.@account_id, .@account_id) )
query_sql "UPDATE global_reg_value SET `value`=`value`+"+.@amt+" WHERE str='#CASHPOINTS' AND account_id="+.@account_id;
else
query_sql "INSERT INTO global_reg_value (str,`value`,`type`,account_id) VALUES ('#CASHPOINTS',"+.@amt+",2,"+.@account_id+")";
there is no "global_reg_value" in my sql table, instead i have "acc_reg_num" that stores the Cashpoint of each account
Question
Heartfelt
i want to use this NPC i found on rathena on my server.
the use of this NPC is to transfer cash points or zeny to other players
prontera,45,99,2 script Transfer Angel 437,{ start: mes "[Transfer Angel]"; mes "Hello " + strcharinfo(0) + ","; mes "What can I do for you?"; next; menu "Cash Transfer",cashi,"Zeny Transfer",zenyi,"Leave",L_Leave; cashi: mes "[Transfer Angel]"; if (#CASHPOINTS==0){ mes "Sorry but you don't have any Cash Points."; next; goto start; } mes "Please enter the char's name:"; mes "(You have " + #CASHPOINTS + " Cash Points)"; input .@name$; query_sql "SELECT `account_id`,`name` FROM `char` WHERE `name` = '"+escape_sql(.@name$)+"'", .@account_id,.@name$; next; if (!.@account_id) { mes "[Transfer Angel]"; mes "^FF0000Char name does not exist.^000000"; close; } else if (.@account_id==getcharid(3)) { mes "[Transfer Angel]"; mes "Why would you send points to yourself?"; next; goto cashi; } cashsend: mes "[Transfer Angel]"; mes "How many Cash Points to send?"; mes "You'r sending to: ^0000FF"+.@name$+"^000000"; mes "(You have: " + #CASHPOINTS + " Cash Points)"; mes "(Type 0 to cancel)"; input .@amt; if (.@amt == 0) close; next; if (.@amt < 1) { mes "[Transfer Angel]"; mes "^0000FFPlease enter a positive number^000000."; next; goto cashsend; } else if (.@amt > #CASHPOINTS) { mes "[Transfer Angel]"; mes "^0000FFYou do not have that many Cash Points.^000000 The max you can send is: "+#CASHPOINTS; next; goto cashsend; } mes "[Transfer Angel]"; mes "Send "+.@amt+" Cash Points to ^0000FF"+.@name$+"^000000?"; menu "Yes",yy,"Back to Menu",nn; yy: // save their Account ID and name set .@AID, playerattached(); set .@send_name$, strcharinfo(0); // subtract their Cash Points set #CASHPOINTS, #CASHPOINTS - .@amt; // transfer the Cash Points if (attachrid(.@account_id)) { // if they are logged in set #CASHPOINTS, #CASHPOINTS + .@amt; dispbottom .@send_name$ + " sent you " + .@amt + " Cash Points! Total = " + #CASHPOINTS; } else { // if they are offline, query_sql if( query_sql("SELECT account_id FROM global_reg_value WHERE str='#CASHPOINTS' AND account_id="+.@account_id, .@account_id) ) query_sql "UPDATE global_reg_value SET `value`=`value`+"+.@amt+" WHERE str='#CASHPOINTS' AND account_id="+.@account_id; else query_sql "INSERT INTO global_reg_value (str,`value`,`type`,account_id) VALUES ('#CASHPOINTS',"+.@amt+",2,"+.@account_id+")"; } attachrid(.@AID); next; mes "[Transfer Angel]"; mes "Transfer successful!"; next; goto start; L_Leave: mes "[Transfer Angel]"; mes "Have a nice day"; close; zenyi: mes "[Transfer Angel]"; if (zeny==0){ mes "Sorry but you don't have any Zeny."; next; goto start; } mes "Please enter the char's name:"; input .@name$; query_sql "SELECT `char_id`,`account_id`,`name` FROM `char` WHERE `name` = '"+escape_sql(.@name$)+"'", .@char_id,.@account_id,.@name$; next; if (!.@account_id) { mes "[Transfer Angel]"; mes "^FF0000Char name does not exist.^000000"; close; } else if (.@char_id==getcharid(0)) { mes "[Transfer Angel]"; mes "Why would you send zeny to yourself?"; next; goto zenyi; } zenysend: mes "[Transfer Angel]"; mes "How much Zeny to send?"; mes "You'r sending to: ^0000FF"+.@name$+"^000000"; mes "(You have: "+Zeny+" Zeny)"; mes "(Type 0 to cancel)"; input .@amt; if (.@amt == 0) close; next; if (.@amt < 1) { mes "[Transfer Angel]"; mes "^0000FFPlease enter a positive number.^000000"; next; goto zenysend; } else if (.@amt > Zeny) { mes "[Transfer Angel]"; mes "^0000FFYou do not have that much zeny.^000000 The max you can send is: "+Zeny; next; goto zenysend; } mes "[Transfer Angel]"; mes "Send "+.@amt+" Zeny to ^0000FF"+.@name$+"^000000?"; menu "Yes",yy2,"Back to Menu",nn; nn: next; goto start; yy2: // save their Account ID and name set .@AID, playerattached(); set .@send_name$, strcharinfo(0); // subtract their zeny set Zeny, Zeny - .@amt; // transfer the money if (attachrid(.@account_id)) { if (getcharid(0)==.@char_id) { // if they are logged in, on the right char set Zeny, Zeny + .@amt; dispbottom .@send_name$ + " sent you " + .@amt + " zeny!"; } else { // logged in, but on wrong char query_sql "UPDATE `char` SET `zeny`=`zeny`+'"+.@amt+"' WHERE `char_id`='"+.@char_id+"'"; } } else { // if they are offline, query_sql query_sql "UPDATE `char` SET `zeny`=`zeny`+'"+.@amt+"' WHERE `char_id`='"+.@char_id+"'"; } attachrid(.@AID); next; mes "[Transfer Angel]"; mes "Transfer successful!"; next; goto start; }
however this part is not working, when i send it to an offline player
there is no "global_reg_value" in my sql table, instead i have "acc_reg_num" that stores the Cashpoint of each account
here is how the "acc_reg_num table looks like
so,which part do i need to modify?
thanks in advance for helping
Link to comment
Share on other sites
1 answer to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.