Files
Anphillia_PRC8/_module/nss/cnr_persist_inc.nss
Jaysyn904 28cdb617b3 Initial commit
Adding all of the current content for Anphillia Unlimited.
2024-01-04 07:49:38 -05:00

173 lines
6.1 KiB
Plaintext

/////////////////////////////////////////////////////////
//
// Craftable Natural Resources (CNR) by Festyx
//
// Name: cnr_persist_inc
//
// Desc: These functions are collected together to
// facilitate interfacing to a persistent database.
//
// Author: David Bobeck 20Apr03
//
/////////////////////////////////////////////////////////
// #include "your_persistent_db_inc_here"
// Note: no include is required to use Bioware's database.
// #include "aps_include"
#include "sql_inc"
#include "chr_inc"
// CNR defined return codes for CnrSQLFetch()
int CNR_SQL_ERROR = 0;
int CNR_SQL_SUCCESS = 1;
string _getVarName(object oHost, string sVarName)
{
if (GetIsPC(oHost))
return "PCID:" + IntToString(chr_GetPCID(oHost)) + "##" + sVarName;
return "NONPC:" + ObjectToString(oHost) + "##" + sVarName;
}
/////////////////////////////////////////////////////////
void CnrSetPersistentInt(object oHost, string sVarName, int nValue)
{
//WriteTimestampedLogEntry("SetPersistantInt: " + GetName(oHost) + " - " + sVarName + " - " + IntToString(nValue));
// Change this function call to whatever function
// should be called from the above include file
// for storing Integers in your Database
// uncomment the following line for NO database support
//SetLocalInt(oHost, sVarName, nValue);
// uncomment the following line for Bioware database support
//SetCampaignInt(CAMPAIGN_NAME, sVarName, nValue, oHost);
sql_SetVar(_getVarName(oHost, sVarName), IntToString(nValue));
// uncomment the following line for APS database support
//SetPersistentInt(oHost, sVarName, nValue, 0, CAMPAIGN_NAME);
}
/////////////////////////////////////////////////////////
int CnrGetPersistentInt(object oHost, string sVarName)
{
//WriteTimestampedLogEntry("GetPersistantInt: " + GetName(oHost) + " - " + sVarName);
// Change this function call to whatever function
// should be called from the above include file
// for retrieving Integers from your Database
// uncomment the following line for NO database support
//return GetLocalInt(oHost, sVarName);
// uncomment the following line for Bioware database support
//return GetCampaignInt(CAMPAIGN_NAME, sVarName, oHost);
return StringToInt(sql_GetVar(_getVarName(oHost, sVarName)));
// uncomment the following line for APS database support
//return GetPersistentInt(oHost, sVarName, CAMPAIGN_NAME);
}
/////////////////////////////////////////////////////////
void CnrSetPersistentFloat(object oHost, string sVarName, float fValue)
{
//WriteTimestampedLogEntry("SetPersistantFloat: " + GetName(oHost) + " - " + sVarName + " - " + FloatToString(fValue));
// Change this function call to whatever function
// should be called from the above include file
// for storing Floats in your Database
// uncomment the following line for NO database support
//SetLocalFloat(oHost, sVarName, fValue);
// uncomment the following line for Bioware database support
//SetCampaignFloat(CAMPAIGN_NAME, sVarName, fValue, oHost);
sql_SetVar(_getVarName(oHost, sVarName), FloatToString(fValue));
// uncomment the following line for APS database support
//SetPersistentFloat(oHost, sVarName, fValue, 0, CAMPAIGN_NAME);
}
/////////////////////////////////////////////////////////
float CnrGetPersistentFloat(object oHost, string sVarName)
{
//WriteTimestampedLogEntry("GetPersistantFloat: " + GetName(oHost) + " - " + sVarName);
// Change this function call to whatever function
// should be called from the above include file
// for retrieving Floats from your Database
// uncomment the following line for NO database support
//return GetLocalFloat(oHost, sVarName);
// uncomment the following line for Bioware database support
//return GetCampaignFloat(CAMPAIGN_NAME, sVarName, oHost);
string sSqlVar = sql_GetVar(_getVarName(oHost, sVarName));
return StringToFloat(sSqlVar);
// uncomment the following line for APS database support
//return GetPersistentFloat(oHost, sVarName, CAMPAIGN_NAME);
}
/////////////////////////////////////////////////////////
void CnrSetPersistentString(object oHost, string sVarName, string sValue)
{
//WriteTimestampedLogEntry("SetPersistantString: " + GetName(oHost) + " - " + sVarName + " - " + sValue);
// Change this function call to whatever function
// should be called from the above include file
// for storing Strings in your Database
// uncomment the following line for NO database support
//SetLocalString(oHost, sVarName, sValue);
// uncomment the following line for Bioware database support
//SetCampaignString(CAMPAIGN_NAME, sVarName, sValue, oHost);
sql_SetVar(_getVarName(oHost, sVarName), sValue);
// uncomment the following line for APS database support
//SetPersistentString(oHost, sVarName, sValue, 0, CAMPAIGN_NAME);
}
/////////////////////////////////////////////////////////
string CnrGetPersistentString(object oHost, string sVarName)
{
//WriteTimestampedLogEntry("GetPersistantString: " + GetName(oHost) + " - " + sVarName);
// Change this function call to whatever function
// should be called from the above include file
// for retrieving Strings from your Database
// uncomment the following line for NO database support
//return GetLocalString(oHost, sVarName);
// uncomment the following line for Bioware database support
//return GetCampaignString(CAMPAIGN_NAME, sVarName, oHost);
return sql_GetVar(_getVarName(oHost, sVarName));
// uncomment the following line for APS database support
//return GetPersistentString(oHost, sVarName, CAMPAIGN_NAME);
}
/////////////////////////////////////////////////////////
void CnrSQLExecDirect(string sSQL)
{
// If you're using APS, uncomment the following line
//SQLExecDirect(sSQL);
}
/////////////////////////////////////////////////////////
int CnrSQLFetch()
{
// If you're using APS, comment out the following line
return CNR_SQL_ERROR;
// If you're using APS, uncomment the following line
//return SQLFetch();
}
/////////////////////////////////////////////////////////
string CnrSQLGetData(int iCol)
{
// If you're using APS, comment out the following line
return "";
// If you're using APS, uncomment the following line
//return SQLGetData(iCol);
}