Jump to content
  • 0

Player not attached! - getcharid(3)


Vincent

Question


  • Group:  Members
  • Topic Count:  130
  • Topics Per Day:  0.03
  • Content Count:  528
  • Reputation:   18
  • Joined:  09/11/12
  • Last Seen:  

Hello,

this script is not working for some reason. Did anyone know whats the problem?

-	script	g_activ	-1,{

OnSat1437:

		query_sql "SELECT `this_week` FROM `char` WHERE `account_id` = " + getcharid(3) + "", .@this_week;
		
		query_sql"UPDATE `char` SET `last_week` = "+.@this_week+" WHERE `account_id` = " + getcharid(3);
		
		query_sql"UPDATE `char` SET `this_week` = 0 WHERE `account_id` = " + getcharid(3);
}

Error:

[Error]: script_rid2sd: fatal error ! player not attached!
[Debug]: Function: getcharid (1 parameter):
[Debug]: Data: number value=3
[Debug]: Source (NPC): g_activ (invisible/not on a map)
Link to comment
Share on other sites

4 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.01
  • Content Count:  666
  • Reputation:   93
  • Joined:  04/27/12
  • Last Seen:  

The problem is, your making the script call:  getcharid(3) automatically, but the issue with that is there isn't a player attached.

If your going to use it in this method, you need to apply the optional parameter of specifying what player to get the id from.

 

ex:

query_sql "SELECT `this_week` FROM `char` WHERE `account_id` = " + getcharid(3, "player_name") + "", .@this_week;
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  130
  • Topics Per Day:  0.03
  • Content Count:  528
  • Reputation:   18
  • Joined:  09/11/12
  • Last Seen:  

 

The problem is, your making the script call:  getcharid(3) automatically, but the issue with that is there isn't a player attached.

If your going to use it in this method, you need to apply the optional parameter of specifying what player to get the id from.

 

ex:

query_sql "SELECT `this_week` FROM `char` WHERE `account_id` = " + getcharid(3, "player_name") + "", .@this_week;

oh damn, i am such a idot. For sure.

 

All the code is wrong at the top, i need  for each player this colum. So i save all acc_ids in the array and now i need to got to each player to update it. How i can i do a loop till the end of the array?!

 
 
This is an not working code, but dont know why.
OnSat1437:
		query_sql "SELECT `account_id` FROM `char` ", .@all_accs$[];
		
		.@array_size = getarraysize( .@all_accs$[] );
		
		for (set @i,0; @i < .@array_size; set @i,@i+1)
		{
		query_sql "SELECT `this_week` FROM `char` WHERE `account_id` = " + .@all_accs$[i] + "", .@this_week;
		
		query_sql"UPDATE `char` SET `last_week` = "+.@this_week+" WHERE `account_id` = " + .@all_accs$[i];
		
		query_sql"UPDATE `char` SET `this_week` = 0 WHERE `account_id` = " + .@all_accs$[i];
		}

Edited by Vincent
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.01
  • Content Count:  666
  • Reputation:   93
  • Joined:  04/27/12
  • Last Seen:  

You need to limit your arrays to 128. Right now your telling sql to fetch ALL your account IDs at 1 time, but rAthena only supports a max of 128 per array.

query_sql("SELECT account_id FROM `char` LIMIT 128;",.@account_ids);

But, this is only HOW you limit it, what you need to do is loop this query until it's completely retrieved all the information, so we'll change it to this:

do {
   set .@results, query_sql("SELECT account_id FROM `char` LIMIT 128,"+ .@page +"",.@account_ids);
   for (set .@x,0; .@x < .@results; set .@x, .@x + 1) {
                    blah;
                    blah;
                    blah;
                    blah;
                    blah;
   }
    set .@page,.@page + 128;
} while (.@results);

Replace blah blah blah blah, with the update query's, and this SHOULD effectively continuously loop through all account_ids and then do what you want with them until they are all done.

Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  

you want to set last_week equal this_week and this_week equal 0 for all account right? what about

OnSat1437:
	query_sql "UPDATE `char` SET `last_week` = `this_week`, `this_week` = 0";
	end;
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...