Guest User

Untitled

a guest
Dec 9th, 2011
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. function saveClient(%this)
  2. {
  3. //Create a new file object
  4. %f = new fileObject();
  5. //Open our file object for writing purposes
  6. %f.openForWrite("config/mydata/"@%this.bl_id@".txt");
  7.  
  8. //Write our data
  9. //--------------
  10. %f.writeLine(%this.gold);
  11.  
  12. echo("Saved "@%this.name@"\'s gold which is "@%this.gold);
  13.  
  14. %f.writeLine(%this.level);
  15.  
  16. echo("Saved "@%this.name@"\'s level which is "@%this.gold);
  17. //--------------
  18.  
  19. //Close our file object
  20. %f.close();
  21. //Delete it
  22. %f.delete();
  23. }
  24.  
  25. function loadClient(%this)
  26. {
  27. //Create a new file object
  28. %f = new fileObject();
  29. //Open our file object for readin purposes
  30. %f.openForRead("config/mydata/"@%this.bl_id@".txt");
  31.  
  32. //Read our data
  33. //-------------
  34. %this.gold = %f.readLine();
  35.  
  36. echo("Loaded "@%this.name@"\'s gold which is "@%this.gold);
  37.  
  38. %this.level = %f.readLine();
  39.  
  40. echo("Loaded "@%this.name@"\'s level which is "@%this.level);
  41. //-------------
  42.  
  43. //Close our file object
  44. %f.close();
  45.  
  46. //Delete it
  47. %f.delete();
  48. }
  49.  
  50. //Declare package
  51. package saveAndLoad
  52. {
  53. function gameConnection::autoAdminCheck(%this)
  54. {
  55. parent::autoAdminCheck(%this);
  56.  
  57. //when someone joins, let's load them up!
  58. loadClient(%this);
  59. }
  60.  
  61. function gameConnection::onClientLeaveGame(%this)
  62. {
  63. //when someone leaves, let's save them before we call the parent!
  64. saveClient(%this);
  65.  
  66. parent::gameConnection::onClientLeaveGame(%this);
  67. }
  68. };
  69. //Activate our package
  70. activatePackage(saveAndLoad);
  71.  
Advertisement
Add Comment
Please, Sign In to add comment