View previous topic :: View next topic |
Author |
Message |
EPOlson
Joined: 22 Jul 2006 Posts: 8
|
Posted: Sat Jul 22, 2006 23:50 Post subject: Detect NWNX from nwscript |
|
|
I could be missing something obvious, but is there a quick way to detect if NWNX is running from nwscript? (I want to auto configure databases & other functions depending upon if NWNX is running) It would be even better if I can tell which plugins have been loaded.
Thanks!
Edit: I did find a "hack" to detect dumbo's chat plugin, the one I care about at the moment. (attempt to assign a chat ID to GetModule() and see if I get something) But I'm still interested in a general solution and a database mod solution. |
|
Back to top |
|
|
Asmodae
Joined: 07 Jan 2005 Posts: 55
|
Posted: Mon Jul 24, 2006 18:26 Post subject: |
|
|
Well, its not totally general, but can't you just execute a query and see if it returns something? If you have an existing database, this is pretty easy. It should also be easy with MySQL (you can use a builtin function to return something).
Or heck, just any old query, if the string gets wiped and returned empty then NWNX is running. If the string isn't changed, then NWNX isn't running.
- Asmodae _________________ Nepenthe - An NWN2 Persistant World, coming to a planet near you. http://www.nepentheonline.com |
|
Back to top |
|
|
Acrodania
Joined: 02 Jan 2005 Posts: 208
|
Posted: Mon Jul 24, 2006 21:13 Post subject: |
|
|
I use the same concept to determine whether to create a database for a system or whether it already exists |
|
Back to top |
|
|
Grumalg
Joined: 04 Nov 2005 Posts: 70
|
Posted: Fri Jul 28, 2006 2:28 Post subject: Misc SQL commands to validate DB use |
|
|
In my pw/database stuff I initially used simply requesting data from a table as a check. Since I do stuff like dynamic table/column create/destroy to support the use of pw system subsystem plugins, I went back and made my DB checks more rigorous. You might find the below commands useful. Note, these have only been tested with MySQL they *may* not be useable with SQLite.
"SELECT VERSION()"
I use this to see if communication with DB is working. SQL_ERROR being returned indicates not talking to the DB. Useing version allows determining the difference between DB engine failure and your specific database name not working.
"SHOW DATABASES LIKE '<dbname>' "
I use this to verify if a <dbname> database exists. If the first field returned doesn't match your dbname a DB of that name is not present.
"SHOW TABLES FROM <dbname> LIKE '<tablename>' "
I use this to verify existance of a specific table. If the first field returned doesn't match your tablename a table of that name is not present.
<edit added>
"SHOW COLUMNS FROM <tablename> LIKE '<columnname>' "
I use this to check if a specific column exists in a table. If the first field returned doesn't match your columnname a column of that name is not present in the table.
Hope others will find this useful
--- Grumalg --- |
|
Back to top |
|
|
|