View previous topic :: View next topic |
Author |
Message |
ironhorse
Joined: 02 May 2005 Posts: 13 Location: uk
|
Posted: Thu Aug 24, 2006 4:58 Post subject: Character name checking. |
|
|
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 |
|
|
virusman
Joined: 30 Jan 2005 Posts: 1020 Location: Russia
|
Posted: Thu Aug 24, 2006 21:43 Post subject: Re: Character name checking. |
|
|
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 |
|
|
ironhorse
Joined: 02 May 2005 Posts: 13 Location: uk
|
Posted: Tue Sep 12, 2006 12:03 Post subject: |
|
|
Where you have put SQLExec, do you mean SQLExecDirect ?
Thanks |
|
Back to top |
|
|
ironhorse
Joined: 02 May 2005 Posts: 13 Location: uk
|
Posted: Wed Sep 27, 2006 20:37 Post subject: |
|
|
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 |
|
|
xaltos
Joined: 03 Jun 2006 Posts: 31 Location: Germany
|
Posted: Wed Sep 27, 2006 21:30 Post subject: |
|
|
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 |
|
|
|