Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Max loop limit question (https://forums.graalonline.com/forums/showthread.php?t=134270322)

Gunderak 06-30-2016 03:59 AM

Max loop limit question
 
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:

PHP Code:

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.0;
  
temp.0;
  
temp.list = new[0];
  
temp.fold = new[15000];
  
temp.fold.loadfolder("levels/houses/players/*Graal*"false);
  echo(
"Looking for "@st@" in "@fold.size()@" houses");
  
temp.fold[10123] = "test";
  echo(
fold[10123]);
  for(
temp.temp.fold){
    
temp.acc temp.i.tokenize("_")[1];
    
//Skip PC accs, since they haven't identified.
    
if(acc.substring(05) != "Graal") continue;
    
temp.= new TServerPlayer(@acc);
    if(
sw){
      
//Look for Email
      
if(st.lower() == p.client.email.lower()){
        echo(
"Found player: "@acc);
        
temp.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

Quote:

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
Quote:

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

Quote:

Originally Posted by BlueMelon (Post 1739183)
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

PHP Code:

temp.fold = new[15000]; 

Was my attempt when I thought maybe the default array size was 10k.

PHP Code:

  temp.fold[10123] = "test"
  echo(
fold[10123]); 

This also has no effect..

MysticalDragon 06-30-2016 12:00 PM

Quote:

Originally Posted by Gunderak (Post 1739184)
Hmm I'm out of ideas then... Also hey, I remember you from when I was on Era PC ha

PHP Code:

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.

PHP Code:

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

PHP Code:

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

Quote:

Originally Posted by DustyPorViva (Post 1739187)
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

Quote:

Originally Posted by Gunderak (Post 1739188)
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

Quote:

Originally Posted by Gunderak (Post 1739188)
I gave this a go with scheduleevent but still the same results, max is 10,000 :(

PHP Code:

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

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




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

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