Deposit items redeemed from CP back to it.

Helena

New member
Messages
238
Points
0
Emulator
rAthena
Hello hercules,

I have a question regarding SQL query. 

When I redeem something from donations through the fluxCP, it gives me an item in-game. This is item ID 677 (I can spend that on special currency shops).

Now my question is, how do i make a NPC with query that turns item 677 back into CP credits? Might i add the course isn't the same. 100x of item 677 is equal to 1 flux cp credit.

I'd like the player to be able to input how many he wants to put back. This is all i could figure out...
default_sad.png


Code:
prontera,150,150,1	script	PutBack	987,{mes "Hi. Can i help you?";menu "Put coins back to CP",-;if (countitem(677) < 100){mes "I'm sorry, you need at least 100 coins because 100 is equal to 1 credit.";close;} mes "Input amount:"input (????) query_sql("UPDATE `cp_credits` SET `balance` = (????+00) WHERE `account_id` = '"+getcharid(3)+"'"); (is this right?)	delitem 677,(input amount here);	sleep2 10;dispbottom "Coins converted back to site credits.";}close;end;}
 
Last edited by a moderator:
Hello hercules,

I have a question regarding SQL query. 

When I redeem something from donations through the fluxCP, it gives me an item in-game. This is item ID 677 (I can spend that on special currency shops).

Now my question is, how do i make a NPC with query that turns item 677 back into CP credits? Might i add the course isn't the same. 100x of item 677 is equal to 1 flux cp credit.

I'd like the player to be able to input how many he wants to put back. This is all i could figure out...
default_sad.png


prontera,150,150,1 script PutBack 987,{mes "Hi. Can i help you?";menu "Put coins back to CP",-;if (countitem(677) < 100){mes "I'm sorry, you need at least 100 coins because 100 is equal to 1 credit.";close;} mes "Input amount:"input (????) query_sql("UPDATE `cp_credits` SET `balance` = (????+00) WHERE `account_id` = '"+getcharid(3)+"'"); (is this right?) delitem 677,(input amount here); sleep2 10;dispbottom "Coins converted back to site credits.";}close;end;}
Here you go:

prontera,150,150,1   script   PutBack   987,{  mes "Hi. Can i help you?";  if(select("Put coins back to CP:Close") == 2) close;  if (countitem(677) < 100){    mes "I'm sorry, you need at least 100 coins because 100 is equal to 1 credit.";    close;  }    mes "Input amount:";  input .@a,100,1000;  if(.@a%100) {    mes "Can't transfer that much";    mes "Because your amount of coins ins't dividable by 100";    close;  }    if(countitem(677) < .@a) {    mes "You don't have enough "+getitemname(677);    mes "You need "+(.@a - countitem(677))+" more "+getitemname(677);    close;  }    next;  .@cp_credits = .@a/100;  mes "Here you go!";  mes "You will get "+.@cp_credits;    query_sql("UPDATE `cp_credits` SET `balance` = `balance` + "+ .@cp_credits +" WHERE `account_id` = '"+getcharid(3)+"'");  delitem 677, .@a;  close;}

Didn't test it btw.

 
Last edited by a moderator:
Hello hercules,

I have a question regarding SQL query. 

When I redeem something from donations through the fluxCP, it gives me an item in-game. This is item ID 677 (I can spend that on special currency shops).

Now my question is, how do i make a NPC with query that turns item 677 back into CP credits? Might i add the course isn't the same. 100x of item 677 is equal to 1 flux cp credit.

I'd like the player to be able to input how many he wants to put back. This is all i could figure out...
default_sad.png


prontera,150,150,1 script PutBack 987,{mes "Hi. Can i help you?";menu "Put coins back to CP",-;if (countitem(677) < 100){mes "I'm sorry, you need at least 100 coins because 100 is equal to 1 credit.";close;} mes "Input amount:"input (????) query_sql("UPDATE `cp_credits` SET `balance` = (????+00) WHERE `account_id` = '"+getcharid(3)+"'"); (is this right?) delitem 677,(input amount here); sleep2 10;dispbottom "Coins converted back to site credits.";}close;end;}
Here you go:

