Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   serverr flag array trouble (https://forums.graalonline.com/forums/showthread.php?t=76283)

coreys 08-15-2007 08:23 AM

serverr flag array trouble
 
Okay, so I'm making an Events System, and I have the events setup like this:
Theres 4 different event types, each has it's own multidimensional array with the
event names and their data in it. What I'm stuck on is trying to make a list of each event in its category in serverr flags. Ex: serverr.events.contest=Musical Chairs, Emoticons

Now, to spare you with all the for loops and such, here's essentially what I'm trying to do:
PHP Code:

temp.testtype = {"race""spar"};
temp.elist.race = {{"Foot Race","bla"}, {"Bush Race","bla"}};
temp.elist.spar = {{"Spar","bla"}, {"Classic Spar","bla"};
serverr.events.(@ temp.testtype[0])[0] = temp.elist.(@ temp.testtype[0])[0][0];
serverr.events.(@ temp.testtype[0])[1] = temp.elist.(@ temp.testtype[0])[1][0];
serverr.events.(@ temp.testtype[0])[0] = temp.elist.(@ temp.testtype[1])[0][0];
serverr.events.(@ temp.testtype[0])[1] = temp.elist.(@ temp.testtype[1])[1][0]; 

My problem is that the serverr flags will not set.

Chompy 08-15-2007 01:20 PM

PHP Code:

temp.testtype = {"race""spar"};
temp.elist.race = {{"Foot Race","bla"}, {"Bush Race","bla"}};
temp.elist.spar = {{"Spar","bla"}, {"Classic Spar","bla"};

serverr.events.(@ temp.testtype[0]) = {};
serverr.events.(@ temp.testtype[0])[0] = temp.elist.(@ temp.testtype[0])[0][0];
serverr.events.(@ temp.testtype[0])[1] = temp.elist.(@ temp.testtype[0])[1][0];

serverr.events.(@ temp.testtype[1]) = {};
serverr.events.(@ temp.testtype[1])[0] = temp.elist.(@ temp.testtype[1])[0][0];
serverr.events.(@ temp.testtype[1])[1] = temp.elist.(@ temp.testtype[1])[1][0]; 

hmm?

I think you need to initialize the array first, for example with {} or new[1]

dNeonb 08-15-2007 03:36 PM

Not releated to the script but to the whole thing. If you make an event system it would be more useful to use a database npc to store all the event informations. If you have many events or long texts it might be a problem.
Yesterday I updated the serverflags on GK Debug because I wanted to add a new tool type. But I was not able to add it, the limit of variables in the serverflags was reached.

Think about it.

xXziroXx 08-15-2007 04:05 PM

First of all, let me just tell you that Bjorn is right. Use a DB instead of serverr. strings. Now to answer your question..


Quote:

Originally Posted by Chompy (Post 1340186)
I think you need to initialize the array first, for example with {} or new[1]

Indeed. You cant edit a part of an array that doesnt exist.

serverr.flag = new[5];
serverr.flag[2] = "lol";

Just an example on how to do it before you set the data.

Horrified 08-15-2007 08:08 PM

Quote:

Originally Posted by dNeonb (Post 1340226)
But I was not able to add it, the limit of variables in the serverflags was reached.

Uh sorry but, do you know the exact limit?

Inverness 08-15-2007 08:48 PM

Quote:

Originally Posted by Horrified (Post 1340301)
Uh sorry but, do you know the exact limit?

The limit is in the RC's editing window itself not the actual server flags. The limit is most likely 255 characters.

Chompy 08-15-2007 08:59 PM

Quote:

Originally Posted by Inverness (Post 1340305)
The limit is in the RC's editing window itself not the actual server flags. The limit is most likely 255 characters.

Yep, and it should be removed as you stated in that other thread..

coreys 08-15-2007 11:06 PM

Quote:

Originally Posted by dNeonb (Post 1340226)
Not releated to the script but to the whole thing. If you make an event system it would be more useful to use a database npc to store all the event informations. If you have many events or long texts it might be a problem.
Yesterday I updated the serverflags on GK Debug because I wanted to add a new tool type. But I was not able to add it, the limit of variables in the serverflags was reached.

Think about it.

...I am using a database npc. I'm trying to set serverr flags so that my event tool doesn't have to do 436263 triggers.

Inverness 08-16-2007 01:15 AM

I believe Database NPCs are a bit unsafe for information thats not set in the script since if its in flags only it could be cleared on reset.

For things like that I use TStaticVars that save to file.

By the way, there is a serveroption that limits you to only changing existing server flags rather than being able to create new ones, make sure thats not enabled?
Quote:

Originally Posted by coreys (Post 1340337)
...I am using a database npc. I'm trying to set serverr flags so that my event tool doesn't have to do 436263 triggers.

Like Ziro said, the array has to be existing before you can edit an index of it, though it is possible to add to non-existant arrays since it will just create one if there isn't one existing.
PHP Code:

serverr.events.(@ temp.testtype[0]) = new [2];
serverr.events.(@ temp.testtype[0])[0] = temp.elist.(@ temp.testtype[0])[0][0];
serverr.events.(@ temp.testtype[0])[1] = temp.elist.(@ temp.testtype[0])[1][0];
//OR
serverr.events.(@ temp.testtype[0]) = {
  
temp.elist.(@ temp.testtype[0])[0][0],
  
temp.elist.(@ temp.testtype[0])[1][0]
}; 

Use the second one :)
Quote:

Originally Posted by Chompy (Post 1340186)
I think you need to initialize the array first, for example with {} or new[1]

You still can't edit index 1 as you did in your code because it doesn't exist, only index 0.

zokemon 08-16-2007 01:53 AM

I personally use database npcs that backup data to a file on update. This uses the least gserver usage (HD usage) in most cases where you don't need to update much.

About editing array members that do not yet exist, make your own function if you want that simply array.add()'s if the array.size() < the member you want to edit (or so).

coreys 08-16-2007 04:47 AM

Chompy helped me make it work. Just used new[]...although, for whatever reason new[] didn't work for me before, in the same exact script.

Chompy 08-16-2007 12:13 PM

Quote:

Originally Posted by Inverness (Post 1340373)
You still can't edit index 1 as you did in your code because it doesn't exist, only index 0.

I forgot new[] indexes start at 1 xD

But Vash, I would suggest what Inver told ya to do:

Quote:

Originally Posted by Inverness (Post 1340373)
PHP Code:

serverr.events.(@ temp.testtype[0]) = {
  
temp.elist.(@ temp.testtype[0])[0][0],
  
temp.elist.(@ temp.testtype[0])[1][0]
}; 


But that's if you know the size ;o

zokemon 08-17-2007 08:37 AM

new[i] is such where i is the count, not an index.

It's kind of like doing:
var.count() = i;

Of course the syntax for that is completely wrong and such a thing is impossible.

MysticalDragon 08-17-2007 06:21 PM

try databases serverr flags dont use arrays anyway http://graalonline.biz/images/smilies/frown.gif

Skyld 08-17-2007 06:30 PM

Quote:

Originally Posted by MysticalDragon (Post 1340912)
try databases serverr flags dont use arrays anyway http://graalonline.biz/images/smilies/frown.gif

You can use arrays in serverr. variables because the Graal engine treats arrays as specially delimited strings; they are not a distinctive datatype in terms of storage.

coreys 08-17-2007 07:49 PM

Quote:

Originally Posted by Skyld (Post 1340916)
You can use arrays in serverr. variables because the Graal engine treats arrays as specially delimited strings; they are not a distinctive datatype in terms of storage.

:o
inteereestiiinggggg

But I already knew arrays worked in serverr flags anyways, they have for as long as I can remember.

Relinquish 08-17-2007 10:49 PM

serverr flags should not be used, at all, there are bugs in the communication of them from server -> client.
The server seems to randomly forget to send some clients the updated variable, or forgets to send the variable period, which leads to some massive problems.

Chompy 08-17-2007 10:52 PM

Quote:

Originally Posted by Relinquish (Post 1341012)
serverr flags should not be used, at all, there are bugs in the communication of them from server -> client.
The server seems to randomly forget to send some clients the updated variable, or forgets to send the variable period, which leads to some massive problems.

What? What are you talking about? O.o

Relinquish 08-17-2007 11:25 PM

If you're on a populated server and change a serverr string a lot, and then have each player echo what they read it as each time it's changed, some of the players will eventually start echo'ing what an old string was, since the server didn't send them the updated string properly.

coreys 08-18-2007 05:11 AM

Quote:

Originally Posted by Relinquish (Post 1341024)
If you're on a populated server and change a serverr string a lot, and then have each player echo what they read it as each time it's changed, some of the players will eventually start echo'ing what an old string was, since the server didn't send them the updated string properly.

Or whatever server you're doing this on is fsked, 'cause I've never had this problem o.0

xXziroXx 08-18-2007 05:37 AM

Quote:

Originally Posted by Relinquish (Post 1341024)
If you're on a populated server and change a serverr string a lot, and then have each player echo what they read it as each time it's changed, some of the players will eventually start echo'ing what an old string was, since the server didn't send them the updated string properly.

I dont know about the problem you speak of, never encountered it on Zodiac or Maloria.


All times are GMT +2. The time now is 04:15 PM.

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