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 
 
Need help writing my first plug-in.

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



Joined: 31 Mar 2007
Posts: 10

PostPosted: Mon Jun 02, 2008 6:40    Post subject: Need help writing my first plug-in. Reply with quote

I've just started learning C++, and want to try to make an NWNX plug-in. What I need it to do is when a player logs in, a certain set of BIC files are moved into their servervault folder. I wrote a simple copy function for testing to see if I could get it to work, but have been unsuccessful so far.

Here's the copy function:
Code:

#include <windows.h>
#include <stdio.h>

void main()
{
SHFILEOPSTRUCT fileop;
  fileop.hwnd = NULL;
  fileop.wFunc = FO_COPY;
  fileop.pFrom = "C:\\test\\test.txt";
  fileop.pTo = "c:\\test\\test2\0";
  fileop.fFlags = FOF_ALLOWUNDO|FOF_NOCONFIRMATION|FOF_NOCONFIRMMKDIR;
  if (!SHFileOperation(&fileop));
  {
     printf("Copy Failed\n");
     system("PAUSE");
  }
}

I have read through pretty much every topic in this forum and tutorial1 and can't seem to figure out how to do this Sad I appreciate any help you guys can give me.
Back to top
View user's profile Send private message
Papillon
x-man


Joined: 28 Dec 2004
Posts: 1060
Location: Germany

PostPosted: Mon Jun 02, 2008 21:00    Post subject: Reply with quote

Before we discuss code, maybe you could elaborate a bit on what you are actually trying to achieve ?

The BIC files are moved into the players directory for what reason ? Why haven't they already been there, or if they have been deleted, how ?
_________________
Papillon
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Skipper Warlock



Joined: 31 Mar 2007
Posts: 10

PostPosted: Mon Jun 02, 2008 21:49    Post subject: Reply with quote

thanks for the reply.
The reason I want to move BIC files is because I want everyone to have the same characters available to them. I'm making a new type of server, and one of the things that it will require is for everyone to be able to choose from a set group of default characters.
Back to top
View user's profile Send private message
Skipper Warlock



Joined: 31 Mar 2007
Posts: 10

PostPosted: Sat Jun 07, 2008 20:13    Post subject: Reply with quote

*bump* >_<
Back to top
View user's profile Send private message
Skywing



Joined: 03 Jan 2008
Posts: 321

PostPosted: Sun Jun 08, 2008 17:11    Post subject: Reply with quote

As a general Win32 programming suggestion, you should look at CopyFile instead of SHFileOperation for this, in general. I would only use SHFileOperation if you are dealing with things that might be special virtual shell objects.
Back to top
View user's profile Send private message
Skipper Warlock



Joined: 31 Mar 2007
Posts: 10

PostPosted: Mon Jun 09, 2008 1:09    Post subject: Reply with quote

Thanks, I'll take a look at that. But can anyone tell me if it is possible to make this into an nwnx plug-in and lead me in the right direction to do that?
Back to top
View user's profile Send private message
Papillon
x-man


Joined: 28 Dec 2004
Posts: 1060
Location: Germany

PostPosted: Sun Jun 29, 2008 10:51    Post subject: Reply with quote

I do not think this would work - scripts only fire after a player has already logged in, and this happens long after the BIC file has been chosen...
_________________
Papillon
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Fireboar



Joined: 17 Feb 2008
Posts: 323

PostPosted: Sun Jun 29, 2008 16:04    Post subject: Reply with quote

Yep - what would have to happen in your case is to hook the event that gives the message "connection attempt made by: xyz" in the server logs. At that point the server does some stuff before showing the player the list of characters. You could then move the bic files over before accepting the connection.

I don't know what you'd have to hook though.
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