Jump to content
  • 0

Variables not resetting unless log off


ToiletMaster

Question


  • Group:  Members
  • Topic Count:  76
  • Topics Per Day:  0.02
  • Content Count:  276
  • Reputation:   7
  • Joined:  08/11/12
  • Last Seen:  

Hi everyone,

 

i seem to be having an issue, as we store permanent character variables in char_reg_num, i have a script that deletes this on a timed basis.

 

	query_sql( "DELETE FROM `char_reg_num` WHERE `key`='variable' " );

However, the problem i find out is that the variables only saves once the person logs out, thus if the person interacts with the NPC and for example gets an additional ranking, it'll be the old value + new value together.

 

For example

Value before Scripts deletes the variables

  • Variable = 100

 

If the person interacts with the NPC and let's say the variable adds 10 without logging off,

  • Variable = 110

If the person interacts with the NPC and let's say the variable adds 10 after logging off

  • Variable = 10

 

Is there any way to force it to clear the values? This is because i'm using a SQL based ranking for this and players are able to add that variable by themselves. Similar to Rachel's donation quest to open the gateway but instead with a ranking.

 

 

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 1

  • Group:  Developer
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  141
  • Reputation:   45
  • Joined:  08/14/12
  • Last Seen:  

You can use addrid https://github.com/rathena/rathena/blob/master/doc/script_commands.txt#L3824-L3844

It will look something like this:

	addrid(0);
	variable = 0;
	detachrid();
	query_sql( "DELETE FROM `char_reg_num` WHERE `key`='variable' " );

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  76
  • Topics Per Day:  0.02
  • Content Count:  276
  • Reputation:   7
  • Joined:  08/11/12
  • Last Seen:  

Thanks a lot @Nitrous ,

 

I've tested this and it works perfectly!

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