View previous topic :: View next topic |
Author |
Message |
Makzimia De Graf
Joined: 31 Dec 2004 Posts: 55 Location: San Diego CA.
|
Posted: Sat Jan 15, 2005 17:26 Post subject: SQLEncode and SQLDecode calls. |
|
|
Hi guys. Ok, I am almost ready to test the new stuff, however, there is an issue. In aps_include, we made changes as you know to use multiple tables etc. In the newer coding we have done which makes extensive use of MySQL calls etc... we have now run into a problem that you may not be aware of.
You have placed code in aps_include which translates the ' character to a ~ in MySQL although that is a terminator normally, it is actually possible to translate that correctly. Can you advise me on a fix, I have addicted working on it as well anyway, as we have a lot of players now who's PCs are not useable since we turned on some new code that requires the names to match 100%.
Thanks in advance.
Makz. _________________ Makzimia De Graf
DM/Creator Island of Fredian
fredian.game-host.org:5123
Forums at http://castille.us/fredian/Forums |
|
Back to top |
|
|
Papillon x-man
Joined: 28 Dec 2004 Posts: 1060 Location: Germany
|
Posted: Sat Jan 15, 2005 21:32 Post subject: |
|
|
I understand your have database entries containing ' characters and what to keep it that way ?
Then you would have to modify SQLEncodeSpecialChars as following:
Code: |
for (i = 0; i < GetStringLength(sString); i++)
{
sChar = GetSubString(sString, i, 1);
if (sChar == "'")
sReturn += "''";
else
sReturn += sChar;
}
|
Note how you can escape ' characters in MySQL with another ', instead of the ~ character. I have not tested this, please take this just as an idea. _________________ Papillon |
|
Back to top |
|
|
Makzimia De Graf
Joined: 31 Dec 2004 Posts: 55 Location: San Diego CA.
|
Posted: Sun Jan 16, 2005 2:20 Post subject: |
|
|
Thanks Pap, we actually found the issue, we think, he forgot a Decode call in one of his latest scripts.
Makz. _________________ Makzimia De Graf
DM/Creator Island of Fredian
fredian.game-host.org:5123
Forums at http://castille.us/fredian/Forums |
|
Back to top |
|
|
Mask
Joined: 20 Mar 2005 Posts: 12
|
Posted: Sun Mar 20, 2005 5:41 Post subject: Well... |
|
|
I don't suppose you were getting a bunch of database entries similiar to the following:
~ PC_HP 0 0 20050314173812
~ PCSavePoint 0 20050314173812
I have 3 entries per PC: Savepoint, IC point, and HP.
Forwhat ever reason I have bout 200 actual player entries, adn abotu 2,000 non-sense entries like the above.
Using standard SQL calling as of this point, but gonna try adn change it with the above alteration, not sure that's what's causing my problem, but its the best I can figure. _________________ DM Mask
Legacy of Netheril |
|
Back to top |
|
|
Mask
Joined: 20 Mar 2005 Posts: 12
|
Posted: Sun Mar 20, 2005 5:48 Post subject: |
|
|
Swapping it out inplace of:
Code: | for (i = 0; i < GetStringLength(sString); i++)
{
sChar = GetSubString(sString, i, 1);
if (sChar == "'")
sReturn += "~";
else
sReturn += sChar;
} |
Would any modificaitons need to be made to teh decode special characters as well? *Pretty damn new to SQL, having learned it only for use in NWN, and pretty damned dumb* _________________ DM Mask
Legacy of Netheril |
|
Back to top |
|
|
NoMercy
Joined: 03 Jan 2005 Posts: 123 Location: UK
|
Posted: Sun Mar 20, 2005 15:53 Post subject: |
|
|
I think the normal route to escape characters is to put a \ before them, \' and requires no decode function, least that's how things are done in php/perl's SQL functions. |
|
Back to top |
|
|
Mask
Joined: 20 Mar 2005 Posts: 12
|
Posted: Sun Mar 20, 2005 20:10 Post subject: |
|
|
well, as of today, I have three entries...
RodgerYoung Mazer Rackham H_IC_Point #AREA#H_WelcomeArea#POSITION_X# 14.988953590#... 0 20050320214308
~ H_IC_Point 0 20050320215412
-Shield- Carol H_IC_Point #AREA#X_H_Fixed08#POSITION_X# 39.871822357#PO... 0 20050320215413
Any bright idea's anyone, I was at a loss when I posted here origionally. _________________ DM Mask
Legacy of Netheril |
|
Back to top |
|
|
Primogenitor
Joined: 08 Jan 2005 Posts: 88
|
Posted: Mon Mar 21, 2005 12:56 Post subject: |
|
|
I suspect your putting objects into the database? And what its doing instead is converting the object into the objects ID number, which is not persistant accross server resets (as in, things get renumbered). Try using tags instead, assuming its for fixed objects on the server such as save points. Make sure the tags are unique so the player doesnt end up at another object by accident. |
|
Back to top |
|
|
Mask
Joined: 20 Mar 2005 Posts: 12
|
Posted: Mon Mar 21, 2005 15:54 Post subject: |
|
|
Ya Gonna hate me primo...
Here are the actual scripts that are writing said values.
Code: | #include "aps_include"
void main()
{
object oPC = OBJECT_SELF;
location lTarget = GetLocation(oPC);
if(GetIsPC(oPC))
{
SetPersistentLocation(oPC, "PCSavePoint", lTarget);
SetPersistentInt(oPC, "PC_HP", GetCurrentHitPoints(oPC));
ExportSingleCharacter(oPC);
}
} |
And...
Code: | #include "aps_include"
void OOCJumper(object oUser)
{
location lOOC = GetLocation(GetObjectByTag("H_Jump_To_OOC_Room"));
SetPersistentLocation(oUser, "H_IC_Point", GetLocation(oUser));
DelayCommand(0.1f, AssignCommand(oUser, ActionJumpToLocation(lOOC)));
}
void main() {
object oUser = GetPCSpeaker();
if (GetArea(oUser) == GetArea(GetObjectByTag("H_OOC_Chat_Room")))
{
SendMessageToPC(oUser, "Your already in the OOC Room.... " + "Sorry, not gonna work.");
}
else
{
OOCJumper(oUser);
}
} |
_________________ DM Mask
Legacy of Netheril |
|
Back to top |
|
|
Primogenitor
Joined: 08 Jan 2005 Posts: 88
|
Posted: Mon Mar 21, 2005 16:33 Post subject: |
|
|
Just to clarify, the problem is with database entries that start with ~ but the scripts work OK?
The ~ at the start is put there if the oObject parameter is not a PC. Or at least doesnt return true for GetIsPC(). Make sure that your passing in a valid object, though how it could be invalid I dont know. Actually, it must be an invalid object becuase GetTag is returning nothing. Try changing your function to:
Code: |
void OOCJumper(object oUser)
{
if(!GetIsObjectValid(oUser))
return;
location lOOC = GetLocation(GetObjectByTag("H_Jump_To_OOC_Room"));
SetPersistentLocation(oUser, "H_IC_Point", GetLocation(oUser));
DelayCommand(0.1f, AssignCommand(oUser, ActionJumpToLocation(lOOC)));
} |
|
|
Back to top |
|
|
Mask
Joined: 20 Mar 2005 Posts: 12
|
Posted: Sun Mar 27, 2005 11:22 Post subject: |
|
|
seems to have solved it, Now I just need to tie that in with the save script.
as ever primo you save the day. _________________ DM Mask
Legacy of Netheril |
|
Back to top |
|
|
|