Break San 3 Posted December 3, 2014 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; Quote Share this post Link to post Share on other sites
0 evilpuncker 503 Posted December 3, 2014 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; Quote Share this post Link to post Share on other sites
0 Break San 3 Posted December 3, 2014 (edited) 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 December 3, 2014 by Break San Quote Share this post Link to post Share on other sites
0 evilpuncker 503 Posted December 3, 2014 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? Quote Share this post Link to post Share on other sites
0 Break San 3 Posted December 3, 2014 No, the points are normally consumed only update that is not done Quote Share this post Link to post Share on other sites
0 evilpuncker 503 Posted December 3, 2014 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? Quote Share this post Link to post Share on other sites
0 Break San 3 Posted December 3, 2014 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 Quote Share this post Link to post Share on other sites
0 Garr 117 Posted December 3, 2014 (edited) 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 December 3, 2014 by Garr 1 Break San reacted to this Quote Share this post Link to post Share on other sites
0 Break San 3 Posted December 3, 2014 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. Quote Share this post Link to post Share on other sites
0 Garr 117 Posted December 3, 2014 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. Quote Share this post Link to post Share on other sites
0 Break San 3 Posted December 3, 2014 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? Quote Share this post Link to post Share on other sites
0 jaBote 438 Posted December 3, 2014 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. Quote Share this post Link to post Share on other sites
0 Break San 3 Posted December 4, 2014 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;} Quote Share this post Link to post Share on other sites
0 jaBote 438 Posted December 4, 2014 atcommand "@adjgroup 1"; You missed the @. Quote Share this post Link to post Share on other sites
0 Break San 3 Posted December 5, 2014 atcommand "@adjgroup 1"; You missed the @. Added, gave no error in the console more group_id not changed group_id = 1 / One day Quote Share this post Link to post Share on other sites
0 jaBote 438 Posted December 5, 2014 That's just a volatile change that will be removed upon logout and is not saved anywhere else but server's RAM. Quote Share this post Link to post Share on other sites
0 Break San 3 Posted December 5, 2014 jaBoteThe problem that this not working, I do not understand why, The points are being consumed normally, just not doing the change in table Quote Share this post Link to post Share on other sites
0 malufett 247 Posted December 5, 2014 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 1 pr3p reacted to this Quote Share this post Link to post Share on other sites
0 Break San 3 Posted December 5, 2014 (edited) 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 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 December 5, 2014 by Break San Quote Share this post Link to post Share on other sites
0 sbk_ 30 Posted December 6, 2014 test> SET `group_id`='1' Quote Share this post Link to post Share on other sites
0 Break San 3 Posted December 8, 2014 test> SET `group_id`='1' It did not work, it has not done the update Quote Share this post Link to post Share on other sites
0 malufett 247 Posted December 8, 2014 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);}*/ 1 Break San reacted to this Quote Share this post Link to post Share on other sites
0 Break San 3 Posted December 9, 2014 (edited) 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);}*/ 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 December 9, 2014 by Break San Quote Share this post Link to post Share on other sites
I'm trying to add script option trading 3 points for 1 day vip, more is wrong giving someone help?
Share this post
Link to post
Share on other sites