Thread: Npc db
View Single Post
  #2  
Old 01-10-2009, 04:19 AM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
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
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote