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 
 
Troubles calling data back into nwn

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Development
View previous topic :: View next topic  
Author Message
Der Phobos



Joined: 07 Nov 2006
Posts: 14

PostPosted: Tue Nov 28, 2006 3:56    Post subject: Troubles calling data back into nwn Reply with quote

I'm using the basic scripts supplied with nwnx, trying to call a speakstring of what I exported, however its not calling it back into the module. I built a php page to verify that the data is correct and that I am brining in proper data. The page displays the results I wrote just as they should be, however nwn cant call back the string. Anyone have any ideas of where to begin debuging, or any tricks?
Back to top
View user's profile Send private message
Urlord



Joined: 17 Nov 2006
Posts: 122

PostPosted: Tue Nov 28, 2006 7:23    Post subject: Re: Troubles calling data back into nwn Reply with quote

Der Phobos wrote:
I'm using the basic scripts supplied with nwnx, trying to call a speakstring of what I exported, however its not calling it back into the module. I built a php page to verify that the data is correct and that I am brining in proper data. The page displays the results I wrote just as they should be, however nwn cant call back the string. Anyone have any ideas of where to begin debuging, or any tricks?


Please post your code that you are using to read in the data from the database. Then we can try to help you troubleshoot it.
_________________
Jim (aka, Urlord)
Visit the Persistent World of Nymri
Back to top
View user's profile Send private message Send e-mail
Der Phobos



Joined: 07 Nov 2006
Posts: 14

PostPosted: Tue Nov 28, 2006 7:39    Post subject: Reply with quote

string sVar = GetPersistentString(oPC, "Highland Saga");
SpeakString(sVar, TALKVOLUME_SHOUT);

string GetPersistentString(object oObject, string sVarName, string sTable = "pwdata")
{
string sPlayer;
string sTag;

if (GetIsPC(oObject))
{
sPlayer = SQLEncodeSpecialChars(GetPCPlayerName(oObject));
sTag = SQLEncodeSpecialChars(GetName(oObject));
}
else
{
sPlayer = "~";
sTag = GetTag(oObject);
}

sVarName = SQLEncodeSpecialChars(sVarName);

string sSQL = "SELECT val FROM " + sTable + " WHERE player='" + sPlayer +
"' AND tag='" + sTag + "' AND name='" + sVarName + "'";
SQLExecDirect(sSQL);

if (SQLFetch() == SQL_SUCCESS)
return SQLDecodeSpecialChars(SQLGetData(1));
else
{
return "";
// If you want to convert your existing persistent data to SQL, this
// would be the place to do it. The requested variable was not found
// in the database, you should
// 1) query it's value using your existing persistence functions
// 2) save the value to the database using SetPersistentString()
// 3) return the string value here.
}
}
_________________
Highland Saga: Black Dawn
Back to top
View user's profile Send private message
Papillon
x-man


Joined: 28 Dec 2004
Posts: 1060
Location: Germany

PostPosted: Tue Nov 28, 2006 9:09    Post subject: Reply with quote

The easiest way to find problems like this is to enable full logging (level 2) in nwnx.ini and then have a look at the generated SQL statements. You can easily compare the SELECT to the actual data in the database, and see why no data is coming back.
_________________
Papillon
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Der Phobos



Joined: 07 Nov 2006
Posts: 14

PostPosted: Tue Nov 28, 2006 11:00    Post subject: Reply with quote

I figured it out, thanks though.
_________________
Highland Saga: Black Dawn
Back to top
View user's profile Send private message
caloup



Joined: 29 Sep 2006
Posts: 59
Location: albi (france)

PostPosted: Tue Nov 28, 2006 15:06    Post subject: HELLO Reply with quote

You should call the function AFTER the define of this function, i think :

Quote:


string GetPersistentString(object oObject, string sVarName, string sTable = "pwdata")
{
string sPlayer;
string sTag;

if (GetIsPC(oObject))
{
sPlayer = SQLEncodeSpecialChars(GetPCPlayerName(oObject));
sTag = SQLEncodeSpecialChars(GetName(oObject));
}
else
{
sPlayer = "~";
sTag = GetTag(oObject);
}

sVarName = SQLEncodeSpecialChars(sVarName);

string sSQL = "SELECT val FROM " + sTable + " WHERE player='" + sPlayer +
"' AND tag='" + sTag + "' AND name='" + sVarName + "'";
SQLExecDirect(sSQL);

if (SQLFetch() == SQL_SUCCESS)
return SQLDecodeSpecialChars(SQLGetData(1));
else
{
return "";
// If you want to convert your existing persistent data to SQL, this
// would be the place to do it. The requested variable was not found
// in the database, you should
// 1) query it's value using your existing persistence functions
// 2) save the value to the database using SetPersistentString()
// 3) return the string value here.
}
}

void main()
{
string sVar = GetPersistentString(oPC, "Highland Saga");
SpeakString(sVar, TALKVOLUME_SHOUT);
}

Back to top
View user's profile Send private message
Der Phobos



Joined: 07 Nov 2006
Posts: 14

PostPosted: Tue Nov 28, 2006 18:29    Post subject: Reply with quote

first off they were in two diffrent scripts, one with an include of the sql_include.

Second the problem was something I tried setting up before I remembered that nwn doesnt realy have array objects. A script I thought I had removed but had not and was goofing everything up.
_________________
Highland Saga: Black Dawn
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Development 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