Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   Getting Information from Arrays in DB (https://forums.graalonline.com/forums/showthread.php?t=73355)

killerogue 04-08-2007 08:00 AM

Getting Information from Arrays in DB
 
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 09:12 AM

There is no way to read from DB-NPCs clientside.

To read (serverside) just use:
dbName.var

Gambet 04-08-2007 09: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 09:36 AM

I suggest using public functions
Inside of the database create a public function like so

PHP Code:

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

You could call this like

PHP Code:

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

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

PHP Code:

function onCreated()
  
itemData this;
//Other code 

You could then call it like

PHP Code:

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 04:38 AM

Quote:

Originally Posted by Chandler (Post 1297953)
PHP Code:

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 );


All times are GMT +2. The time now is 07:17 PM.

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