Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 01-11-2009, 02:46 AM
Seich Seich is offline
Noctorious' NeoHunter
Seich's Avatar
Join Date: Jun 2008
Location: Honduras
Posts: 193
Seich will become famous soon enough
Send a message via MSN to Seich Send a message via Yahoo to Seich
Quote:
Originally Posted by Tigairius View Post
Well, the multiple flag variables that you're talking about are called arrays and this is the format:

PHP Code:
this.array = {"One""two""three"}; 
and to access the data within the array you would do something like:

PHP Code:
this.chat this.array[1]; 
Which would return "two" because all arrays start with 0.

In a DB NPC (which is similar or exactly the same to a local npc, ie: putnpc2) each NPC has it's own ID which can be used to identify the DB NPC. When you store a flag using a DBNPC it stores to that DB NPC, naturally. You can access it remotely by using
PHP Code:
 findNPC("DB NPC NAME").flag 
So, let's say we want our DBNPC to be specifically used to hold flags and information. This is an easy way we could set it up:

Step one, create the DB NPC, right click it and click edit flags.

Step two, add all of your this. variables in to the DB NPC without the this. prefix.

Step three, access your variables by using findNPC(Obj) or findNPCById(Obj). You can view the DBNPC's ID by displaying the list of DBNPCs in RC. The ID of the DBNPC is aligned on the right side of the text list. Here is my last example to show you how to access variables within the DBNPC.

PHP Code:
temp.npc findNPC("MyDB");
npc.variable1 123;
npc.string1 "hello";
npc.array1 = {"one""five""fifteen"};
npc.flag true

Thank you, that's great, I didn't know that I could store arrays in flags, well I simply never tried that.

I still have one question, how can I use a dynamic flag name? like on my example with the number or, that isn't possible?
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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