pastebin - collaborative debugging tool
eathena.kpaste.net RSS


kafrapoints_transfer.txt
Posted by Anonymous on Fri 11th Mar 2011 05:53
raw | new post

  1. // http://www.eathena.ws/board/index.php?showtopic=226379
  2. // I need a NPC than transfer points to another account when this person is online.
  3.  
  4. ball2,50,50,0   script  KafraPoints Transfer    910,{
  5.         mes "[Kafra]";
  6.         mes "Hello " + strcharinfo(0) + ",";
  7.         mes "you have " + #KAFRAPOINTS + " Kafra Points.";
  8.         if (#KAFRAPOINTS==0) close;
  9.         mes "Would you like to send some points to another person?";
  10.         next;
  11.         if(select("Yes:No, thanks")==2) {
  12.                 mes "[Kafra]";
  13.                 mes " ";
  14.                 mes "Thank you, come again!";
  15.                 close;
  16.         }
  17.        
  18.         mes "[Kafra]";
  19.         mes "Enter the char's name:";
  20.         input .@name$;
  21.         query_sql "SELECT `account_id`,`name` FROM `char` WHERE `name` = '"+escape_sql(.@name$)+"'", .@account_id,.@name$;
  22.         if (!.@account_id) {
  23.                 mes "^FF0000     Char name does not exist.";
  24.                 close;
  25.         } else if (.@account_id==getcharid(3)) {
  26.                 mes "Why would you send points to yourself?";
  27.                 close;
  28.         }
  29.        
  30.         mes "Send how many Kafra Points?";
  31.         input .@amt;
  32.         if (.@amt < 1) {
  33.                 mes "^0000FFEnter a positive number.";
  34.                 close;
  35.         } else if (.@amt > #KAFRAPOINTS) {
  36.                 mes "^0000FFYou do not have that many Kafra Points. The max you can send is: "+#KAFRAPOINTS;
  37.                 close;
  38.         }
  39.        
  40.         mes "Send "+.@amt+" Kafra Points to "+.@name$+"?";
  41.         if(select("Yes:No")==2) close;
  42.        
  43.         // save their Account ID and name
  44.         set .@AID, playerattached();
  45.         set .@send_name$, strcharinfo(0);
  46.        
  47.         // subtract their Kafra Points
  48.         set #KAFRAPOINTS, #KAFRAPOINTS - .@amt;
  49.         // transfer the Kafra Points
  50.         if (attachrid(.@account_id)) {
  51.                 // if they are logged in
  52.                 set #KAFRAPOINTS, #KAFRAPOINTS + .@amt;
  53.                 dispbottom .@send_name$ + " sent you " + .@amt + " Kafra Points!     Total = " + #KAFRAPOINTS;
  54.         } else {
  55.                 // if they are offline, query_sql
  56.                 if( query_sql("SELECT account_id FROM global_reg_value WHERE str='#KAFRAPOINTS' AND account_id="+.@account_id, .@account_id) )
  57.                         query_sql "UPDATE global_reg_value SET `value`=`value`+"+.@amt+" WHERE str='#KAFRAPOINTS' AND account_id="+.@account_id;
  58.                 else
  59.                         query_sql "INSERT INTO global_reg_value (str,`value`,`type`,account_id) VALUES ('#KAFRAPOINTS',"+.@amt+",2,"+.@account_id+")";
  60.         }
  61.        
  62.         attachrid(.@AID);
  63.         mes "Transfer successful!";
  64.         close;
  65. }

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at