ShaDoOoW - It's not letting me message you for some reason, but I was curious if you could please explain to me how to fix the "server cr@ash du(ping ex&plo^it fix (by exporting character at Acquired events)", as I am well past the need for a base module.
You save when the character unaquires something (though you want to be a little more sophisticated about it). Otherwise, they can transfer it to another character, save that character (assuming you provide that functionality in something like a 'saving pen', or onrest), and cr%ash the server if they know an ex#plo@it to do so. The unsaved character is not saved as a result of the cr)ash, so they have all the items they transferred back again. Here's a code snippet from unacquire:
/* the object/area/possessor valid checks here are to ensure that
* barter doesn't break with onunacquire saving */
if (nItType != BASE_ITEM_POTIONS &&
nItType != BASE_ITEM_ENCHANTED_POTION &&
(!GetIsObjectValid(oItem) ||
GetIsObjectValid(oArea) ||
GetIsObjectValid(GetItemPossessor(oItem)))) {
ForceDelayedSave(oLoser);
}
The added checks are to prevent spamming of Exports. ForceDelayedSave is as follows, and does the same:
void ForceDelayedSave (object oPC, float fDelay=2.0) {
if (!GetIsPC(oPC) || GetIsDM(oPC))
return;
int nUptime = GetLocalInt(GetModule(), "uptime");
int nDelayedSave = GetLocalInt(oPC, "DelayedSave");
if (nDelayedSave < nUptime) {
SetLocalInt(oPC, "DelayedSave", nUptime);
DelayCommand(fDelay, ForceSave(oPC, TRUE));
} else if (nDelayedSave == nUptime + 1) {
SetLocalInt(oPC, "DelayedSave", nUptime + 2);
DelayCommand(10.0, ForceSave(oPC));
}
}
Obviously that particular function relies on an incrementing uptime timer in mod heartbeat, but there are lots of ways to skin that cat.
If you're nice, you'll also do a FDS onacquire, so that items transferred aren't lost if they forget to save.
That can get a bit tricky, as there may be times when you don't want to autosave, like when they're riffling through their bank items, and it autosaves when they close the chest (another potential ex+pl*oit there). Here are the other two spots where FDS is used in our mod, within a few lines of each other in onacquire:
/* don't save while transacting in vault */
if (!GetLocalInt(oLoser, "Vault") &&
GetStringLeft(sRes, 13) != "ele_material_" &&
GetStringLeft(sRes, 13) != "fey_material_")
ForceDelayedSave(oAcquire);
string sFound = "&&" + COLOR_LT_GREY + "Found ";
string sLoser = COLOR_LT_GREY + ".";
if (GetIsPC(oLoser)) {
ForceDelayedSave(oLoser);
if (GetArea(oAcquire) == GetArea(oLoser) && GetLocalInt(GetArea(oAcquire), "NO_PVP")) {
sFound = "&&" + COLOR_LT_GREY + "Received ";
sLoser = COLOR_LT_GREY + " from " + GetName(oLoser) + ".";
}
}
Funky