Jump to content
  • 0
Helena

Deposit items redeemed from CP back to it.

Question

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

 

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;}
Edited by Helena

Share this post


Link to post
Share on other sites

8 answers to this question

Recommended Posts

  • 0

 

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

 

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.

Edited by Oxxy

Share this post


Link to post
Share on other sites
  • 0

 

 

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

 

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

 

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

Edited by Helena

Share this post


Link to post
Share on other sites
  • 0

After:

    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:

if(.@a < 100 || .@a > 1000) close;

Edited by Oxxy

Share this post


Link to post
Share on other sites
  • 0

 

 

 

 

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

 

 

 

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.

 

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

 

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 possible

input .@a,100,1000;

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

Share this post


Link to post
Share on other sites
  • 0

 

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

Edited by Helena

Share this post


Link to post
Share on other sites
  • 0

 

 

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

Check my post again.

Share this post


Link to post
Share on other sites
  • 0

 

 

 

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

Check my post again.

 

Made the edit but oddly it still takes it.

Share this post


Link to post
Share on other sites
  • 0

 

 

 

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

 

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

 

 

 

 

 

 

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

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.

Share this post


Link to post
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.   Restore formatting

  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.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.