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 
 
checking for same name in database

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Scripts and Modules
View previous topic :: View next topic  
Author Message
ironhorse



Joined: 02 May 2005
Posts: 13
Location: uk

PostPosted: Tue Sep 28, 2010 16:30    Post subject: checking for same name in database Reply with quote

Hi all,

I am trying to figure out how I can check that the name of the incoming player has not already been taken.

now a good few years ago I was given this

SQLExecDirect("SELECT id FROM charnames WHERE tag='"+SQLEncodeSpecialChars(GetName(oPC))+"'");

but it just doesn't seem to work

Here is full script
Code:

int nNew = 0;
SQLExecDirect("SELECT id FROM charnames WHERE tag='"+SQLEncodeSpecialChars(GetName(oPC))+"'");
if (SQLFetch())
{
nNew = 1;
}



All I am trying to do is check to see if the player that is coming in doesn't already have the name that someone else has. The names are under tag in pwdata.

Can anybody help please?

Thanks,

Ironhorse
Back to top
View user's profile Send private message Visit poster's website
Zebranky



Joined: 04 Jun 2006
Posts: 415

PostPosted: Tue Sep 28, 2010 18:09    Post subject: Reply with quote

It's not clear whether you mean the names are in pwdata or in charnames. However, this is how I'd do it, assuming you did mean pwdata:
Code:
int nExists = 0;
SQLExecDirect(SELECT COUNT(*) FROM pwdata WHERE tag='" + SQLEncodeSpecialChars(GetName(oPC)) + "'");
if(SQLFetch() == SQL_SUCCESS)
  if(StringToInt(SQLGetData(1)))
    nExists = 1;

Not tested, but I think that should do 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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Scripts and Modules 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