Saving Variables in a Plugin

Posted by Tjcheckley on Wed 25 Jan 2012 03:44 AM — 2 posts, 10,248 views.

#0
Currently I have an autodonater plugin that I wrote. It automatically donates 1k gold to my clan on aardwolf for every clan member's power-up or level-up every 12 hours. It then keeps track of how much gold and how many levels and power-ups (pups) have been donated for. When I made the triggers, aliases, variables, and timers into a plugin I got this for the variables section:

<!-- Variables -->

<variables>
<variable name="mPups">0</variable>
<variable name="tGold">0</variable>
<variable name="tPups">0</variable>
<variable name="dGold">0</variable>
<variable name="mLevels">0</variable>
<variable name="tLevels">0</variable>
<variable name="modLevel">1000</variable>
<variable name="modPup">1000</variable>
</variables>

Everything works fine but when I quit out of the client and come back everything is back to zero for total gold donated, etc. Is there a way to fix this? Should the variables be left out of the plugin altogether?

Thanks,
Visible
Australia Forum Administrator #1
Yes. You can use variables in a plugin, and write to them with SetVariable. They are saved if you have "saving state" enabled, and loaded again next time.

But if you actually put them in the plugin file like that, they overwrite whatever saved variables you might have had.