Jump to content
  • 0

need help with a query_sql command


sizenine

Question


  • Group:  Members
  • Topic Count:  37
  • Topics Per Day:  0.01
  • Content Count:  149
  • Reputation:   12
  • Joined:  02/17/12
  • Last Seen:  

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


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

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;
}

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  37
  • Topics Per Day:  0.01
  • Content Count:  149
  • Reputation:   12
  • Joined:  02/17/12
  • Last Seen:  

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 by sizenine
Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

huh ? goes through every character ?

but your SQL only read for 1 character...

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  37
  • Topics Per Day:  0.01
  • Content Count:  149
  • Reputation:   12
  • Joined:  02/17/12
  • Last Seen:  

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 by sizenine
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  187
  • Reputation:   35
  • Joined:  01/01/12
  • Last Seen:  

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.

Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

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

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  75
  • Topics Per Day:  0.02
  • Content Count:  2223
  • Reputation:   593
  • Joined:  10/26/11
  • Last Seen:  

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.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  37
  • Topics Per Day:  0.01
  • Content Count:  149
  • Reputation:   12
  • Joined:  02/17/12
  • Last Seen:  

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 by sizenine
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  75
  • Topics Per Day:  0.02
  • Content Count:  2223
  • Reputation:   593
  • Joined:  10/26/11
  • Last Seen:  

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'
}

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  37
  • Topics Per Day:  0.01
  • Content Count:  149
  • Reputation:   12
  • Joined:  02/17/12
  • Last Seen:  

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 by sizenine
Link to comment
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.   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.

×
×
  • Create New...