Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   getstringkeys() and loadvars() (https://forums.graalonline.com/forums/showthread.php?t=81534)

Frankie 08-28-2008 03:56 PM

getstringkeys() and loadvars()
 
I'm not sure how to use the 2 together.

PHP Code:

function onCreated()
{
  
temp.gang.loadvars("gangs/Los Carteles.txt");
  for (
temp.igetstringkeys("rights-"))
  {
  }


It's hard to put in words, but I know in a database you can do
PHP Code:

with (findNPC("database stuff"))
{
  for (
temp.igetstringkeys("stuff"))
  {
  }


which will get the strings in the database.
I'm just not sure how to get the strings in the text file.

DustyPorViva 08-28-2008 03:59 PM

I'm not terribly familiar with this, but...
PHP Code:

function onCreated()
{
  
temp.gang.loadvars("gangs/Los Carteles.txt");
  for (
temp.itemp.gang.getstringkeys("rights-"))
  {
  }


?

Frankie 08-28-2008 04:00 PM

I've tried that :(

Script: Function gang.getstringkeys not found at line 69 in script of *Frankie

Chompy 08-28-2008 04:11 PM

getstringkeys() can't but used directly on an object (obj.getstringkeys())
Use it inside a with() scope.

And, for the files, use obj.getDynamicVarNames();

PHP Code:

function onCreated() {
  
temp.file.loadvars("gangs/PizzaClan.txt");
  
  
temp.gang_PizzaClan = new TStaticVar();

  for(
temp.var : temp.file.getDynamicVarNames()) {
    
temp.gang_PizzaClan.(@var) = temp.file.(@var);
  }

  
temp.keys 0;
  
with(temp.gang_PizzaClan) {
    
temp.keys getstringkeys("variable_prefix");
  }


Just a fast mockup, but something like that would work I guess

xXziroXx 08-28-2008 04:20 PM

Quote:

Originally Posted by Chompy (Post 1418613)
getstringkeys() can't but used directly on an object (obj.getstringkeys())
Use it inside a with() scope.

No. :oo:

PHP Code:

temp.string_foobar "lawl";
temp.string_lolwat "baz";
for (
temp.foogetstringkeys("temp.string_")) {
  echo(
foo SPC "[" makevar("temp.string_" foo) @ "]");


Result:

PHP Code:

foobar [lawl]
lolwat [baz


Chompy 08-28-2008 04:29 PM

Quote:

Originally Posted by xXziroXx (Post 1418618)
No. :oo:

PHP Code:

... 

Result:

PHP Code:

... 


Where in your script are you doing object.getstringkeys() though? ;o

I might of worded it wrong, as my vocabulary isn't that big in English :p
But I did put 'obj.getstringkeys()' in parenthesises :p

xXziroXx 08-28-2008 04:40 PM

If I wanted to do it with an object, I would do:


PHP Code:

temp.obj findNPC("foobarbaz");
obj.string_foobar "lawl";  // Just to show a string example.
obj.string_lolwat "baz";  // Just to show a string example.
for (temp.foogetstringkeys("obj.string_")) {
  echo(
foo SPC "[" makevar("obj.string_" foo) @ "]");



Chompy 08-28-2008 04:43 PM

Quote:

Originally Posted by xXziroXx (Post 1418631)
If I wanted to do it with an object, I would do:


PHP Code:

temp.obj findNPC("foobarbaz");
obj.string_foobar "lawl";  // Just to show a string example.
obj.string_lolwat "baz";  // Just to show a string example.
for (temp.foogetstringkeys("obj.string_")) {
  echo(
foo SPC "[" makevar("obj.string_" foo) @ "]");



Hmm, you're right, but you can't do obj.getstringkeys() :p

But yeah.. I probably read through your script to fast :)

xXziroXx 08-28-2008 04:45 PM

Quote:

Originally Posted by Chompy (Post 1418636)
Hmm, you're right, but you can't do obj.getstringkeys() :p

Agreed. I also didn't read your post too well, I was under the impression that you meant something like this for a while:

PHP Code:

with (getstringkeys("foobar")) {
...



Chompy 08-28-2008 05:02 PM

Quote:

Originally Posted by xXziroXx (Post 1418638)
Agreed. I also didn't read your post too well, I was under the impression that you meant something like this for a while:

PHP Code:

... 


:p hehe

TheStan 08-28-2008 07:30 PM

Booyah!

PHP Code:

function onCreated() {
  
this.test();
}
public function 
test() {
  
temp.file = new TStaticVar();
  
temp.file.var_1 "moo";
  
temp.file.var_2 46;
  
  
with (temp.file) {
    
temp.keys getstringkeys("this.var_");
  }
  echo(
"Keys: " temp.keys);



Frankie 08-28-2008 09:28 PM

PHP Code:

function onCreated() {
  
this.test();
}
public function 
test() {
  
temp.file = new TStaticVar();
  
temp.file.loadvars("gangs/Los Carteles.txt");
  
  
with (temp.file) {
    
temp.keys getstringkeys("this.rights-");
    
    for (
temp.itemp.keys)
    {
      if (
this.("rights-" temp.i)[7] == 1)
      {
        echo(
temp.i);
      }
    }
  }


basically I was trying to cycle through all the accounts and their rights and find out if they had a specific right (leader right)

thanks :D

Chompy 08-28-2008 09:39 PM

Quote:

Originally Posted by Frankie (Post 1418733)
PHP Code:

... 

basically I was trying to cycle through all the accounts and their rights and find out if they had a specific right (leader right)

thanks :D

Also, loops inside with() aren't optimized :p Just thought you would want to know =p

xXziroXx 08-28-2008 09:43 PM

makevar("this.rights-" @ temp.i) instead of this.("rights-" @ temp.i) :rolleyes:

Frankie 08-28-2008 11:30 PM

Quote:

Originally Posted by Chompy (Post 1418741)
Also, loops inside with() aren't optimized :p Just thought you would want to know =p

it doesn't work if I take the for() loop out of the with()


All times are GMT +2. The time now is 02:22 PM.

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