With Zandronum 1.3 out, I think it should be possible to implement a persistent inventory system in ACS. (Konda's coop stats mod does this in 1.2 but doesn't save across server restarts.)
I'm going to start working on this for my Survivalism mod, but before I write some code I figured I'd ask and see if anyone had any ideas about how to approach it. AFAIK the only documentation for the new database functions is the changelog that Torr posted, along with the actual Zandronum source code.
Anyways, the simplest approach I can think of is using:
Code: Select all
void SetDBEntry ( string Namespace, string Key, int Value )
int GetDBEntry ( string Namespace, string Key )
Code: Select all
On player disconnect:
str persistentInventory[10] = { "Clip", "Rocket", "Shotgun", "SuperShotgun", etc... }
for (int i = 0; i < 10; i++) {
SetDBEntry(PlayerName + "_inventory", persistentInventory[i], GetActorInventory(playerTid, persistentInventory[i]));
}
When a player reconnects:
for (int i = 0; i < 10; i++) {
GiveActorInventory(playerTid, GetDBEntry(PlayerName + "_inventory", persistentInventory[i]));
}
I think the hardcoded list of inventory items to save is probably necessary since I don't think you can iterate over all inventory items in ACS. Also, it has the advantage that you won't be serializing dummy inventory items...
Thanks!
Hax