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 
 
SQLEncode and SQLDecode calls.

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



Joined: 31 Dec 2004
Posts: 55
Location: San Diego CA.

PostPosted: Sat Jan 15, 2005 17:26    Post subject: SQLEncode and SQLDecode calls. Reply with quote

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
View user's profile Send private message
Papillon
x-man


Joined: 28 Dec 2004
Posts: 1060
Location: Germany

PostPosted: Sat Jan 15, 2005 21:32    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website MSN Messenger
Makzimia De Graf



Joined: 31 Dec 2004
Posts: 55
Location: San Diego CA.

PostPosted: Sun Jan 16, 2005 2:20    Post subject: Reply with quote

Thanks Pap, Embarassed 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
View user's profile Send private message
Mask



Joined: 20 Mar 2005
Posts: 12

PostPosted: Sun Mar 20, 2005 5:41    Post subject: Well... Reply with quote

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
View user's profile Send private message Send e-mail MSN Messenger
Mask



Joined: 20 Mar 2005
Posts: 12

PostPosted: Sun Mar 20, 2005 5:48    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail MSN Messenger
NoMercy



Joined: 03 Jan 2005
Posts: 123
Location: UK

PostPosted: Sun Mar 20, 2005 15:53    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website MSN Messenger
Mask



Joined: 20 Mar 2005
Posts: 12

PostPosted: Sun Mar 20, 2005 20:10    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail MSN Messenger
Primogenitor



Joined: 08 Jan 2005
Posts: 88

PostPosted: Mon Mar 21, 2005 12:56    Post subject: Reply with quote

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
View user's profile Send private message
Mask



Joined: 20 Mar 2005
Posts: 12

PostPosted: Mon Mar 21, 2005 15:54    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail MSN Messenger
Primogenitor



Joined: 08 Jan 2005
Posts: 88

PostPosted: Mon Mar 21, 2005 16:33    Post subject: Reply with quote

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
View user's profile Send private message
Mask



Joined: 20 Mar 2005
Posts: 12

PostPosted: Sun Mar 27, 2005 11:22    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail MSN Messenger
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