prontera,150,150,1   script   PutBack   987,{  mes "Hi. Can i help you?";  if(select("Put coins back to CP:Close") == 2) close;  if (countitem(677) < 100){    mes "I'm sorry, you need at least 100 coins because 100 is equal to 1 credit.";    close;  }    mes "Input amount:";  input .@a,100,1000;  if(.@a%100) {    mes "Can't transfer that much";    mes "Because your amount of coins ins't dividable by 100";    close;  }    if(countitem(677) < .@a) {    mes "You don't have enough "+getitemname(677);    mes "You need "+(.@a - countitem(677))+" more "+getitemname(677);    close;  }    next;  .@cp_credits = .@a/100;  mes "Here you go!";  mes "You will get "+.@cp_credits;    query_sql("UPDATE `cp_credits` SET `balance` = `balance` + "+ .@cp_credits +" WHERE `account_id` = '"+getcharid(3)+"'");  delitem 677, .@a;  close;}

Didn't test it btw.
Thank you sir, works perfectly!

 
Hello hercules,

I have a question regarding SQL query. 

When I redeem something from donations through the fluxCP, it gives me an item in-game. This is item ID 677 (I can spend that on special currency shops).

Now my question is, how do i make a NPC with query that turns item 677 back into CP credits? Might i add the course isn't the same. 100x of item 677 is equal to 1 flux cp credit.

I'd like the player to be able to input how many he wants to put back. This is all i could figure out... 
default_sad.png


prontera,150,150,1 script PutBack 987,{mes "Hi. Can i help you?";

menu "Put coins back to CP",-;

if (countitem(677) < 100){

mes "I'm sorry, you need at least 100 coins because 100 is equal to 1 credit.";

close;

}

mes "Input amount:"

input (????)

 query_sql("UPDATE `cp_credits` SET `balance` = (????+00) WHERE `account_id` = '"+getcharid(3)+"'"); (is this right?)

delitem 677,(input amount here);

sleep2 10;

dispbottom "Coins converted back to site credits.";

}

close;

end;

}
Here you go:

prontera,150,150,1   script   PutBack   987,{ mes "Hi. Can i help you?";

 if(select("Put coins back to CP:Close") == 2) close;

 if (countitem(677) < 100){

   mes "I'm sorry, you need at least 100 coins because 100 is equal to 1 credit.";

   close;

 }

 mes "Input amount:";

 input .@a,100,1000;

 if(.@a%100) {

   mes "Can't transfer that much";

   mes "Because your amount of coins ins't dividable by 100";

   close;

 }

 if(countitem(677) < .@a) {

   mes "You don't have enough "+getitemname(677);

   mes "You need "+(.@a - countitem(677))+" more "+getitemname(677);

   close;

 }

 next;

 .@cp_credits = .@a/100;

 mes "Here you go!";

 mes "You will get "+.@cp_credits;

 query_sql("UPDATE `cp_credits` SET `balance` = `balance` + "+ .@cp_credits +" WHERE `account_id` = '"+getcharid(3)+"'");

 delitem 677, .@a;

 close;

}

Didn't test it btw.
Ah, i found an issue.

If players input 1234, they take 1234 coins, but the credits on the CP only gets updated by 10. What do i need to edit so they can only input amounts that end with two (or three) zeros? >.<


 
Last edited by a moderator:
After:

Code:
    mes "Input amount:";    input .@a,100,1000;    if(.@a%100) {        mes "Can't transfer that much";        mes "Because your amount of coins ins't dividable by 100";        close;    }
add this:

Code:
if(.@a < 100 || .@a > 1000) close;
 
Last edited by a moderator:
Hello hercules,

I have a question regarding SQL query. 

When I redeem something from donations through the fluxCP, it gives me an item in-game. This is item ID 677 (I can spend that on special currency shops).

Now my question is, how do i make a NPC with query that turns item 677 back into CP credits? Might i add the course isn't the same. 100x of item 677 is equal to 1 flux cp credit.

I'd like the player to be able to input how many he wants to put back. This is all i could figure out...
default_sad.png


prontera,150,150,1 script PutBack 987,{mes "Hi. Can i help you?";menu "Put coins back to CP",-;if (countitem(677) < 100){mes "I'm sorry, you need at least 100 coins because 100 is equal to 1 credit.";close;} mes "Input amount:"input (????) query_sql("UPDATE `cp_credits` SET `balance` = (????+00) WHERE `account_id` = '"+getcharid(3)+"'"); (is this right?) delitem 677,(input amount here); sleep2 10;dispbottom "Coins converted back to site credits.";}close;end;}
Here you go:

