Following on from various discussions about alignment/reputation and dynamic statics I'm interested to try some scripts including persistent variables. Two questions; To use the functions detailed on the Wiki do you need an include in your script; and are you encouraging such things or would you rather the database was left alone?
Cheers,
Teric
Persistent Variables
Moderators: ALFA Administrators, Staff - Technical
- Teric neDhalir
- Githyanki
- Posts: 1495
- Joined: Mon Jan 05, 2004 10:04 pm
- Location: Manchester UK
This is to be used in a conversation in Actions Taken (hit refresh so you can set the variable name and value).
And this is the Text Appears When version:
But AL will have the definitive method of doing it. This is just the way I do it.
Code: Select all
#include "ginc_param_const"
#include "ginc_var_ops"
#include "acr_db_persist_i"
void main(string sVariable, string sChange, string sTarget)
{
object oPC = GetPCSpeaker();
if (GetIsObjectValid(oPC) == FALSE)
PrintString("ga_local_int: " + sTarget + " is invalid");
int nOldValue = ACR_GetPersistentInt(oPC, sVariable);
int nNewValue = CalcNewIntValue(nOldValue, sChange);
ACR_SetPersistentInt(oPC, sVariable, nNewValue, 0);
//PrintString(sTarget + "'s variable " + sVariable + " is now set to " + IntToString(nNewValue) );
}
Code: Select all
#include "ginc_var_ops"
#include "acr_db_persist_i"
int StartingConditional(string sVariable, string sCheck)
{
object oPC = GetPCSpeaker();
int nValue = ACR_GetPersistentInt(oPC, sVariable);
int iRet = CompareInts(nValue, sCheck);
//PrintString ("gc_global_int: nValue = " + IntToString(nValue) + ", sCheck = " + sCheck + " -- return val: " + IntToString(iRet));
return (iRet);
}
