PDA

View Full Version : Getting Information from Arrays in DB


killerogue
04-08-2007, 09:00 AM
Welllll, what I did was create a Database for all my weapons and items on the server.

Much more efficient than a MUD and much simpler. However, I've gotten stuck as far as showing the images for icons in our inventory. We're using regular showimg controls.

Could anyone help me with this issue?

napo_p2p
04-08-2007, 10:12 AM
There is no way to read from DB-NPCs clientside.

To read (serverside) just use:
dbName.var

Gambet
04-08-2007, 10:33 AM
GS1 you would use with (getnpc(blah)), but with object oriented programming, the DB itself is an object, and thus, as napo stated, you can do dbName.var as an alternative, which is much more efficient and faster to use.


I think the GS2 version of with (getnpc(blah)) would be with (findnpc("blah")) or whatever, but you don't need a with for this.

Chandler
04-08-2007, 10:36 AM
I suggest using public functions
Inside of the database create a public function like so


public function getItemData(itemID)
return this.("item_"@ temp.itemID);


You could call this like


temp.itemInfo = ("my Database").getItemData(itemID);


If you wanted, you could do this.
Inside of the database, add this


function onCreated()
itemData = this;
//Other code


You could then call it like


temp.itemInfo = itemData.getItemData(itemID);


Which ever you find easier to understand, if you are to use the bottom one, make sure you remember what you call these though. Keep a document or a weapon explaining what each one does, so you don't get lost or reuse the same name.

cbk1994
04-10-2007, 05:38 AM
temp.itemInfo = ("my Database").getItemData(itemID);



Assuming the database name is one word (which it really should probably be ...) you can just do myDatabase.getItemData( itemID );