So when I try to use the database methods I get some problems. I create a local server with the authhostname set as auth.zandronum.com:166666. While saving the data, everything works fine but when loading it's all 0.
Relevant parts of code: (Pastebin:
Click)
[spoiler]
Code: Select all
Script 1001 (void) NET {
// if not hardcore don't bother trying to load
if(!GetCVar("dnd_hardcore"))
Terminate;
// not logged in we don't care
if(!PlayerIsLoggedIn(PlayerNumber()) || !HardcoreSet)
Terminate;
LoadPlayerData(PlayerNumber());
}
void LoadPlayerData(int pnum) {
// assumes all checks have been performed before reaching this function
int tid = P_TIDSTART + pnum, i = 0;
str pacc = GetPlayerAccountName(pnum);
print(s:pacc);
// prevents weapon tips from going crazy
GiveActorInventory(tid, "ParsingData", 1);
// read all things recorded one by one and give inventories
// reset weapons
ClearInventory();
for(i = 0; i < MAXWEPS; ++i)
TakeInventory(Weapons[i][WEPINFO_NAME], 1);
// read weapons
int temp = GetDBEntry(DND_DB_WEAPONINT_1, pacc);
print(d:temp);
for(i = SHOP_WEAPON_BEGIN; i < 32; ++i)
if(IsSet(temp, i))
GiveInventory(ShopItemNames[i][SHOPNAME_ITEM], 1);
temp = GetDBEntry(DND_DB_WEAPONINT_2, pacc);
for(i = SHOP_WEAPON_BEGIN + 32; i < SHOP_LASTWEP_INDEX; ++i)
if(IsSet(temp, i))
GiveInventory(ShopItemNames[i][SHOPNAME_ITEM], 1);
.......
.......
}
void SavePlayerData(int pnum) {
int temp, tid = pnum + P_TIDSTART, i, bit;
str pacc = GetPlayerAccountName(PlayerNumber());
// save weapons
for(i = 0; i < 32; ++i)
if(CheckActorInventory(tid, Weapons[i][WEPINFO_NAME]))
temp = SetBit(temp, i);
// send temp over
SetDBEntry(DND_DB_WEAPONINT_1, pacc, temp);
Log(d:GetDBentry(DND_DB_WEAPONINT_1, pacc));
temp = 0;
for(i = 32; i < MAXWEPS; ++i)
if(CheckActorInventory(tid, Weapons[i][WEPINFO_NAME]))
temp = SetBit(temp, i);
// send temp over
SetDBEntry(DND_DB_WEAPONINT_2, pacc, temp);
.....
.....
}
// Handle all database stuff now
Script 894 OPEN {
while(1) {
if(HardcoreSet && MapChanged) {
BeginDBTransaction();
for(int i = 0; i < MAXPLAYERS; ++i) {
if(PlayerInGame(i) && PlayerIsLoggedIn(i)) {
SavePlayerData(i);
Log(s:"Saving player ", d:i, s:"'s data.");
}
}
EndDBTransaction();
}
Delay(35);
}
}
[/spoiler]
I read correct values in the save function, which is usually a big number from GetDBEntry. But on the load function this is 0. Why is that?
Additionally, how do I view the database state? What must I do in this sqlite browser to view it?