View previous topic :: View next topic |
Author |
Message |
Waher
Joined: 28 Aug 2009 Posts: 13 Location: Tallinn, EST
|
Posted: Mon Aug 31, 2009 23:05 Post subject: Mm, alternative to nwnx_SystemData to get timestamps? |
|
|
Good day!
I am wondering if there is an nwnx plugin which allows me to retreive Unix timestamps? They are integral to keeping things running in my in-development persistent world. I found this nwnx_SystemData plugin and it does work, but I think it is buggy and causes my client to crash every now and then (player, not the server itself). _________________ Kristo Vaher
Developer of Teramyre PW |
|
Back to top |
|
|
Zebranky
Joined: 04 Jun 2006 Posts: 415
|
Posted: Tue Sep 01, 2009 0:19 Post subject: |
|
|
At the very least, nwnx_odbc + MySQL will let you do it. That's what I've always used. _________________ Win32 SVN builds: http://www.mercuric.net/nwn/nwnx/
<Fluffy-Kooshy> NWNx plugin is to this as nuclear warheads are to getting rid of fire ants.
<ThriWork> whenever I hear nwn extender, I think what does NWN need a penis extender for? |
|
Back to top |
|
|
Waher
Joined: 28 Aug 2009 Posts: 13 Location: Tallinn, EST
|
Posted: Tue Sep 01, 2009 8:16 Post subject: |
|
|
Client crashes were caused by something else and were not related to this plugin, however this plugin seemed to have caused DEP errors, as my XP kept warning me about it.
Also, while timestamps through database are interesting, they aren't really optimal, which is why I wondered if there is an alternative. _________________ Kristo Vaher
Developer of Teramyre PW |
|
Back to top |
|
|
Disco
Joined: 06 Dec 2006 Posts: 152
|
Posted: Tue Sep 01, 2009 10:19 Post subject: |
|
|
I think there's a newer version of that plugin. I use it a lot and never had an issue with it. Win XP here as well. I guess you can find the email of the author? |
|
Back to top |
|
|
Gryphyn
Joined: 20 Jan 2005 Posts: 431
|
Posted: Tue Sep 01, 2009 13:16 Post subject: |
|
|
Is this for NWNX2?
You could try my NWNX^2 RealTime v1.2 plugin. (*halfway down the page)
This will give you all the server date/time info you could want.
It's ISO not Unix, but still down to the second.
Cheers
Gryphyn |
|
Back to top |
|
|
Waher
Joined: 28 Aug 2009 Posts: 13 Location: Tallinn, EST
|
Posted: Tue Sep 01, 2009 13:40 Post subject: |
|
|
Gryphyn wrote: | Is this for NWNX2?
You could try my NWNX^2 RealTime v1.2 plugin. (*halfway down the page)
This will give you all the server date/time info you could want.
It's ISO not Unix, but still down to the second.
Cheers
Gryphyn |
I'll try it if I continue having problems with the other one. I'd still want to use UNIX timestamp which makes calculations extremely easy without me having to convert one to another all the time. But thank you! _________________ Kristo Vaher
Developer of Teramyre PW |
|
Back to top |
|
|
Paul R
Joined: 17 Apr 2009 Posts: 42
|
Posted: Tue Sep 01, 2009 16:57 Post subject: |
|
|
Assuming you are using the main trunk the nwnx_system plugin has the following:
Code: |
/* Get the current system time in seconds since the epoch. */
int GetSystemTime ();
|
along with other UNIXy goodness |
|
Back to top |
|
|
Disco
Joined: 06 Dec 2006 Posts: 152
|
Posted: Tue Sep 01, 2009 17:13 Post subject: |
|
|
Terra (the author of sysdata) made the plugin to help me with some common tasks, and it does more than just give time stuff.
I am not 100% sure if everything is working, and I am quite sure that this is for sysdata2, but here's an idea:
Code: | //Returns the current second
//UNIX timestap style
//Returns a smaller variant if nShorten = TRUE
int GetCurrentSecond( int nShorten = TRUE );
//Returns the time the server has been running in seconds
int GetServerRunTime( );
//Returns the desired intiger from sFile under sSection with sKey
//If non is found it returns nDefault
//Note: the parameters may not be more then 255 characters long
int ReadIntFromINI( string sSection, string sKey, int nDefault, string sFile );
//Returns the desired string from sFile under sSection with sKey
//If non is found it returns nDefault
//Note: the parameters may not be more then 255 characters long
string ReadStringFromINI( string sSection, string sKey, string sDefault, string sFile );
//Returns the desired float from sFile under sSection with sKey
//If non is found it returns nDefault
//Note: the parameters may not be more then 255 characters long
float ReadFloatFromINI( string sSection, string sKey, float fValue, string sFile );
//Returns the desired boolean from sFile under sSection with sKey
//If non is found it returns nDefault
//Note: Valid boolean types: 1/0 yes/no true/false
//Note: the parameters may not be more then 255 characters long
int ReadBooleanFromINI( string sSection, string sKey, int nDefault, string sFile );
//Writes or changes an existing intiger in sFile
//Note: the parameters may not be more then 255 characters long
void WriteIntToINI( string sSection, string sKey, int nValue, string sFile );
//Writes or changes an existing string in sFile
//Note: the parameters may not be more then 255 characters long
void WriteStringToINI( string sSection, string sKey, string sValue, string sFile );
//Writes or changes an existing float in sFile
//Note: the parameters may not be more then 255 characters long
void WriteFloatToINI( string sSection, string sKey, float fValue, string sFile );
//Writes or changes an existing boolean in sFile
//Note: the parameters may not be more then 255 characters long
void WriteBooleanToINI( string sSection, string sKey, int nValue, string sFile );
//This function calls strftime( char * format ) via system data 2
//Definition on how to use this function can be found here:
//http://www.cplusplus.com/reference/clibrary/ctime/strftime.html
//Note: the parameters may not be more then 255 characters long
string RealLifeClock( string sParameterString );
//Preforms a system command (aka CMD command)
//Definition can be found here:
//http://www.cplusplus.com/reference/clibrary/cstdlib/system.html
//Note: the parameters may not be more then 255 characters long
//WARNING! Some commands may freeze nwserver.exe until they're executed
//meaning executing commands such as "cmd" will cause the thread running
//nwserver.exe to freeze until the new window is terminated!
int System( string sParameters );
//Returns a system environment string variable
//This function returns system environment variables
//see: http://www.cplusplus.com/reference/clibrary/cstdlib/getenv.html
//Note: the parameters may not be more then 255 characters long
string GetEnvironmentString( string sName );
//Converts the first character in cChar to its respective ascii number
int CharToInt( string cChar );
//Turns each of nData to their respecive ascii signs and puts them togheter
//Example: 72 69 76 76 79 = "HELLO"
string IntToChar( int nData1, int nData2 = -1, int nData3 = -1, int nData4 = -1, int nData5 = -1 );
//Returns the first matching file with sPath
//Example C:/*.* will return the first file in C:
//Example C:/*.jpg will return the first .jpg
//Example C:/Bo.* returns the first file with the filename "Bo"
//etc
//Returns "0" on failure
//Sets the filehandle to the first file specified
//Note: the parameters may not be more then 255 characters long
string GetFirstFile( string sPath );
//Returns the next file according to the specifics of GetFirstFile()
//Returns "0" on failure or there is no more files to show
//Sets the filehandle to the next file specified
string GetNextFile( );
//Returns the latest used file in sPath
//Returns "0" on failure
//Sets the filehandle to the first file specified
//Note: the parameters may not be more then 255 characters long
string GetLatestUsedFileFile( string sPath );
//Sets the file handle to the specified file
//or returns the currently handled file if sTargetFile is empty
//returns "0" on failure
//Note: the parameters may not be more then 255 characters long
string GetSetFileHandle( string sTargetFile = "" );
//Gets the desired timestamp from the filehandle
//GetSetFilehandle() GetFirst/NextFile() can be used to set the filehandle
//TIMETYPE = 1 for creation time
//TIMETYPE = 2 for last accessed time
//TIMETYPE = 3 for last write time
struct FILETIME GetFileTime( int TIMETYPE );
//Returns the current systemtime
struct FILETIME GetSystemTime( );
//Returns a unixstyle timestamp instead of a human readable
//GetSetFilehandle() GetFirst/NextFile() can be used to set the filehandle
//to determin which file to read off
//TIMETYPE = 1 for creation time
//TIMETYPE = 2 for last accessed time
//TIMETYPE = 3 for last write time
int GetUnixTimeStampFromFile( int TIMETYPE );
//Returns a MM/DD/YY HH:MM:SS timestamp from a filetime struct
string FileTimeToTimeStamp( struct FILETIME FT );
//Sets filetime local data on oTarget under sVarname
void SetLocalFileTime( object oTarget, string sVarName, struct FILETIME ftValue );
//Returns the local filetime from oTarget
struct FILETIME GetLocalFileTime( object oTarget, string sVarName );
//Deletes the localdata off oTarget
void DeleteLocalFileTime( object oTarget, string sVarName );
//Wrapper function, returns your desired variable from the struct
//nType:
//1: Day
//2: Day Of Week
//3: Hour
//4: Millisecond
//5: Minute
//6: Month
//7: Second
//8: Year
//Returns -1 on error
int GetTimeVariable( struct FILETIME ftValue, int nType );
//Wrapper function to check if the filetime is valid
int GetIsValidFileTime( struct FILETIME ftTime );
//Delets s filename
//sFile should be in "c:/folder/folder/file.extention" formatting
//Note: the parameters may not be more then 255 characters long
//Returns true on success false otherwise
int DeleteFile( string sFile );
//File copy
//sOrginalFile and sNewFile should be in "c:/folder/folder/file.extention" formatting
//Note: the parameters may not be more then 255 characters long
//Returns true on success false otherwise
int CopyFile( string sOrginalFile, string sNewFile, int bAllowOverWriting = FALSE );
//File moving
//sOrginalFile and sNewFile should be in "c:/folder/folder/file.extention" formatting
//Note: the parameters may not be more then 255 characters long
//Returns true on success false otherwise
int MoveFile( string sOrginalFile, string sNewFile, int bAllowOverWriting = FALSE );
//File renaming
//sFile and sNewFileName should be in "c:/folder/folder/file.extention" formatting
//Note: the parameters may not be more then 255 characters long
//Returns true on success false otherwise
int RenameFile( string sFile, string sNewFileName );
//Strips path from a fillfile path
//Example: "c:/folder/folder/file.extention" = "file.extention"
//nGetName = TRUE and it returns: "file.extention"
//nGetName = FALSE and it returns: "c:/folder/folder"
string StripFilePath( string sFullFilePath, int nGetName = TRUE ); |
What I use myself atm:
The INI reader is VERY handy if you work on multiple computers. I have an ini in my root that tells NWN if it isn't a test server or not, the local NWN directory (for leto), etc. I got the same on the server, so I never have to worry about test variables that I forgot to revert to their original values etc.
GetServerRunTime( ) is very nice for getting rid of long delays. I use it on encounter triggers. Instead of blocking them with a delay I simply store the trigger moment's timestamp on them and check the difference between that timestamp and the one on any new hit.
Anyway, I can recommend this little gem. |
|
Back to top |
|
|
Terra_777
Joined: 27 Jun 2008 Posts: 216 Location: Sweden
|
Posted: Tue Oct 06, 2009 19:28 Post subject: |
|
|
http://nwvault.ign.com/View.php?view=Other.Detail&id=139934&id=1428
The old plugin was cluttery-testy. Here is the function list for the new one anyway:
Code: | //Returns TRUE if system data is responding
int NWNX_GetSystemDataAlive( );
//Returns the current second
//UNIX timestap style
//Returns a smaller variant if nShorten = TRUE
int NWNX_GetCurrentSecond( int nShorten = TRUE );
//Returns the time the server has been running in seconds
int NWNX_GetRunTime( );
//Returns the desired intiger from sFile under sSection with sKey
//If non is found it returns nDefault
//Note: the parameters may not be more then 255 characters long
int NWNX_ReadIntFromINI( string sSection, string sKey, int nDefault, string sFile );
//Returns the desired string from sFile under sSection with sKey
//If non is found it returns nDefault
//Note: the parameters may not be more then 255 characters long
string NWNX_ReadStringFromINI( string sSection, string sKey, string sDefault, string sFile );
//Returns the desired float from sFile under sSection with sKey
//If non is found it returns nDefault
//Note: the parameters may not be more then 255 characters long
float NWNX_ReadFloatFromINI( string sSection, string sKey, float fValue, string sFile );
//Returns the desired boolean from sFile under sSection with sKey
//If non is found it returns nDefault
//Note: Valid boolean types: 1/0 yes/no true/false
//Note: the parameters may not be more then 255 characters long
int NWNX_ReadBooleanFromINI( string sSection, string sKey, int nDefault, string sFile );
//Writes or changes an existing intiger in sFile
//Note: the parameters may not be more then 255 characters long
void NWNX_WriteIntToINI( string sSection, string sKey, int nValue, string sFile );
//Writes or changes an existing string in sFile
//Note: the parameters may not be more then 255 characters long
void NWNX_WriteStringToINI( string sSection, string sKey, string sValue, string sFile );
//Writes or changes an existing float in sFile
//Note: the parameters may not be more then 255 characters long
void NWNX_WriteFloatToINI( string sSection, string sKey, float fValue, string sFile );
//Writes or changes an existing boolean in sFile
//Note: the parameters may not be more then 255 characters long
void NWNX_WriteBooleanToINI( string sSection, string sKey, int nValue, string sFile );
//This function calls strftime( char * format ) via system data 2
//Definition on how to use this function can be found here:
//http://www.cplusplus.com/reference/clibrary/ctime/strftime.html
//Note: the parameters may not be more then 255 characters long
//nUnix represents which timestamp "STRFTIME" should use to generate the timestring
//is nUnix = 0 it'll take the current time
string NWNX_RealLifeClock( string sParameterString, int nUnix = 0 );
//Preforms a system command (aka CMD command)
//Definition can be found here:
//http://www.cplusplus.com/reference/clibrary/cstdlib/system.html
//Note: the parameters may not be more then 255 characters long
//WARNING! Some commands may freeze nwserver.exe until they're executed
//meaning executing commands such as "cmd" will cause the thread running
//nwserver.exe to freeze until the new window is terminated!
int NWNX_System( string sParameters );
//Returns a system environment string variable
//This function returns system environment variables
//see: http://www.cplusplus.com/reference/clibrary/cstdlib/getenv.html
//Note: the parameters may not be more then 255 characters long
string NWNX_GetEnvironmentString( string sName );
//Converts the first character in cChar to its respective ascii number
int NWNX_CharToInt( string cChar );
//Turns each of nData to their respecive ascii signs and puts them togheter
//Example: 72 69 76 76 79 = "HELLO"
string NWNX_IntToChar( int nData1, int nData2 = -1, int nData3 = -1, int nData4 = -1, int nData5 = -1 );
//Returns the first matching file with sPath
//Example C:/*.* will return the first file in C:
//Example C:/*.jpg will return the first .jpg
//Example C:/Bo.* returns the first file with the filename "Bo"
//etc
//Returns "0" on failure
//Sets the filehandle to the first file specified
//Note: the parameters may not be more then 255 characters long
string NWNX_GetFirstFile( string sPath );
//Returns the next file according to the specifics of GetFirstFile()
//Returns "0" on failure or there is no more files to show
//Sets the filehandle to the next file specified
string NWNX_GetNextFile( );
//Returns a unixstyle timestamp instead of a human readable
//GetSetFilehandle() GetFirst/NextFile() can be used to set the filehandle
//to determin which file to read off
//TIMETYPE = 1 for creation time
//TIMETYPE = 2 for last accessed time
//TIMETYPE = 3 for last write time
int NWNX_GetTimeStampFromFile( int TIMETYPE, string sFile );
//Delets s filename
//sFile should be in "c:/folder/folder/file.extention" formatting
//Note: the parameters may not be more then 255 characters long
//Returns true on success false otherwise
int NWNX_DeleteFile( string sFile );
//File copy
//sOrginalFile and sNewFile should be in "c:/folder/folder/file.extention" formatting
//Note: the parameters may not be more then 255 characters long
//Returns true on success false otherwise
int NWNX_CopyFile( string sOrginalFile, string sNewFile, int bAllowOverWriting = FALSE );
//File moving
//sOrginalFile and sNewFile should be in "c:/folder/folder/file.extention" formatting
//Note: the parameters may not be more then 255 characters long
//Returns true on success false otherwise
int NWNX_MoveFile( string sOrginalFile, string sNewFile, int bAllowOverWriting = FALSE );
//File renaming
//sFile and sNewFileName should be in "c:/folder/folder/file.extention" formatting
//Note: the parameters may not be more then 255 characters long
//Returns true on success false otherwise
int NWNX_RenameFile( string sFile, string sNewFileName );
//Strips path from a fillfile path
//Example: "c:/folder/folder/file.extention" = "file.extention"
//nGetName = TRUE and it returns: "file.extention"
//nGetName = FALSE and it returns: "c:/folder/folder"
string NWNX_StripFilePath( string sFullFilePath, int nGetName = TRUE );
//Writes sData to sFile and breaks to the next line afterwards if nNextLine = true
int NWNX_WriteStringToTextFile( string sFile, string sData, int nNextLine = TRUE );
//Reads the entire content of sFile and returns as a string
//Suggest not using this on non textfiles or overly long ones, nwn strings has a limit.
string NWNX_ReadStringFromTextFile( string sFile );
//Sets oObjects gold worth to nValue
//Returns TRUE on success
int NWNX_SetGoldPieceValue( object oObject, int nValue );
//Get the filesize of sFile
int NWNX_GetFileSize( string sFile );
//Kill sProcess
void NWNX_TerminateProcess( string sProcess ); |
_________________ I dun have any signature, I'm happy anyway. |
|
Back to top |
|
|
Zebranky
Joined: 04 Jun 2006 Posts: 415
|
Posted: Tue Oct 06, 2009 19:29 Post subject: |
|
|
Source code? _________________ Win32 SVN builds: http://www.mercuric.net/nwn/nwnx/
<Fluffy-Kooshy> NWNx plugin is to this as nuclear warheads are to getting rid of fire ants.
<ThriWork> whenever I hear nwn extender, I think what does NWN need a penis extender for? |
|
Back to top |
|
|
Terra_777
Joined: 27 Jun 2008 Posts: 216 Location: Sweden
|
|
Back to top |
|
|
Zebranky
Joined: 04 Jun 2006 Posts: 415
|
Posted: Wed Oct 07, 2009 4:04 Post subject: |
|
|
Email is andrew@mercuric.net, but really you should just upload it _________________ Win32 SVN builds: http://www.mercuric.net/nwn/nwnx/
<Fluffy-Kooshy> NWNx plugin is to this as nuclear warheads are to getting rid of fire ants.
<ThriWork> whenever I hear nwn extender, I think what does NWN need a penis extender for? |
|
Back to top |
|
|
Terra_777
Joined: 27 Jun 2008 Posts: 216 Location: Sweden
|
Posted: Wed Oct 07, 2009 4:14 Post subject: |
|
|
Did, check above ign link. _________________ I dun have any signature, I'm happy anyway. |
|
Back to top |
|
|
|
|
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
|