Jump to content
  • 0
Sign in to follow this  
Break San

query sql

Question

I'm trying to add script option trading 3 points for 1 day vip, more is wrong giving someone help?

 

mes "Okay!";set .@account_id,getcharid(3);set .@usedPoints,3;set $nivelVip, 1;set $diasVip, 1;set $verificaVip, 1;query_sql("UPDATE `cp_v4p_voters` SET points=(points-"+.@usedPoints+") WHERE account_id='"+.@account_id+"'");if (getgroupid() == 0){query_sql "UPDATE `login` SET `group_id` = "+$nivelVip+", `dt_vip` = DATE_ADD(`dt_vip`,INTERVAL "+$diasVip+" DAY) WHERE `group_id` = "+$nivelVip+" AND `account_id` = "+getcharid(3);dispbottom "Relogue para ter seu VIP ativado.";}else{query_sql "UPDATE `login` SET `group_id` = "+$nivelVip+", `dt_vip` = DATE_ADD(`dt_vip`,INTERVAL "+$diasVip+" DAY) WHERE `group_id` = "+$nivelVip+" AND `account_id` = "+getcharid(3);}garbagecol();close2;message strcharinfo(0),"Points added";end;

 

Share this post


Link to post
Share on other sites

22 answers to this question

Recommended Posts

  • 0
mes "Okay!";.@account_id = getcharid(3);.@usedPoints = 3;.nivelVip = 1;.diasVip = 1;$verificaVip = 1;query_sql("UPDATE `cp_v4p_voters` SET points=(points-"+.@usedPoints+") WHERE account_id='"+.@account_id+"'");if (getgroupid() == 0){query_sql "UPDATE `login` SET `group_id` = "+.nivelVip+", `dt_vip` = DATE_ADD(`dt_vip`,INTERVAL "+.diasVip+" DAY) WHERE `group_id` = "+.nivelVip+" AND `account_id` = "+getcharid(3);dispbottom "Relogue para ter seu VIP ativado.";} else {query_sql "UPDATE `login` SET `group_id` = "+.nivelVip+", `dt_vip` = DATE_ADD(`dt_vip`,INTERVAL "+.diasVip+" DAY) WHERE `group_id` = "+.nivelVip+" AND `account_id` = "+getcharid(3);}close2;message strcharinfo(0),"Points added";end;

Share this post


Link to post
Share on other sites
  • 0

 

mes "Okay!";.@account_id = getcharid(3);.@usedPoints = 3;.nivelVip = 1;.diasVip = 1;$verificaVip = 1;query_sql("UPDATE `cp_v4p_voters` SET points=(points-"+.@usedPoints+") WHERE account_id='"+.@account_id+"'");if (getgroupid() == 0){query_sql "UPDATE `login` SET `group_id` = "+.nivelVip+", `dt_vip` = DATE_ADD(`dt_vip`,INTERVAL "+.diasVip+" DAY) WHERE `group_id` = "+.nivelVip+" AND `account_id` = "+getcharid(3);dispbottom "Relogue para ter seu VIP ativado.";} else {query_sql "UPDATE `login` SET `group_id` = "+.nivelVip+", `dt_vip` = DATE_ADD(`dt_vip`,INTERVAL "+.diasVip+" DAY) WHERE `group_id` = "+.nivelVip+" AND `account_id` = "+getcharid(3);}close2;message strcharinfo(0),"Points added";end;

It did not work, I'll post the full script

Points are consumed is not only made the update on the table

 

http://pastebin.com/yx19q9yx

Edited by Break San

Share this post


Link to post
Share on other sites
  • 0

 

 

mes "Okay!";.@account_id = getcharid(3);.@usedPoints = 3;.nivelVip = 1;.diasVip = 1;$verificaVip = 1;query_sql("UPDATE `cp_v4p_voters` SET points=(points-"+.@usedPoints+") WHERE account_id='"+.@account_id+"'");if (getgroupid() == 0){query_sql "UPDATE `login` SET `group_id` = "+.nivelVip+", `dt_vip` = DATE_ADD(`dt_vip`,INTERVAL "+.diasVip+" DAY) WHERE `group_id` = "+.nivelVip+" AND `account_id` = "+getcharid(3);dispbottom "Relogue para ter seu VIP ativado.";} else {query_sql "UPDATE `login` SET `group_id` = "+.nivelVip+", `dt_vip` = DATE_ADD(`dt_vip`,INTERVAL "+.diasVip+" DAY) WHERE `group_id` = "+.nivelVip+" AND `account_id` = "+getcharid(3);}close2;message strcharinfo(0),"Points added";end;

It did not work, I'll post the full script

Points are consumed is not only made the update on the table

 

http://pastebin.com/yx19q9yx

any error on console?

Share this post


Link to post
Share on other sites
  • 0

No, the points are normally consumed only update that is not done

 

are you using hercules or another emulator? If you are using hercules, are you using a recent version of it?

Share this post


Link to post
Share on other sites
  • 0

 

No, the points are normally consumed only update that is not done

 

are you using hercules or another emulator? If you are using hercules, are you using a recent version of it?

 

Yes I am using the latest version of Hercules.

 

I think the problem only in the update

For the script works

Share this post


Link to post
Share on other sites
  • 0

Umm, corect me if I'm wrong, but isn't performing queries on online character data is useless? It'll get resaved again on log off. I think you'd be better off kicking the character before sql query.

mes "Okay!";.@account_id = getcharid(3);.@usedPoints = 3;.nivelVip = 1;.diasVip = 1;$verificaVip = 1;query_sql("UPDATE `cp_v4p_voters` SET points=(points-"+.@usedPoints+") WHERE account_id='"+.@account_id+"'");atcommand "@kick " + strcharinfo(0);if (getgroupid() == 0){query_sql "UPDATE `login` SET `group_id` = "+.nivelVip+", `dt_vip` = DATE_ADD(`dt_vip`,INTERVAL "+.diasVip+" DAY) WHERE `group_id` = "+.nivelVip+" AND `account_id` = "+getcharid(3);} else {query_sql "UPDATE `login` SET `group_id` = "+.nivelVip+", `dt_vip` = DATE_ADD(`dt_vip`,INTERVAL "+.diasVip+" DAY) WHERE `group_id` = "+.nivelVip+" AND `account_id` = "+getcharid(3);}end;
Edited by Garr

Share this post


Link to post
Share on other sites
  • 0

 

Umm, corect me if I'm wrong, but isn't performing queries on online character data is useless? It'll get resaved again on log off. I think you'd be better off kicking the character before sql query.

mes "Okay!";.@account_id = getcharid(3);.@usedPoints = 3;.nivelVip = 1;.diasVip = 1;$verificaVip = 1;query_sql("UPDATE `cp_v4p_voters` SET points=(points-"+.@usedPoints+") WHERE account_id='"+.@account_id+"'");atcommand "@kick " + strcharinfo(0);if (getgroupid() == 0){query_sql "UPDATE `login` SET `group_id` = "+.nivelVip+", `dt_vip` = DATE_ADD(`dt_vip`,INTERVAL "+.diasVip+" DAY) WHERE `group_id` = "+.nivelVip+" AND `account_id` = "+getcharid(3);} else {query_sql "UPDATE `login` SET `group_id` = "+.nivelVip+", `dt_vip` = DATE_ADD(`dt_vip`,INTERVAL "+.diasVip+" DAY) WHERE `group_id` = "+.nivelVip+" AND `account_id` = "+getcharid(3);}end;

 

 

The off was done, the problem that this does not alter the group_id to 1, and leaving it only for 1 day in the table dt_vip.

This script is just to get the three points of the vote and return for a day of vip.

Share this post


Link to post
Share on other sites
  • 0

As I said, altering the group_id is useless while character is online, and by your script he's online during your queries. The thing is, it DOES alter the login table, but when the player logs off or some time passes, his group will reset to 0, as it is initialised in his session data. That's why I offered you to kick the player, and then perform queries on the login table.

Share this post


Link to post
Share on other sites
  • 0

As I said, altering the group_id is useless while character is online, and by your script he's online during your queries. The thing is, it DOES alter the login table, but when the player logs off or some time passes, his group will reset to 0, as it is initialised in his session data. That's why I offered you to kick the player, and then perform queries on the login table.

 

Yes I did, I made the change as you posted.
But the group_id is not changing.
I take off again when just continue with group_id = 0
You can review the script?

Share this post


Link to post
Share on other sites
  • 0

You could alter the group id via SQL, then use @adjgroup script command to grant the desired group id to the user for his current session.

Share this post


Link to post
Share on other sites
  • 0

You could alter the group id via SQL, then use @adjgroup script command to grant the desired group id to the user for his current session.

 

This would? tested is giving debug

mes "Okay!";set .@account_id,getcharid(3);set .@usedPoints,3;set $nivelVip, 1;set $diasVip, 1;set $verificaVip, 1;query_sql("UPDATE `cp_v4p_voters` SET points=(points-"+.@usedPoints+") WHERE account_id='"+.@account_id+"'");if (getgroupid() == 0){atcommand "adjgroup 1 " ;query_sql "UPDATE `login` SET `group_id` = "+$nivelVip+", `dt_vip` = DATE_ADD(`dt_vip`,INTERVAL "+$diasVip+" DAY) WHERE `group_id` = "+$nivelVip+" AND `account_id` = "+getcharid(3);dispbottom "Relogue to get your VIP activated.";}else{query_sql "UPDATE `login` SET `group_id` = "+$nivelVip+", `dt_vip` = DATE_ADD(`dt_vip`,INTERVAL "+$diasVip+" DAY) WHERE `group_id` = "+$nivelVip+" AND `account_id` = "+getcharid(3);}garbagecol();close2;message strcharinfo(0),"points added";end;case 2:close;}

Share this post


Link to post
Share on other sites
  • 0

the problem is your query has illogical condition...

let's simplify this way..look at this

$nivelVip = 1;UPDATE `login` SET `group_id` = "+$nivelVip+", `dt_vip` = DATE_ADD(`dt_vip`,INTERVAL "+$diasVip+" DAY) WHERE `group_id` = "+$nivelVip

when we evaluate it ..

 

UPDATE `login` SET `group_id` = 1... WHERE `group_id` = 1

 

so if initially group_id is 0 it will never ever happen to set to 1 if the condition is `group_id` = 1

and even your else block of 'if (getgroupid() == 0)' is useless if you try to evaluate it

 

:meow:

Share this post


Link to post
Share on other sites
  • 0

the problem is your query has illogical condition...

let's simplify this way..look at this

$nivelVip = 1;UPDATE `login` SET `group_id` = "+$nivelVip+", `dt_vip` = DATE_ADD(`dt_vip`,INTERVAL "+$diasVip+" DAY) WHERE `group_id` = "+$nivelVip

when we evaluate it ..

 

UPDATE `login` SET `group_id` = 1... WHERE `group_id` = 1

 

so if initially group_id is 0 it will never ever happen to set to 1 if the condition is `group_id` = 1

and even your else block of 'if (getgroupid() == 0)' is useless if you try to evaluate it

 

:meow:

 

 

More needs to be validated for one day, that is, an exchange point for 1 day 3 vip


mes "Okay!";.@account_id = getcharid(3);.@usedPoints = 3;.nivelVip = 1;.diasVip = 1;$verificaVip = 1;query_sql("UPDATE `cp_v4p_voters` SET points=(points-"+.@usedPoints+") WHERE account_id='"+.@account_id+"'");atcommand "@kick " + strcharinfo(0);if (getgroupid() == 0){query_sql "UPDATE `login` SET `group_id` = 1, `dt_vip` = DATE_ADD(`dt_vip`,INTERVAL "+$diasVip+" DAY) WHERE `group_id` = 1 AND `account_id` = "+getcharid(3);dispbottom "Relogue para ter seu VIP ativado.";}else{query_sql "UPDATE `login` SET `group_id` = 1, `dt_vip` = DATE_ADD(`dt_vip`,INTERVAL "+$diasVip+" DAY) WHERE `group_id` = 1 AND `account_id` = "+getcharid(3);}garbagecol();close2;message strcharinfo(0),"Pontos adicionados";end;

 

Edited by Break San

Share this post


Link to post
Share on other sites
  • 0

I don't know if you get me..

use this

if (getgroupid() == 0){query_sql "UPDATE `login` SET `group_id` = 1, `dt_vip` = DATE_ADD(`dt_vip`,INTERVAL "+$diasVip+" DAY) WHERE `group_id` = 0 AND `account_id` = "+getcharid(3);dispbottom "Relogue para ter seu VIP ativado.";}/** I don't know why it is here is this used for removing group id?else{query_sql "UPDATE `login` SET `group_id` = 1, `dt_vip` = DATE_ADD(`dt_vip`,INTERVAL "+$diasVip+" DAY) WHERE `group_id` = 1 AND `account_id` = "+getcharid(3);}*/

 

 

:meow:

Share this post


Link to post
Share on other sites
  • 0

I don't know if you get me..

use this

if (getgroupid() == 0){query_sql "UPDATE `login` SET `group_id` = 1, `dt_vip` = DATE_ADD(`dt_vip`,INTERVAL "+$diasVip+" DAY) WHERE `group_id` = 0 AND `account_id` = "+getcharid(3);dispbottom "Relogue para ter seu VIP ativado.";}/** I don't know why it is here is this used for removing group id?else{query_sql "UPDATE `login` SET `group_id` = 1, `dt_vip` = DATE_ADD(`dt_vip`,INTERVAL "+$diasVip+" DAY) WHERE `group_id` = 1 AND `account_id` = "+getcharid(3);}*/

 

 

:meow:

 

Making the group_id to 1, but if I log back 2 times back to group_id 0.

 

The dt_vip is not changing.

 

@edit

 

Resolved

 

I used the following code

set .@account_id,getcharid(3);updatePoints( .@account_id,-3 );query_sql "UPDATE `login` SET `dt_vip` = if( `group_id` = 1 and `dt_vip` > now(), `dt_vip` + INTERVAL 1 day, now() + interval 1 day ), `group_id` = 1  WHERE `account_id` = "+ .@account_id;atcommand "@adjgroup 1";garbagecol();close2;end;

 

 

Edited by Break San

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...
Sign in to follow this  

×
×
  • Create New...

Important Information

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