PDA

View Full Version : Max loop limit question


Gunderak
06-30-2016, 03:59 AM
Been a while!

Anywho, tasked with finding a way to trace a players account from email.
This is to find offline players rather than just online, e.g. helping to recover lost accounts where the player has lost access to the email account but still knows the email address that was used to identify etc.

I seem to have hit an issue with what I assume are limits imposed by the internals of Graal, my method of getting a list of all the accounts ever used to check against was looping through the player houses folder:


function onCreated(){
this.maxlooplimit = 15000;
echo(this.maxlooplimit); //Echos 15000
LookFor("[email protected]", 1);
}

//Params:
// st - string - Either IP or Email.
// sw - integer - 0 for IP, 1 for Email.
function LookFor(st,sw){
temp.p = 0;
temp.f = 0;
temp.list = new[0];
temp.fold = new[15000];
temp.fold.loadfolder("levels/houses/players/*Graal*", false);
echo("Looking for "@[email protected]" in "@fold.size()@" houses");
temp.fold[10123] = "test";
echo(fold[10123]);
for(temp.i : temp.fold){
temp.acc = temp.i.tokenize("_")[1];
//Skip PC accs, since they haven't identified.
if(acc.substring(0, 5) != "Graal") continue;
temp.p = new TServerPlayer(@acc);
if(sw){
//Look for Email
if(st.lower() == p.client.email.lower()){
echo("Found player: "@acc);
temp.f = 1;
break;
}
}else{
//Look for IP
}
}
if(!temp.f) echo("Unable to locate player.");
temp.p.destroy();
}


This is the RC output, any ideas?

The script of NPC Gund_Lookup has been updated by Gund
15000
Looking for [email protected] in 10000 houses
Unable to locate player.

BlueMelon
06-30-2016, 06:14 AM
The script of NPC Gund_Lookup has been updated by Gund
15000
Is this the line you think you have a limit?

Because you have
temp.fold = new[15000];

In your code. And you also have maxlooplimit set, but not sure of the conditions when that gets triggered tbh.

Gunderak
06-30-2016, 06:46 AM
Is this the line you think you have a limit?

Because you have


In your code. And you also have maxlooplimit set, but not sure of the conditions when that gets triggered tbh.

Hmm I'm out of ideas then... Also hey, I remember you from when I was on Era PC ha

temp.fold = new[15000];
Was my attempt when I thought maybe the default array size was 10k.

temp.fold[10123] = "test";
echo(fold[10123]);
This also has no effect..

MysticalDragon
06-30-2016, 12:00 PM
Hmm I'm out of ideas then... Also hey, I remember you from when I was on Era PC ha

temp.fold = new[15000];
Was my attempt when I thought maybe the default array size was 10k.


Default (Not sure if you can even change the max limitations) size is 9999.


function onCreated() {
temp.fold = new[15000];
temp.fold[9999] = {"test"};
echo(temp.fold[9999]);
}
The script of NPC Cache has been updated by Carlito
test,


Echoes Test while


function onCreated() {
temp.fold = new[15000];
temp.fold[10000] = {"test"};
echo(temp.fold[10000]);
}
The script of NPC Cache has been updated by Carlito


echoes nothing.

I also noticed the method in which you are using to get the players account. What if they don't have a player house? How I would personally do it without loading the accounts folder directly is every player that logs into the game register them in SQL.

DustyPorViva
07-01-2016, 10:10 AM
You can indeed raise the maxlooplimit on serverside and clientside.

However, it won't take effect until the next tick, so if you intend to do something that's loop-intensive onCreated() you're going to need to schedule it with scheduleEvent or timeout.

Gunderak
07-02-2016, 01:55 AM
You can indeed raise the maxlooplimit on serverside and clientside.

However, it won't take effect until the next tick, so if you intend to do something that's loop-intensive onCreated() you're going to need to schedule it with scheduleEvent or timeout.

I gave this a go with scheduleevent but still the same results, max is 10,000 :(

DustyPorViva
07-03-2016, 04:44 PM
I gave this a go with scheduleevent but still the same results, max is 10,000 :(

If it's possible, try a timeout instead of a scheduleevent.

fowlplay4
07-04-2016, 11:18 AM
I gave this a go with scheduleevent but still the same results, max is 10,000 :(


function onCreated() {
maxlooplimit = 100001;
example();
}

function example() {
for (temp.i = 0; temp.i < 99999; temp.i++) {
temp.c++;
}
echo(temp.c); // echos 99999
}