sizenine Posted March 8, 2012 Group: Members Topic Count: 37 Topics Per Day: 0.01 Content Count: 149 Reputation: 13 Joined: 02/17/12 Last Seen: January 25, 2018 Share Posted March 8, 2012 query_sql "UPDATE `global_reg_value` SET `value` = '6' WHERE `char_id` = "+.@dest_id+" AND `str` = 'TEST_COUNT'"; it seems that when I use this command, my TEST_COUNT value does not update until my character relogs... is there anyway to update it without needing to kick the player off game? and i'm using this instead of set var because its used massively. Quote Link to comment Share on other sites More sharing options...
Emistry Posted March 8, 2012 Group: Forum Moderator Topic Count: 93 Topics Per Day: 0.02 Content Count: 10018 Reputation: 2370 Joined: 10/28/11 Last Seen: Sunday at 05:32 PM Share Posted March 8, 2012 i think you can do it like this way... just a simply sketch for the script... prontera,155,181,5 script Sample 757,{ mes "Write the Player name. must be ^FF0000ONLINE^000000"; input .@Name$; close2; announce .@Name$+" Your TEST_COUNT variable is set to 6."; attachrid( getcharid( 3,.@Name$ ) ); set TEST_COUNT,6; end; } Quote Link to comment Share on other sites More sharing options...
sizenine Posted March 8, 2012 Group: Members Topic Count: 37 Topics Per Day: 0.01 Content Count: 149 Reputation: 13 Joined: 02/17/12 Last Seen: January 25, 2018 Author Share Posted March 8, 2012 (edited) no... lol the only reason why i have to use query_sql is because it's in a for loop that goes through ALL existing characters in the database... which is why i said this is to be used massively on all players with one click, not just one person. Edited March 8, 2012 by sizenine Quote Link to comment Share on other sites More sharing options...
Emistry Posted March 8, 2012 Group: Forum Moderator Topic Count: 93 Topics Per Day: 0.02 Content Count: 10018 Reputation: 2370 Joined: 10/28/11 Last Seen: Sunday at 05:32 PM Share Posted March 8, 2012 huh ? goes through every character ? but your SQL only read for 1 character... Quote Link to comment Share on other sites More sharing options...
sizenine Posted March 8, 2012 Group: Members Topic Count: 37 Topics Per Day: 0.01 Content Count: 149 Reputation: 13 Joined: 02/17/12 Last Seen: January 25, 2018 Author Share Posted March 8, 2012 (edited) well that's because i didnt include the for loop part of my script.. and it's why the char id is a temp variable Edited March 8, 2012 by sizenine Quote Link to comment Share on other sites More sharing options...
Earthlingz Posted March 8, 2012 Group: Members Topic Count: 0 Topics Per Day: 0 Content Count: 187 Reputation: 35 Joined: 01/01/12 Last Seen: September 20, 2014 Share Posted March 8, 2012 when you do it in sql you will have to make the players logout.. so its better to execute it when your server is on maintenance/offline. Quote Link to comment Share on other sites More sharing options...
Emistry Posted March 8, 2012 Group: Forum Moderator Topic Count: 93 Topics Per Day: 0.02 Content Count: 10018 Reputation: 2370 Joined: 10/28/11 Last Seen: Sunday at 05:32 PM Share Posted March 8, 2012 well that's because i didnt include the for loop part of my script.. and it's why the char id is a temp variable i am try to refer on this part.. WHERE `char_id` = "+.@dest_id+" in your SQL command....you search for only 1 Character.... and yes..you should do it during server maintenance / offline.. or you have to kick the chracter out afterward to ensure the variable is updated corectly Quote Link to comment Share on other sites More sharing options...
Brian Posted March 8, 2012 Group: Members Topic Count: 75 Topics Per Day: 0.02 Content Count: 2223 Reputation: 593 Joined: 10/26/11 Last Seen: June 2, 2018 Share Posted March 8, 2012 no... lol the only reason why i have to use query_sql is because it's in a for loop that goes through ALL existing characters in the database... which is why i said this is to be used massively on all players with one click, not just one person. Add an if/else in your loop: if they are online (use 'attachrid' to check), then use set to update their variable else if they are offline, use query_sql to modify the variable in SQL. As you said, modifying their variables in SQL while they are online has no effect. Quote Link to comment Share on other sites More sharing options...
sizenine Posted March 9, 2012 Group: Members Topic Count: 37 Topics Per Day: 0.01 Content Count: 149 Reputation: 13 Joined: 02/17/12 Last Seen: January 25, 2018 Author Share Posted March 9, 2012 (edited) when you do it in sql you will have to make the players logout.. so its better to execute it when your server is on maintenance/offline. Yeah, i think that is my last resort though because I don't want to kick players off if it is possible to use an alternative method like the one brian posted below (except there's one conflict). no... lol the only reason why i have to use query_sql is because it's in a for loop that goes through ALL existing characters in the database... which is why i said this is to be used massively on all players with one click, not just one person. Add an if/else in your loop: if they are online (use 'attachrid' to check), then use set to update their variable else if they are offline, use query_sql to modify the variable in SQL. As you said, modifying their variables in SQL while they are online has no effect. yes, but the problem is that i'm trying to set a char variable, not an account variable. i think attachrid only works for account id, not char id. is there a custom script command anyone made so we can attach to char id? Edited March 9, 2012 by sizenine Quote Link to comment Share on other sites More sharing options...
Brian Posted March 9, 2012 Group: Members Topic Count: 75 Topics Per Day: 0.02 Content Count: 2223 Reputation: 593 Joined: 10/26/11 Last Seen: June 2, 2018 Share Posted March 9, 2012 if (isloggedin(<account id>,<char id>)) { attachrid <account_id>; // use 'set' to modify variable } else { // char is offline or on a different char of the account // use 'query_sql' } Quote Link to comment Share on other sites More sharing options...
sizenine Posted March 9, 2012 Group: Members Topic Count: 37 Topics Per Day: 0.01 Content Count: 149 Reputation: 13 Joined: 02/17/12 Last Seen: January 25, 2018 Author Share Posted March 9, 2012 (edited) if (isloggedin(<account id>,<char id>)) { attachrid <account_id>; // use 'set' to modify variable } else { // char is offline or on a different char of the account // use 'query_sql' } so you mean that i can use "set COUNTER,1;" with "attachrid <account_id>;" even though no char id is given to set with? im just curious of how the set command will know which char within that account_id to set the COUNTER to.. because COUNTER var is attached to a char and not the account(#). UPDATE: it works! thanks so much brian. i guess what i didnt understand is that attachrid actually attaches to the online player of the account rather than the whole account. Edited March 9, 2012 by sizenine Quote Link to comment Share on other sites More sharing options...
Question
sizenine
query_sql "UPDATE `global_reg_value` SET `value` = '6' WHERE `char_id` = "+.@dest_id+" AND `str` = 'TEST_COUNT'";
it seems that when I use this command, my TEST_COUNT value does not update until my character relogs...
is there anyway to update it without needing to kick the player off game? and i'm using this instead of set var because its used massively.
Link to comment
Share on other sites
10 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.