Jump to content

Question

Posted

Hi! i always got DB Error - Data truncated for column `balance` at row 1

 

i dont know what to do, here's my script

 

            mes "You have a total of "+#VOTEPOINTS+" Vote Points.";
            mes "Would you like to convert it to credits?";
            mes "^ff0000Note:^000000 1 Vote Points = 1 Credits.";
            next;
            switch(select("Let me think first.:Yes, let's continue.")){
            case 1:
                    mes .npcName$;
                    mes "Come back if you already want to talk to me.";
                    close;
            case 2:
                    if(#VOTEPOINTS < 1){
                    mes .npcName$;
                    mes "You don't have enough Vote Points to convert.";
                    close;
                    }
                    else {
                    mes .npcName$;
                    mes "Put your desired amount to be converted.";
                    }
                    input @vote,0,#VOTEPOINTS;
                    
                    if( @vote < #VOTEPOINTS ){
                        next;
                        mes .npcName$;
                        mes "Not enough Vote Points.";
                        close;
                    }
                    else {
                        next;
                        mes .npcName$;
                        mes "Thank you! and come again.";
                        query_sql "UPDATE `cp_credits` SET `balance` = `balance` + @vote WHERE `account_id` = "+ getcharid(3) +" AND `balance` <> 0;";
                        set #VOTEPOINTS,#VOTEPOINTS-@vote;
                        close;
                }
        }

8 answers to this question

Recommended Posts

Posted

I think the query should look like this:

query_sql "UPDATE `cp_credits` SET `balance` = `balance` + " + @vote + " WHERE `account_id` = " + getcharid(3) + " AND `balance` <> 0;";

 

 

 

someone knows wtf  

 

AND `balance` <> 0;

means?

 

<> is the operator for "not equal", the same as !=

Posted

I think the query should look like this:

query_sql "UPDATE `cp_credits` SET `balance` = `balance` + " + @vote + " WHERE `account_id` = " + getcharid(3) + " AND `balance` <> 0;";

 

 

 

someone knows wtf  

 

AND `balance` <> 0;

means?

 

<> is the operator for "not equal", the same as !=

ahh thanks :D

Posted

I think the query should look like this:

query_sql "UPDATE `cp_credits` SET `balance` = `balance` + " + @vote + " WHERE `account_id` = " + getcharid(3) + " AND `balance` <> 0;";

 

 

 

someone knows wtf  

 

AND `balance` <> 0;

means?

 

<> is the operator for "not equal", the same as !=

 

Hi! i got problems when updating the cp_credits, i wiped out my server, then i try to vote, when i try to convert my votepoints to credits, it doesnt updating. please help.

Posted

I think the query should look like this:

query_sql "UPDATE `cp_credits` SET `balance` = `balance` + " + @vote + " WHERE `account_id` = " + getcharid(3) + " AND `balance` <> 0;";

 

 

 

someone knows wtf  

 

AND `balance` <> 0;

means?

 

<> is the operator for "not equal", the same as !=

 

Hi! i got problems when updating the cp_credits, i wiped out my server, then i try to vote, when i try to convert my votepoints to credits, it doesnt updating. please help.

 

Because update only works if there is something in the database to edit...

 

		query_sql "SELECT `account_id` FROM `cp_credits` WHERE `account_id` = "+getcharid(3)+";",.@a;
		mes "You have a total of "+#VOTEPOINTS+" Vote Points.";
		mes "Would you like to convert it to credits?";
		mes "^ff0000Note:^000000 1 Vote Points = 1 Credits.";
		next;
		switch(select("Let me think first.:Yes, let's continue.")) {
		case 1:
				mes .npcName$;
				mes "Come back if you already want to talk to me.";
				close;
		case 2:
			if(#VOTEPOINTS < 1) {
				mes .npcName$;
				mes "You don't have enough Vote Points to convert.";
				close;
			} else {
				mes .npcName$;
				mes "Put your desired amount to be converted.";
			}
			input @vote,0,#VOTEPOINTS;

			if( @vote < #VOTEPOINTS ) {
				next;
				mes .npcName$;
				mes "Not enough Vote Points.";
				close;
			} else {
				next;
				mes .npcName$;
				mes "Thank you! and come again.";
				if(.@a) query_sql "UPDATE `cp_credits` SET `balance` = `balance` + " + @vote + " WHERE `account_id` = " + getcharid(3) + " AND `balance` <> 0;";
				else query_sql "INSERT INTO `cp_credits` (account_id, balance) VALUES ("+getcharid(3)+", "+@vote+")";
				set #VOTEPOINTS,#VOTEPOINTS-@vote;
				close;
			}
		}
Posted

Hi

 

 

I think the query should look like this:

query_sql "UPDATE `cp_credits` SET `balance` = `balance` + " + @vote + " WHERE `account_id` = " + getcharid(3) + " AND `balance` <> 0;";

 

 

 

someone knows wtf  

 

AND `balance` <> 0;

means?

 

<> is the operator for "not equal", the same as !=

 

Hi! i got problems when updating the cp_credits, i wiped out my server, then i try to vote, when i try to convert my votepoints to credits, it doesnt updating. please help.

 

Because update only works if there is something in the database to edit...

 

		query_sql "SELECT `account_id` FROM `cp_credits` WHERE `account_id` = "+getcharid(3)+";",.@a;
		mes "You have a total of "+#VOTEPOINTS+" Vote Points.";
		mes "Would you like to convert it to credits?";
		mes "^ff0000Note:^000000 1 Vote Points = 1 Credits.";
		next;
		switch(select("Let me think first.:Yes, let's continue.")) {
		case 1:
				mes .npcName$;
				mes "Come back if you already want to talk to me.";
				close;
		case 2:
			if(#VOTEPOINTS < 1) {
				mes .npcName$;
				mes "You don't have enough Vote Points to convert.";
				close;
			} else {
				mes .npcName$;
				mes "Put your desired amount to be converted.";
			}
			input @vote,0,#VOTEPOINTS;

			if( @vote < #VOTEPOINTS ) {
				next;
				mes .npcName$;
				mes "Not enough Vote Points.";
				close;
			} else {
				next;
				mes .npcName$;
				mes "Thank you! and come again.";
				if(.@a) query_sql "UPDATE `cp_credits` SET `balance` = `balance` + " + @vote + " WHERE `account_id` = " + getcharid(3) + " AND `balance` <> 0;";
				else query_sql "INSERT INTO `cp_credits` (account_id, balance) VALUES ("+getcharid(3)+", "+@vote+")";
				set #VOTEPOINTS,#VOTEPOINTS-@vote;
				close;
			}
		}

 

Thanks! it worked, but i have notice that there is a problem, for example, i have 10 Vote Points, and i only want to convert 8 Points, it says i dont have enough vote points, but if i put the exact amount of my vote points, the npc will accept my input and then it will convert it.

Posted
if( @vote < #VOTEPOINTS ) {
	next;
	mes .npcName$;
	mes "Not enough Vote Points.";
	close;
}

you dont need this. ....

the input script command already limiting what number you can enter ..

input @vote,0,#VOTEPOINTS;

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...