Doing this is cool too:
PHP Code:
// In a weapon or class:
function onCreated() {
this.db = findnpc("Your Favorite DB for this kind of thing");
}
function otherCode() {
this.db.yeehaw();
}
or
PHP Code:
// In the DB:
function onInitialized() {
onCreated(); // Called when the NPC-Server starts up.
}
function onCreated() {
myFavDBlol = this;
}
// Anywhere on the server-side:
function otherCode() {
myFavDBlol.rofl();
}
Directly referring to the DB's name kind of bottlenecks your script if you plan to release it for others who might want to use a different name for it.