This is the include which I'm going to be using in a Custom Binding Rod, which allows for Recall Back to saved locations, however, I having problems with the NWN database, and I don't have a part for NWNX2, therefore, I'm asking a talented scripter to help me here...
Can someone who is skilled in database scripting help me make this include correct and add NWNX2 functionality to it as well?
Your help will be greatly apprecated, not just by me, but by the community as well, for this script is going in my custom scripted items module which I'm making for the community. (It's going to be HUGE!)
Here is what I have so far in the include script... (Edited 8/13/10) - Tested To Be Good (Offline or Online)
////////////////////////////////////////////////////////////////////////////
//Script Name: gen_bind_inc (Include Script)
///////////////////////////////////////////////////////////////////////////
//Created By: Genisys (Guile)
//Created On: 7/25/10
///////////////////////////////////////////////////////////////////////////
/*
Set the important settings below for the Binding Rod System!
This system uses database, but it doesn't have to!
*/
///////////////////////////////////////////////////////////////////////////
//Set this to FALSE if you DON'T want to use a Database
//NOTE: By use of Database the system IS PERSISTENT! (BUT Not For Recall!)
const int USE_DATABASE = TRUE; //Default = TRUE ~ Use The NWN Database
//Set this to 1 for Storing by Account Login Name (Not The Character's Name)
//Set this to 2 for storing by Public CD Key
//Set this to 3 for storing by the Genisys ID Token System (Must have my Current Starter Module!)
const int USE_THIS_ID_SYSTEM = 1; //Default = 1 (Use PC Login Name)
//Set this to 1 if you if this is a Multiplayer Online Module
//Set this to 2 if this is a Single Player Module!
//Set this to 3 only if you have my (Genisys / Guile) most recent starter modules
const int MODULE_BINDING = 2; //Default = 2 (Single Player Offline Modules)
///////////////////////////////////////////////////////////////////////////////
//Declare Custom Prototypes
string BINDING_NAME(object oPC);
location GetCampLoc(object oPC, int nSlot);
void SetTokenLocation(location lSaved, int nSaved);
void SetTokens(object oPC);
void SetBindedLocation(object oPC, location lStored, int nSlot);
//////////////////////////////////////////////////////////////////////////////
//Define Custom Prototypes
//////////////////////////////////////////////////////////////////////////////
string BINDING_NAME(object oPC)
{
string sBind = "BINDING_LOCATION"; //Default String..
object oToken = GetItemPossessedBy(oPC, "id_token");
string sToken = GetName(oToken);
string sAdd;
int nMod;
if(MODULE_BINDING == 1)
{
nMod = TRUE;
}
else if(MODULE_BINDING == 2)
{ nMod = FALSE; }
else if(MODULE_BINDING == 3)
{
nMod = GetLocalInt(GetModule(), "MULTI");
}
//If we are using the Database System..
if(USE_DATABASE)
{
//In Multi Player we use the Player's Login Account Name
if(USE_THIS_ID_SYSTEM == 1)
{
//Limit to 18 Characters...
sAdd = GetStringLeft(GetPCPlayerName(oPC), 18);
}
//In Single Player we use the Player's CD Key Only...
else if(USE_THIS_ID_SYSTEM == 2)
{
sAdd = GetPCPublicCDKey(oPC, nMod);
}
//For the Unique Player ID System (Works offline or online!) IN MY MODULES ONLY
else if(USE_THIS_ID_SYSTEM == 3)
{
sAdd = sToken;
}
//Send this as what to use...
return sBind + sAdd;
}
//Otherwise we are NOT Using the Database System, so do this instead..
else
{
//In Multi Player we use the Player's Login Account Name
if(USE_THIS_ID_SYSTEM == 1)
{
//This needs to be something else...
sAdd = GetStringLeft(GetPCPlayerName(oPC), 24);
}
//In Single Player we use the Player's CD Key Only...
else if(USE_THIS_ID_SYSTEM == 2)
{
sAdd = GetPCPublicCDKey(oPC, nMod);
}
//For the Unique Player ID System (Works offline or online!) IN MY MODULES ONLY
else if(USE_THIS_ID_SYSTEM == 3)
{
sAdd = sToken;
}
//Tell the script to use this instead for - Non-Database Storing..
return sBind + sAdd;
}
//Function End
}
///////////////////////////////////////////////////////////////////////////////
location GetCampLoc(object oPC, int nSlot)
{
string sCamp = "GEN_BINDINGS";
string sVar;
location lVar;
//If we are using the Database
if(USE_DATABASE)
{
sVar = BINDING_NAME(oPC);
return GetCampaignLocation(sCamp, sVar, oPC);
}
else
{
sVar = "BINDING_LOCATION";
return GetLocalLocation(oPC, sVar);
}
return lVar;
//Function End
}
////////////////////////////////////////////////////////////////////////////////
void SetTokenLocation(location lSaved, int nSaved)
{
object oArea;
int nToken = 420 + nSaved; //eg 421, 422, 423 etc..
string sName;
oArea = GetAreaFromLocation(lSaved);
if(oArea != OBJECT_INVALID)
{
sName = GetName(oArea);
}
else
{
sName = "Location Not Stored";
}
SetCustomToken(nToken, sName);
//Function End
}
///////////////////////////////////////////////////////////////////////////////
void SetTokens(object oPC)
{
string sID = BINDING_NAME(oPC);
location l1,l2,l3,l4,l5,l6;
if(USE_DATABASE)
{
//NOTE: This will function properly for any module, because it validates area!
l1 = GetCampaignLocation("GEN_BINDINGS", sID + "1", oPC);
l2 = GetCampaignLocation("GEN_BINDINGS", sID + "2", oPC);
l3 = GetCampaignLocation("GEN_BINDINGS", sID + "3", oPC);
l4 = GetCampaignLocation("GEN_BINDINGS", sID + "4", oPC);
l5 = GetCampaignLocation("GEN_BINDINGS", sID + "5", oPC);
l6 = GetCampaignLocation("GEN_BINDINGS", sID + "6", oPC);
}
else
{
l1 = GetLocalLocation(oPC, sID + "1");
l2 = GetLocalLocation(oPC, sID + "2");
l3 = GetLocalLocation(oPC, sID + "3");
l4 = GetLocalLocation(oPC, sID + "4");
l5 = GetLocalLocation(oPC, sID + "5");
l6 = GetLocalLocation(oPC, sID + "6");
}
SetTokenLocation(l1, 1);
DelayCommand(0.1, SetTokenLocation(l2, 2));
DelayCommand(0.2, SetTokenLocation(l3, 3));
DelayCommand(0.3, SetTokenLocation(l4, 4));
DelayCommand(0.4, SetTokenLocation(l5, 5));
DelayCommand(0.5, SetTokenLocation(l6, 6));
//Function End
}
///////////////////////////////////////////////////////////////////////////////
void SetBindedLocation(object oPC, location lStored, int nSlot)
{
string sBind = BINDING_NAME(oPC);
string sSlot = IntToString(nSlot);
location lVar;
SetCampaignLocation("GEN_BINDINGS", sBind + sSlot, lStored, oPC);
//Function End
}
///////////////////////////////////////////////////////////////////////////////
I'm using the functions above in scripts which are part of a conversation..
Modifié par Genisys, 13 août 2010 - 04:54 .