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 
 
NWNX Files

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Windows development
View previous topic :: View next topic  
Author Message
ShaDoOoW



Joined: 20 Aug 2005
Posts: 565

PostPosted: Fri Feb 06, 2009 13:54    Post subject: NWNX Files Reply with quote

So I finally done it.

This plugin allow basic file functions in nwscript. This plugin have access only to server's files and directories.

DOWNLOAD version 1.0 (plugin + nwscript include + source)

I myself doubt about usage, however few things could be done with this. For example getting newest bic file to get player char's bic, backuping and deleting bics, logging. I know, this all was already there in other plugins, however difference is that now you have much more confort and control over this (in exchange for efficiency).

int FileExists(string filename, string path="");
int FileDeleteFile(string filename, string path="");
int FileDeleteDirectory(string dirname, string path="");
string FileMD5(string filename, string path="");
int FileClose();
int FileWrite(string sString);
int FileSize(string filename, string path="");
int FileOpen(string filename, string path="", int nMode = FILE_OPEN_MODE_FOR_READING);
int FileCopy(string filename, string path, string newpath, string newname="", int rewrite_if_exists=FALSE);
string FileRead();
struct time FileTime(string filename, string path="", int nTime=FILE_TIME_OF_WRITE);
int FileCreateFile(string filename, string path="");
int FileCreateDirectory(string dirname, string path="");
string FileGetFirst(string path="", string filter="*", int mode=FILE_SEARCH_FOR_FILES);
string FileGetNext(string path="", string filter="*", int mode=FILE_SEARCH_FOR_FILES);

example how to loop all files in player directory (this will make account backup)
Code:
string path = "servervault/"+GetPCPlayerName(oPC);
FileCreateDirectory(backup,path);
string newpath = path+"/backup";
string filter = "*.bic";
string file = FileGetFirst(path,filter);
 while(file != "")
 {
 FileCopy(file,path,newpath,"",TRUE);
 file = FileGetNext(path,filter);
 }

example how to read from file:
Code:
string sAll;
FileOpen("readme.txt");
file = FileRead();
 while(file!="")
 {
 sAll+=file;
 file = FileRead();
 }
FileClose();
//ok sAll now contain every text in readme.txt

_________________
Community Patch / NWNX Patch / NWNX Files / NWNX Connect


Last edited by ShaDoOoW on Tue Jul 06, 2010 16:04; edited 5 times in total
Back to top
View user's profile Send private message
MaxRock



Joined: 24 Jan 2008
Posts: 196

PostPosted: Fri Feb 06, 2009 19:21    Post subject: Reply with quote

This will come in handy. Thank you very much.

One minor thing I've found is that TIME request doesn't write back the seconds to nwn
Back to top
View user's profile Send private message Send e-mail MSN Messenger
ShaDoOoW



Joined: 20 Aug 2005
Posts: 565

PostPosted: Tue Jul 06, 2010 15:55    Post subject: Reply with quote

So I finally decided to update my plugin. Yeah Terra_777 overcame me with his plugin, so I stopped further development, however I managed to make three new functions until that and felt there is still reason to share it with others.
Code:
//return current unix time (seconds since midnight 1. January 1970)
int GetSystemTime();

//this will rename existing file in specified path to given new name
//returns TRUE if creating will be sucesfull, FALSE otherwise
//filename - desired file name eg. "readme.txt"
//path - full or partial path to the directory which should contain this file for more info look at FileExists function
//newname - desired new file name eg "test.txt"
int FileRenameFile(string filename, string path, string newname);

//using GetSystemTime, this will search through all files in PC account directory and
//return the newly changed
//in order this function get return real newest bic, you have to save character in OnClientEnter
//and call this function with some delay (like 3.0), as ExportSingleCharacter is not instant
//then I would recommend to save the bic into database, so you will have to do this only for new characters
//Note: this is nwscriptwise function using other File functions
//Note: do not work in OnClientExit (but thats unlogical to use it there anyway)
string GetNewestBic(object oPC);


Also I updated FileTime to return integer, unix time which was kinda requested by MaxRock Smile.
_________________
Community Patch / NWNX Patch / NWNX Files / NWNX Connect
Back to top
View user's profile Send private message
ShaDoOoW



Joined: 20 Aug 2005
Posts: 565

PostPosted: Sun Jul 11, 2010 13:24    Post subject: Reply with quote

I had request for ftp handling at vault, however I can't contact requester. Anyway I realised what it could be good for, so if anyone would like this feature, I could get back to work Smile.
_________________
Community Patch / NWNX Patch / NWNX Files / NWNX Connect
Back to top
View user's profile Send private message
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Sun Jul 11, 2010 22:16    Post subject: a stretch but... Reply with quote

Its a bit of a stretch, but it might be useful to make a plugin that is capable of monitoring specific folders, and checking for the most recent file versions.

Eg - If it detects a newer version of the Module, reset
or
Detects newer Haks, reset....
or perhaps monitor a ftp folder, for such things, and download them automatically

I only suggest it because I recently made an application in c# to allow me to transfer my BMU files and 2da files to my website, where they get rar'd in my nightly builds.

Note - I hate FtpWebRequests - theyre sooooo unfriendly.

But the application itself was kinda cool.
Makes an ini file, where the user can specify the local folder to scan,
the file type to scan for,
remote address and folder to put the file,
username and password for the ftp,

and then it has a neat wee feature, allowing the user to have it on quiet mode too, so it uploads, and closes itself when done. BMU's and all, it could be a long file transfer.

But yeah, some plugin which can be used for managing haks, bmus, or files that a module may require?
Back to top
View user's profile Send private message
RoyHobbs



Joined: 17 Dec 2015
Posts: 2

PostPosted: Mon Mar 07, 2016 19:28    Post subject: Character Deletion Reply with quote

I am looking for the Linux Alternative

Does anyone know how to set this up so that the character is renamed and saved to the server vault and removed from the player vault?

Anything at this point would be greatly appreciated...
Back to top
View user's profile Send private message
ShaDoOoW



Joined: 20 Aug 2005
Posts: 565

PostPosted: Mon Mar 14, 2016 14:06    Post subject: Re: Character Deletion Reply with quote

RoyHobbs wrote:
I am looking for the Linux Alternative

Does anyone know how to set this up so that the character is renamed and saved to the server vault and removed from the player vault?

Anything at this point would be greatly appreciated...

No idea what do you even need...

This plugin is very simple and Im afraid I won't be able to add any more functionalities...
_________________
Community Patch / NWNX Patch / NWNX Files / NWNX Connect
Back to top
View user's profile Send private message
RoyHobbs



Joined: 17 Dec 2015
Posts: 2

PostPosted: Tue Mar 15, 2016 2:37    Post subject: Charactr Deletion Reply with quote

I am trying to set up a way to delete character and we use Linux. For some reason I am missing something. I was sent the .so files from a friend.

Is there any place that explains how to make this work or I am trying to hard and making this more problematic than it needs to be?

I want to have the characters renamed and removed from the players list but archived in the database.

I am the one making updates to the server and have been asked to set this up but i dont have access to the server or the plugins.
Back to top
View user's profile Send private message
ShaDoOoW



Joined: 20 Aug 2005
Posts: 565

PostPosted: Tue Mar 15, 2016 3:01    Post subject: Re: Charactr Deletion Reply with quote

nwnx_system for linux has File related functions
_________________
Community Patch / NWNX Patch / NWNX Files / NWNX Connect
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Windows development 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