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 
 
Character name checking.

 
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: Thu Aug 24, 2006 4:58    Post subject: Character name checking. Reply with quote

I am trying to figure out how to do the following.

I am trying to make the following on my PW but I dont know how to do the check. I am trying to make it that when a character speaks to an NPC, it runs a check in the database to see if the characters name is unique (the systems I have in the world require unique names).

So for example the database has the following names:

Vostan Blake
Mara Blake
Rossii
Creal

(these are active players in the world)

Someone comes on with the name Mara Blake and speaks to the NPC to get onto the world, it checks the name list and sees that it matches. So the NPC then says that someone else has that name on the world and doesn't let them in.

I am an ok scripter but I dont know how to do the mysql checks for this.

Thanks in advance,

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



Joined: 30 Jan 2005
Posts: 1020
Location: Russia

PostPosted: Thu Aug 24, 2006 21:43    Post subject: Re: Character name checking. Reply with quote

ironhorse wrote:
I am trying to figure out how to do the following.

I am trying to make the following on my PW but I dont know how to do the check. I am trying to make it that when a character speaks to an NPC, it runs a check in the database to see if the characters name is unique (the systems I have in the world require unique names).

So for example the database has the following names:

Vostan Blake
Mara Blake
Rossii
Creal

(these are active players in the world)

Someone comes on with the name Mara Blake and speaks to the NPC to get onto the world, it checks the name list and sees that it matches. So the NPC then says that someone else has that name on the world and doesn't let them in.

I am an ok scripter but I dont know how to do the mysql checks for this.

Thanks in advance,

Ironhorse

SQLExec("SELECT id FROM chars WHERE name='"+SQLEncodeSpecialChars(GetName(oPC))+"'");
if (SQLFetch())
{
//this character name is already taken
return 0;
}
else
{
SQLExec("INSERT INTO chars (name) VALUES('"+SQLEncodeSpecialChars(GetName(oPC))+"')");
//character name is now added to DB
}
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
ironhorse



Joined: 02 May 2005
Posts: 13
Location: uk

PostPosted: Tue Sep 12, 2006 12:03    Post subject: Reply with quote

Where you have put SQLExec, do you mean SQLExecDirect ?

Thanks
Back to top
View user's profile Send private message Visit poster's website
ironhorse



Joined: 02 May 2005
Posts: 13
Location: uk

PostPosted: Wed Sep 27, 2006 20:37    Post subject: Reply with quote

I have been trying to get this section of the script to work but I am getting no where.

Here is what I have.

Code:

#include "aps_include"
void main()
{
object oPC = GetPCSpeaker();
int nNew = 0;

SQLExecDirect("SELECT id FROM charnames WHERE name='"+SQLEncodeSpecialChars(GetName(oPC))+"'");
if (SQLFetch())
{
//this character name is already taken
nNew = 1;
}

if (nNew = 1)
    {
    ActionStartConversation(oPC, "no_access", TRUE);
    }
if (nNew = 0)
    {
    ActionStartConversation(oPC, "new_char", TRUE);
    }

}


Can anyone help please. It just keeps using the conv that doesnt allow people on (saying that the name is already used), but its not.

Thanks

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



Joined: 03 Jun 2006
Posts: 31
Location: Germany

PostPosted: Wed Sep 27, 2006 21:30    Post subject: Reply with quote

This is wrong:
Code:

if (nNew = 1)
...
if (nNew = 0)
...



Use == instead.
( e.g. if (nNew == 1) )

A single = will assign a new value to nNew.
Back to top
View user's profile Send private message
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