PDA

View Full Version : The mass deletion of client. and clientr. variables! Yay!


zokemon
11-09-2006, 04:27 AM
So I want to be able to delete mass amounts of client. and clientr. variables in the most efficient way.

First thing I tried:

for (temp.d : client.blah.getdynamicvarnames()) {
("client.blah." @ temp.d) = "";
}

A for loop that checks all the getdynamicvarnames() and deletes all that data in each sub variable. Problem here is you get a "folder depth" issue where you have to have for loops inside for loops if you have variables like this:
client.blah.rar.test (while trying to clear client.blah)

This method works but is obviously very lag intensive.

Second thing I tried:

client.blah.copyfrom(null);

This is a much easier way to clear all the data and sub-variables in the variable but there remains a big problem with client. and clientr. variables:
If a client. or clientr. variable is cleared using a method such as copyfrom(), The effect can be seen on the side it is done on (clientside or serverside) but the effect does not transfer over to the other side and also does not save to the account (you don't see the changes if you do "/open account" in rc).

Third thing I tried

client.blah = new TStaticVar("client.blah");
client.blah.destroy();
client.blah = new TGraalVar("client.blah");

Maybe making a client. or clientr. variable an object and then destroying it will work? Not quiet. It deletes all the data and sub-variables like we want but it has the same problem as above: The data does transfer to the other side.

So...

Anyone have another way to do this? Thoughts on the process? Ideas? Questions? Comments?

Thanks,
- Zero

Andy0687
11-09-2006, 08:09 AM
for (i: getstringkeys("client.foo.")) {
client.foo.(@ i) = NULL;
}

im suprised 27 views before me and I still managed to get here in time. But there you go.

zokemon
11-09-2006, 08:59 AM
for (i: getstringkeys("client.foo.")) {
client.foo.(@ i) = NULL;
}

im suprised 27 views before me and I still managed to get here in time. But there you go.

First thing I tried:

for (temp.d : client.blah.getdynamicvarnames()) {
("client.blah." @ temp.d) = "";
}

A for loop that checks all the getdynamicvarnames() and deletes all that data in each sub variable. Problem here is you get a "folder depth" issue where you have to have for loops inside for loops if you have variables like this:
client.blah.rar.test (while trying to clear client.blah)

This method works but is obviously very lag intensive.

Already did that. Please read what I said and what I am asking.

KuJi
11-09-2006, 08:59 AM
Already did that. Please read what I said and what I am asking.

How many sub categories can it go in from client.?

zokemon
11-09-2006, 09:02 AM
How many sub categories can it go in from client.?

As many loops as you are willing to add. I suppose you could do some sort of function loop but all of this is very bad and laggy.

Andy0687
11-09-2006, 09:12 AM
Already did that. Please read what I said and what I am asking.

Mmm, sorry about that, I skipped over the part where you said about "folder depth" issues, how many variables could you have where it becomes THAT laggy anyways for such a long period of time that it would become an incuberance to gameplay?

xAndrewx
11-09-2006, 10:19 AM
I see the bug, knda
I did this though, dunno if it's of value


temp.curList = getstringkeys("client.");
this.clearList("client.", temp.curList);

function clearList(stringType, currentList)
{
for (temp.curString: temp.currentList)
{
unset( (@ temp.stringType @ temp.curString) );
}
}

zokemon
11-09-2006, 09:24 PM
Mmm, sorry about that, I skipped over the part where you said about "folder depth" issues, how many variables could you have where it becomes THAT laggy anyways for such a long period of time that it would become an incuberance to gameplay?

It is not so much an incuberance to game play as it is simply an issue of having more serverside cpu usage. I have many cases where I have to delete huge sections of variables because savevars() does not delete variables that aren't actually writen in the txt you are calling it from.

My 1st method is the method I am using right now...I just wanted to know if someone found a better way...

I see the bug, knda
I did this though, dunno if it's of value


temp.curList = getstringkeys("client.");
this.clearList("client.", temp.curList);

function clearList(stringType, currentList)
{
for (temp.curString: temp.currentList)
{
unset( (@ temp.stringType @ temp.curString) );
}
}


That is pretty much what I did in my first method except you seemed to add a little more unnecessary code.

xAndrewx
11-09-2006, 10:42 PM
Ooh, you're wanting to clear a document?

Admins
11-10-2006, 02:37 AM
Probably client.blah = ""; should be enough, if that is not working then it should be made working I guess.

zokemon
11-10-2006, 03:24 AM
No I just want to clear a large number of variables o_o

Novo
11-10-2006, 08:50 AM
function onCreated()
{
clearList( "client" );
}

function clearList( strName )
{
for ( temp.d: makevar( strName ).getvarnames() )
clearList( strName @"."@ temp.d );

makevar( strName ) = "";
}

zokemon
11-10-2006, 10:02 AM
Yes I mentioned that you can do that via functions but it doesn't show a less lag instensive way.