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 
 
Function idea: Shutdown server
Goto page Previous  1, 2, 3, 4, 5, 6  Next
 
Post new topic   Reply to topic    nwnx.org Forum Index -> General Discussion
View previous topic :: View next topic  
Author Message
Asmodae



Joined: 07 Jan 2005
Posts: 55

PostPosted: Sun Jun 25, 2006 16:41    Post subject: Reply with quote

Hrm.. NWscript is a generic name for any script written for Neverwinter Nights. It isn't a specific file.

For instance, if you go into a simple mod (with NWNX setup and functioning properly) put down a placeable, then edit its properties...

Make sure the 'useable' checkbox is checked. Goto the scripts tab, then click edit fot the OnUsed event. This will open up a script editor window. Paste in the single line of code from the instructions.. like this:

Code:

main
{
   SetLocalString(GetModule(),"NWNX!RESETPLUGIN!SHUTDOWN","1")
}


Save the script (the name doesn't matter, choose something you like or think is suitable). Now build the mod... and you have a placeable that will reset your server. Extrapolate from this how to get the server to reset in other circumstances. If you need extra help with specific scripting issues, or how NWN events work, bioware has a lot of great guys on their forums that can help you out.

Good Luck!

- 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
Zunath



Joined: 06 Jul 2006
Posts: 183

PostPosted: Sat Jul 08, 2006 17:32    Post subject: Reply with quote

I have this system installed into my server, but whenever the server crashes and restarts I lose data.

How can I prevent this? Also, how can I make it so that the restart goes off at a designated time of day? (such as 4am, 12pm, and 8pm)

Sorry if this is a lot to ask, but this seems very useful.
Back to top
View user's profile Send private message
DarkstarsDad



Joined: 17 Jan 2005
Posts: 59
Location: Overland Park, Kansas USA

PostPosted: Tue Jul 11, 2006 5:28    Post subject: Save before you reset Reply with quote

You will need to add save char line to the script then reset.
_________________
Just because you think you can't. Is the best reason to try it anyway.
Back to top
View user's profile Send private message
Asmodae



Joined: 07 Jan 2005
Posts: 55

PostPosted: Tue Jul 11, 2006 15:06    Post subject: Reply with quote

Indeed. I believe the line is:

ExportAllCharacters();

as per the lexicon http://www.nwnlexicon.com/compiled/function.exportallcharacters.html

I made a note of this in the readme that comes with the package, check it out.

Good luck and let us know if there are other problems.

- 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
Zunath



Joined: 06 Jul 2006
Posts: 183

PostPosted: Fri Jul 14, 2006 3:49    Post subject: Reply with quote

I'm sorry I wasn't specific enough... Will ExportAllCharacters(); also save all of the data into my SQLite database? Such as items in the bank?

Thanks!
Back to top
View user's profile Send private message
Acrodania



Joined: 02 Jan 2005
Posts: 208

PostPosted: Fri Jul 14, 2006 4:47    Post subject: Reply with quote

Zunath wrote:
I'm sorry I wasn't specific enough... Will ExportAllCharacters(); also save all of the data into my SQLite database? Such as items in the bank?

Thanks!

No, exporting characters only makes sure that the character file is saved correctly in the server vault. It has nothing at all to do with NWNX or any database access
Back to top
View user's profile Send private message
Rami_Ahmed



Joined: 07 Dec 2005
Posts: 37
Location: Denmark

PostPosted: Fri Jul 14, 2006 10:20    Post subject: Reply with quote

Wouldn't the best be like this:
Code:
#include "aps_include"
void main()
{object oPC = GetFirstPC();
 while (GetIsObjectValid(oPC))
 {  if (!GetIsDM(oPC))
     {  BootPC(oPC);
     }
  oPC = GetNextPC();
 }
 DelayCommand(0.1, SQLExecDirect("COMMIT TRANSACTION")); // Not sure if this only works for SQLite
 DelayCommand(0.2, SQLExecDirect("BEGIN TRANSACTION"));  // Not sure if it's needed to start it up again
 AssignCommand(GetModule(), DelayCommand(5.0, SetLocalString(GetModule(),"NWNX!RESETPLUGIN!SHUTDOWN","1")));
}

We use something like that anyway. We have SQLite. I don't know if the transaction things work for anything else.
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Asmodae



Joined: 07 Jan 2005
Posts: 55

PostPosted: Tue Jul 18, 2006 6:23    Post subject: Reply with quote

I'm happy to see that people are using the plugin, yay!

Yes, Rami, I like your solution as it gives the players a disconnect notice before shutting down, thanks for posting it. I may include a version of that in a later release as an example script, is this ok with you?

As for Non-SQLite, we use MyISAM tables in MySQL and there's no need for committing transactions.

In response to Zunath: As for saving your data, it really depends on what needs to be saved and where you want to store it in your database. If you use Rami's example code you should be able to cycle through every player and save what is needed right before booting them and resetting the server.

To get the server to reset at a specific time you will have to setup some kind of timer, probably in the module heartbeat event. Make it very simple so that it doesn't use much cpu time. Reset the server when so much time has passed, you can warn players with shouts or server messages when getting close to a reset.

- 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
Rami_Ahmed



Joined: 07 Dec 2005
Posts: 37
Location: Denmark

PostPosted: Fri Jul 28, 2006 21:58    Post subject: Reply with quote

Asmodae wrote:
is this ok with you?

Of course. Feel free to do so.
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Asmodae



Joined: 07 Jan 2005
Posts: 55

PostPosted: Wed Aug 02, 2006 19:08    Post subject: Reply with quote

Rami_Ahmed wrote:
Asmodae wrote:
is this ok with you?

Of course. Feel free to do so.


Great, thanks!

- 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
virusman



Joined: 30 Jan 2005
Posts: 1020
Location: Russia

PostPosted: Wed Aug 02, 2006 21:05    Post subject: Reply with quote

Hmm, does EndGame("") work?
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
Asmodae



Joined: 07 Jan 2005
Posts: 55

PostPosted: Thu Aug 03, 2006 20:14    Post subject: Reply with quote

good question:

http://www.nwnlexicon.com/compiled/function.endgame.html

from the sound of things it pretty much just roles credits.

- 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
Gorgonzola



Joined: 21 Jun 2006
Posts: 6

PostPosted: Fri Aug 11, 2006 18:24    Post subject: Reply with quote

any chance of getting a linux port of the reset plugin?

i could seriously use one...
Back to top
View user's profile Send private message
virusman



Joined: 30 Jan 2005
Posts: 1020
Location: Russia

PostPosted: Sat Aug 12, 2006 1:34    Post subject: Reply with quote

Gorgonzola wrote:
any chance of getting a linux port of the reset plugin?

i could seriously use one...
Sure. Wink
http://www.nwnx.org/phpBB2/viewtopic.php?p=3695
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
Asmodae



Joined: 07 Jan 2005
Posts: 55

PostPosted: Fri Aug 18, 2006 18:59    Post subject: Reply with quote

Nice work Virusman. Very Happy

- 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
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> General Discussion All times are GMT + 2 Hours
Goto page Previous  1, 2, 3, 4, 5, 6  Next
Page 4 of 6

 
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