Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   The mass deletion of client. and clientr. variables! Yay! (https://forums.graalonline.com/forums/showthread.php?t=69958)

zokemon 11-09-2006 04:27 AM

The mass deletion of client. and clientr. variables! Yay!
 
So I want to be able to delete mass amounts of client. and clientr. variables in the most efficient way.

First thing I tried:

NPC Code:
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:

NPC Code:
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

NPC Code:
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

PHP Code:

for (igetstringkeys("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

Quote:

Originally Posted by Andy0687 (Post 1241111)
PHP Code:

for (igetstringkeys("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.

Quote:

Originally Posted by zokemon (Post 1241054)
First thing I tried:

NPC Code:
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

Quote:

Originally Posted by zokemon (Post 1241117)
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

Quote:

Originally Posted by KuJi (Post 1241118)
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

Quote:

Originally Posted by zokemon (Post 1241117)
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

HTML Code:

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

Quote:

Originally Posted by Andy0687 (Post 1241124)
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...

Quote:

Originally Posted by xAndrewx (Post 1241132)
I see the bug, knda
I did this though, dunno if it's of value

HTML Code:

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

PHP Code:

function onCreated()
  {
  
clearList"client" );
  }

function 
clearListstrName )
  {
  for ( 
temp.dmakevarstrName ).getvarnames() )
    
clearListstrName @"."temp.);

  
makevarstrName ) = "";
  } 


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.


All times are GMT +2. The time now is 04:46 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.