OK I'll say this just once, if I ditch VCE - I'd have to remake EVERYTHING. That means everything on my server will be wrong and I'd need to fix it. I am not willing to do this.
Taking the time to improve your code is part of being a good programmer. It won't take long (rewriting this function would have taken less than 5 minutes if I wasn't looking for/fixing other issues), and it will potentially save many headaches, as well as save everyone the hassle of clicking save and load bricks. Using a better method will allow you to modify the values directly, and save only the ones needed, only when needed, instead of constantly saving everything
Issues/Suggestions (some are fixed in the code I gave you, some are not)
I do like that you made global variables instead of magic numbers, but if this is a bigger project with many more, I would give them all a common prefix, for example, $RP::Interest::* (I'll call it RP because I have no idea what to call it)
If the client's score is greater than Interest::CutOff[2] they will be taxed twice, once according to Percentage[0] and once according to Percentage[2]. (fixed)
Why are you setting InterestTickCount to 0? Doing this, combined with not taxing if InterestTickCount is less than 10, results in running the function every minute, but only actually doing anything every 10 minutes.
You misspelled interest in several places (fixed)
$Interest::CutOff[0] = "100";
$Interest::Percentage[0] = "1";
$Interest::CutOff[2] = "20000";
$Interest::Percentage[2] = "4";
$Interest::TickTime = 10;
function interestTick()
{
cancel($interestTickShed);
$interestTickShed = schedule(60000, 0, interestTick);
$InterestTickCount++;
if($InterestTickCount < ($Interest::TickTime - 1))
return;
for(%i = 0; %i < clientGroup.getCount(); %i++)
{
%client = clientGroup.getObject(%i);
%score = %client.score;
if(%score > $Interest::CutOff[0])
%per = %score * (0.01 * $Interest::Percentage[0]);
else if(%score > $Interest::CutOff[2])
%per = %score * (0.01 * $Interest::Percentage[2]);
%per = mCeil(%per);
%score-=%per;
messageClient(%client, '', "\c2You have been taxed \c6" @ %per @ "\c2 points.");
messageClient(%client, '', "\c2You now have a total of \c6" @ %num @ "\c2 points.");
%client.setScore(%num);
}
$InterestTickCount = 0;
}
interestTick();
You'd also want to to put this in server.cs
LoadRequiredAddOn("Script_Player_Persistence");
if(isFunction(RegisterPersistenceVar))
{
RegisterPersistenceVar("rp", true, "");
// RegisterPersistenceVar("someOtherVariable", false, "");
}
And then every client field you create for your RP will be named starting with rp, and PlayerPersistence will take care of all saving and loading for you.
You could change rp to something else too.
For default fields that you want saved, but are not saved by the default Player Persistance, add lines similar to commented out second RegisterPersistenceVar function.
Keep in mind the default Player Persistence will save some fields you may not want saved, I'm not sure how to make it unregister them