Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement