Here's the functions for that from NWNX's APS include:
string SQLLocationToString(location lLocation)
{
object oArea = GetAreaFromLocation(lLocation);
vector vPosition = GetPositionFromLocation(lLocation);
float fOrientation = GetFacingFromLocation(lLocation);
string sReturnValue = "#AREA#" + GetTag(oArea) +
"#POSITION_X#" + FloatToString(vPosition.x) +
"#POSITION_Y#" + FloatToString(vPosition.y) +
"#POSITION_Z#" + FloatToString(vPosition.z) +
"#ORIENTATION#" + FloatToString(fOrientation) + "#END#";
return sReturnValue;
}
location SQLStringToLocation(string sLocation)
{
location lReturnValue;
object oArea;
vector vPosition;
float fOrientation, fX, fY, fZ;
int nPos, nCount, nLen = GetStringLength(sLocation);
if (nLen > 0)
{
nPos = FindSubString(sLocation, "#AREA#") + 6;
nCount = FindSubString(GetSubString(sLocation, nPos, nLen - nPos), "#");
oArea = GetObjectByTag(GetSubString(sLocation, nPos, nCount));
nPos = FindSubString(sLocation, "#POSITION_X#") + 12;
nCount = FindSubString(GetSubString(sLocation, nPos, nLen - nPos), "#");
fX = StringToFloat(GetSubString(sLocation, nPos, nCount));
nPos = FindSubString(sLocation, "#POSITION_Y#") + 12;
nCount = FindSubString(GetSubString(sLocation, nPos, nLen - nPos), "#");
fY = StringToFloat(GetSubString(sLocation, nPos, nCount));
nPos = FindSubString(sLocation, "#POSITION_Z#") + 12;
nCount = FindSubString(GetSubString(sLocation, nPos, nLen - nPos), "#");
fZ = StringToFloat(GetSubString(sLocation, nPos, nCount));
vPosition = Vector(fX, fY, fZ);
nPos = FindSubString(sLocation, "#ORIENTATION#") + 13;
nCount = FindSubString(GetSubString(sLocation, nPos, nLen - nPos), "#");
fOrientation = StringToFloat(GetSubString(sLocation, nPos, nCount));
lReturnValue = Location(oArea, vPosition, fOrientation);
}
return lReturnValue;
}
Modifié par Squatting Monk, 18 mai 2013 - 08:56 .