View previous topic :: View next topic |
Author |
Message |
ironhorse
Joined: 02 May 2005 Posts: 13 Location: uk
|
Posted: Tue Sep 28, 2010 16:30 Post subject: checking for same name in database |
|
|
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 |
|
|
Zebranky
Joined: 04 Jun 2006 Posts: 415
|
Posted: Tue Sep 28, 2010 18:09 Post subject: |
|
|
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 |
|
|
|