Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. Script 1001 (void) NET {
  2. // if not hardcore don't bother trying to load
  3. if(!GetCVar("dnd_hardcore"))
  4. Terminate;
  5.  
  6. // not logged in we don't care
  7. if(!PlayerIsLoggedIn(PlayerNumber()) || !HardcoreSet)
  8. Terminate;
  9. LoadPlayerData(PlayerNumber());
  10. }
  11.  
  12. void LoadPlayerData(int pnum) {
  13. // assumes all checks have been performed before reaching this function
  14. int tid = P_TIDSTART + pnum, i = 0;
  15. str pacc = GetPlayerAccountName(pnum);
  16. print(s:pacc);
  17. // prevents weapon tips from going crazy
  18. GiveActorInventory(tid, "ParsingData", 1);
  19.  
  20. // read all things recorded one by one and give inventories
  21.  
  22. // reset weapons
  23. ClearInventory();
  24. for(i = 0; i < MAXWEPS; ++i)
  25. TakeInventory(Weapons[i][WEPINFO_NAME], 1);
  26.  
  27. // read weapons
  28. int temp = GetDBEntry(DND_DB_WEAPONINT_1, pacc);
  29. print(d:temp);
  30. for(i = SHOP_WEAPON_BEGIN; i < 32; ++i)
  31. if(IsSet(temp, i))
  32. GiveInventory(ShopItemNames[i][SHOPNAME_ITEM], 1);
  33.  
  34. temp = GetDBEntry(DND_DB_WEAPONINT_2, pacc);
  35. for(i = SHOP_WEAPON_BEGIN + 32; i < SHOP_LASTWEP_INDEX; ++i)
  36. if(IsSet(temp, i))
  37. GiveInventory(ShopItemNames[i][SHOPNAME_ITEM], 1);
  38.  
  39. .......
  40. .......
  41. }
  42.  
  43. void SavePlayerData(int pnum) {
  44. int temp, tid = pnum + P_TIDSTART, i, bit;
  45. str pacc = GetPlayerAccountName(PlayerNumber());
  46. // save weapons
  47. for(i = 0; i < 32; ++i)
  48. if(CheckActorInventory(tid, Weapons[i][WEPINFO_NAME]))
  49. temp = SetBit(temp, i);
  50. // send temp over
  51. SetDBEntry(DND_DB_WEAPONINT_1, pacc, temp);
  52. Log(d:GetDBentry(DND_DB_WEAPONINT_1, pacc));
  53.  
  54. temp = 0;
  55. for(i = 32; i < MAXWEPS; ++i)
  56. if(CheckActorInventory(tid, Weapons[i][WEPINFO_NAME]))
  57. temp = SetBit(temp, i);
  58. // send temp over
  59. SetDBEntry(DND_DB_WEAPONINT_2, pacc, temp);
  60. .....
  61. .....
  62. }
  63.  
  64. // Handle all database stuff now
  65. Script 894 OPEN {
  66. while(1) {
  67. if(HardcoreSet && MapChanged) {
  68. BeginDBTransaction();
  69. for(int i = 0; i < MAXPLAYERS; ++i) {
  70. if(PlayerInGame(i) && PlayerIsLoggedIn(i)) {
  71. SavePlayerData(i);
  72. Log(s:"Saving player ", d:i, s:"'s data.");
  73. }
  74. }
  75. EndDBTransaction();
  76. }
  77. Delay(35);
  78. }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement