query sql

Break San

New member
Messages
240
Points
0
Location
França
I'm trying to add script option trading 3 points for 1 day vip, more is wrong giving someone help?

Code:
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;
 
Code:
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;
 
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

 
Last edited by a moderator:
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?

 
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?

 
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.

Code:
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;
 
Last edited by a moderator:
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.

 
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.

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

 
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

Code:
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;}
 
atcommand "@adjgroup 1";

You missed the @.

 
Last edited by a moderator:
That's just a volatile change that will be removed upon logout and is not saved anywhere else but server's RAM.

 
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

default_ani_meow.gif


 
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

default_ani_meow.gif

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

Code:
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;
 
Last edited by a moderator:
Back
Top