Code:
prontera,150,150,1    script    PutBack    987,{    mes "Hi. Can i help you?";    if(select("Put coins back to CP:Close") == 2) close;    if (countitem(677) < 100){        mes "I'm sorry, you need at least 100 coins because 100 is equal to 1 credit.";        close;    }        mes "Input amount:";    input .@a,100,1000;    if(.@a0) {        mes "Can't transfer that much";        mes "Because your amount of coins ins't dividable by 100";        close;    }        if(countitem(677) < .@a) {        mes "You don't have enough "+getitemname(677);        mes "You need "+(.@a - countitem(677))+" more "+getitemname(677);        close;    }        next;    .@cp_credits = .@a/100;    mes "Here you go!";    mes "You will get "+.@cp_credits;        query_sql("UPDATE `cp_credits` SET `balance` = `balance` + "+ .@cp_credits +" WHERE `account_id` = '"+getcharid(3)+"'");    delitem 677, .@a;    close;}
 Didn't test it btw.
 Thank you sir, works perfectly!

Hello hercules,

I have a question regarding SQL query. 

When I redeem something from donations through the fluxCP, it gives me an item in-game. This is item ID 677 (I can spend that on special currency shops).

Now my question is, how do i make a NPC with query that turns item 677 back into CP credits? Might i add the course isn't the same. 100x of item 677 is equal to 1 flux cp credit.

I'd like the player to be able to input how many he wants to put back. This is all i could figure out... 
default_sad.png


prontera,150,150,1 script PutBack 987,{

mes "Hi. Can i help you?";

menu "Put coins back to CP",-;

if (countitem(677) < 100){

mes "I'm sorry, you need at least 100 coins because 100 is equal to 1 credit.";

close;

}

mes "Input amount:"

input (????)

 query_sql("UPDATE `cp_credits` SET `balance` = (????+00) WHERE `account_id` = '"+getcharid(3)+"'"); (is this right?)

delitem 677,(input amount here);

sleep2 10;

dispbottom "Coins converted back to site credits.";

}

close;

end;

}
Here you go:
prontera,150,150,1   script   PutBack   987,{

 mes "Hi. Can i help you?";

 if(select("Put coins back to CP:Close") == 2) close;

 if (countitem(677) < 100){

   mes "I'm sorry, you need at least 100 coins because 100 is equal to 1 credit.";

   close;

 }

 mes "Input amount:";

 input .@a,100,1000;

 if(.@a0) {

   mes "Can't transfer that much";

   mes "Because your amount of coins ins't dividable by 100";

   close;

 }

 if(countitem(677) < .@a) {

   mes "You don't have enough "+getitemname(677);

   mes "You need "+(.@a - countitem(677))+" more "+getitemname(677);

   close;

 }

 next;

 .@cp_credits = .@a/100;

 mes "Here you go!";

 mes "You will get "+.@cp_credits;

 query_sql("UPDATE `cp_credits` SET `balance` = `balance` + "+ .@cp_credits +" WHERE `account_id` = '"+getcharid(3)+"'");

 delitem 677, .@a;

 close;

}

Didn't test it btw.
 Ah, i found an issue.

If players input 1234, they take 1234 coins, but the credits on the CP only gets updated by 10. What do i need to edit so they can only input amounts that end with two (or three) zeros? >.<
Not possibleinput .@a,100,1000;

See, .@a is limited to 1000, so only 1000 coins get deleted and 10 cp credit gets added.

 
There's a check for that:

  if(!(.@a%100)) {    mes "Can't transfer that much";    mes "Because your amount of coins ins't dividable by 100";    close;  }

Try this
Tried, but now it doesnt let me put 400 either

...Ah, ok dastgir.
default_sad.png


 
Last edited by a moderator:
Hello hercules,

I have a question regarding SQL query. 

When I redeem something from donations through the fluxCP, it gives me an item in-game. This is item ID 677 (I can spend that on special currency shops).

Now my question is, how do i make a NPC with query that turns item 677 back into CP credits? Might i add the course isn't the same. 100x of item 677 is equal to 1 flux cp credit.

I'd like the player to be able to input how many he wants to put back. This is all i could figure out...
default_sad.png


