PenUltima Online

It is currently Thu Aug 28, 2008 8:10 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: detect crashes
PostPosted: Sun Mar 30, 2008 8:25 am 
Offline

Joined: Fri Aug 31, 2007 2:25 pm
Posts: 54
how can I detect a crash in start script? to see if the last pol close was made by a crash or by ctrl-C ??

and, saveworldstate() function save every prop in datafiles?

_________________
Hello from Brazil :)


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 30, 2008 8:52 am 
Offline
User avatar

Joined: Fri Feb 10, 2006 12:15 am
Posts: 206
You could save a global property just before calling Shutdown(). Then, in start.src that property is read, and if it returns error (unset property), you know POL crashed. If property exists, you have to erase it.

As far as I know, CTRL+C is reserved command and thus you cannot manipulate its actions. You could however create a script shutdownalias.src into scripts/console/, add a command, say, CTRL+X, and use that instead of hardcoded shutdown.

Scriptwise the whole setting would look like this.

A new line to /config/console.cfg
Code:
CMD ^X shutdownalias Forces shutdown.


/scripts/console/shutdownalias.src
Code:
use uo;

program shutdownalias( )
   
    SetGlobalProperty("CleanShutdown", 1);
    Shutdown();
   
endprogram


A new line to /scripts/start.src
Code:
// Inside the program block...
if (GetGlobalProperty("CleanShutdown"))
    Print("POL did not crash.");
    EraseGlobalProperty("CleanShutdown");
else
    Print("POL crashed!");
endif


And before every other Shutdown() function call..
Code:
SetGlobalProperty("CleanShutdown", 1);


I do not use this myself, and thus cannot guarantee that it would work for sure. Anyhow this should give you an idea.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 30, 2008 10:11 am 
Offline

Joined: Fri Aug 31, 2007 2:25 pm
Posts: 54
lol, take a look on that:
console.cfg
Code:
Commands
{
   CMD w exitpol POL safe exit
   CMD u [unlock]
   CMD l [lock]
}


console output:
Code:
Console is locked.  Press 'u' to unlock.
Console is now unlocked.
Console is locked.  Press 'u' to unlock.
Console is now unlocked.


every "Console is locked. Press 'u' to unlock." message is an 'w' keypress I am doing.

_________________
Hello from Brazil :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 0 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Style based on FI Subice by phpBBservice.nl