logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Detect NWNX from nwscript

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Scripts and Modules
View previous topic :: View next topic  
Author Message
EPOlson



Joined: 22 Jul 2006
Posts: 8

PostPosted: Sat Jul 22, 2006 23:50    Post subject: Detect NWNX from nwscript Reply with quote

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
View user's profile Send private message
Asmodae



Joined: 07 Jan 2005
Posts: 55

PostPosted: Mon Jul 24, 2006 18:26    Post subject: Reply with quote

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
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Acrodania



Joined: 02 Jan 2005
Posts: 208

PostPosted: Mon Jul 24, 2006 21:13    Post subject: Reply with quote

I use the same concept to determine whether to create a database for a system or whether it already exists Smile
Back to top
View user's profile Send private message
Grumalg



Joined: 04 Nov 2005
Posts: 70

PostPosted: Fri Jul 28, 2006 2:28    Post subject: Misc SQL commands to validate DB use Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Scripts and Modules All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group