Jump to content
  • 0

How to make this Sender NPC work with newer version of SQL table?


Heartfelt

Question


  • Group:  Members
  • Topic Count:  20
  • Topics Per Day:  0.01
  • Content Count:  31
  • Reputation:   0
  • Joined:  01/09/16
  • Last Seen:  

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

here is how the "acc_reg_num table looks like

image.png.3ac3e7c95eed4d8859a0172b2686506f.png

so,which part do i need to modify?


thanks in advance for helping

Edited by Heartfelt
Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  49
  • Topics Per Day:  0.01
  • Content Count:  1536
  • Reputation:   237
  • Joined:  08/03/12
  • Last Seen:  

16 hours ago, Heartfelt said:

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

image.png.3ac3e7c95eed4d8859a0172b2686506f.png

so,which part do i need to modify?


thanks in advance for helping

maybe change global_reg_value to acc_reg_num, and str to key ?

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