prontera,150,150,1 script PutBack 987,{mes "Hi. Can i help you?";menu "Put coins back to CP",-;if (countitem(677) < 100){mes "I'm sorry, you need at least 100 coins because 100 is equal to 1 credit.";close;} mes "Input amount:"input (????) query_sql("UPDATE `cp_credits` SET `balance` = (????+00) WHERE `account_id` = '"+getcharid(3)+"'"); (is this right?) delitem 677,(input amount here); sleep2 10;dispbottom "Coins converted back to site credits.";}close;end;}
Here you go:

prontera,150,150,1   script   PutBack   987,{  mes "Hi. Can i help you?";  if(select("Put coins back to CP:Close") == 2) close;  if (countitem(677) < 100){    mes "I'm sorry, you need at least 100 coins because 100 is equal to 1 credit.";    close;  }    mes "Input amount:";  input .@a,100,1000;  if(.@a%100) {    mes "Can't transfer that much";    mes "Because your amount of coins ins't dividable by 100";    close;  }    if(countitem(677) < .@a) {    mes "You don't have enough "+getitemname(677);    mes "You need "+(.@a - countitem(677))+" more "+getitemname(677);    close;  }    next;  .@cp_credits = .@a/100;  mes "Here you go!";  mes "You will get "+.@cp_credits;    query_sql("UPDATE `cp_credits` SET `balance` = `balance` + "+ .@cp_credits +" WHERE `account_id` = '"+getcharid(3)+"'");  delitem 677, .@a;  close;}

Didn't test it btw.
Thank you sir, works perfectly!

 
Hello hercules,

I have a question regarding SQL query. 

When I redeem something from donations through the fluxCP, it gives me an item in-game. This is item ID 677 (I can spend that on special currency shops).

Now my question is, how do i make a NPC with query that turns item 677 back into CP credits? Might i add the course isn't the same. 100x of item 677 is equal to 1 flux cp credit.

I'd like the player to be able to input how many he wants to put back. This is all i could figure out... 
default_sad.png


There's a check for that:

  if(!(.@a%100)) {    mes "Can't transfer that much";    mes "Because your amount of coins ins't dividable by 100";    close;  }

Try this
Tried, but now it doesnt let me put 400 either

...Ah, ok dastgir.
default_sad.png
Check my post again.
Made the edit but oddly it still takes it.
Didn't test it btw.
Ah, i found an issue.

If players input 1234, they take 1234 coins, but the credits on the CP only gets updated by 10. What do i need to edit so they can only input amounts that end with two (or three) zeros? >.<
  prontera,150,150,1   script   PutBack   987,{   mes "Hi. Can i help you?";   menu "Put coins back to CP",-;   if (countitem(677) < 100){   mes "I'm sorry, you need at least 100 coins because 100 is equal to 1 credit.";   close;   }   mes "Input amount:"   input (????) query_sql("UPDATE `cp_credits` SET `balance` = (????+00) WHERE `account_id` = '"+getcharid(3)+"'"); (is this right?)   delitem 677,(input amount here);   sleep2 10;   dispbottom "Coins converted back to site credits.";   }   close;   end;   }Here you go:prontera,150,150,1   script   PutBack   987,{   mes "Hi. Can i help you?";   if(select("Put coins back to CP:Close") == 2) close;   if (countitem(677) < 100){   mes "I'm sorry, you need at least 100 coins because 100 is equal to 1 credit.";   close;   } mes "Input amount:";   input .@a,100,1000;   if(.@a%100) {   mes "Can't transfer that much";   mes "Because your amount of coins ins't dividable by 100";   close;   }    if(.@a < 100 || .@a > 1000) close; if(countitem(677) < .@a) {   mes "You don't have enough "+getitemname(677);   mes "You need "+(.@a - countitem(677))+" more "+getitemname(677);   close;   } next;   .@cp_credits = .@a/100;   mes "Here you go!";   mes "You will get "+.@cp_credits; query_sql("UPDATE `cp_credits` SET `balance` = `balance` + "+ .@cp_credits +" WHERE `account_id` = '"+getcharid(3)+"'");   delitem 677, .@a;   close;}

it can't just take 1234 coins, because if you will enter more than 1000, it will just interrupt the script.

 
Back
Top