Advertisement
Guest User

Lee Gao

a guest
Aug 5th, 2009
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.05 KB | None | 0 0
  1. Module USERSTATS Documentation
  2.  
  3. Dependencies: MySQLdb (Google MySQLdb and click on the first link)
  4.  
  5. 1. Extract all files into CS2D/sys/stats folder, make sure that userstatsdemo.py is in the stats folder and not in the userstats folder
  6. 2. Stop CS2D
  7. 3. Run the demo.py file
  8. 4. Modify demo.py to do what you need to do.
  9. 5. Change userstats.dat.backup to userstats.dat
  10.  
  11. ---------------------
  12. Using userstats.Stats
  13. ---------------------
  14. Stats.filename = filename => Creates the Stats.stats object
  15. Stats.login(username, [password]) => Logs in to the local MySQL Server
  16. Stats.run() => Saves a copy of the userstats.dat and userstats.sql file
  17. as well as updating the MySQL database
  18.  
  19. ====================================================
  20.  
  21. ----------------------
  22. Getting userstats data
  23. ----------------------
  24. stats -> userstats.Stats.stats
  25. Contains all of the userstats data of the given file.
  26. ----------------------
  27. stats[usgn] => Player
  28. stats(usgn = usgn) => Player
  29. stats(name = 'Player') => [Player, Player2, ...]
  30. stats.usgn_usgn => Player
  31.  
  32. ------------------------------------------
  33. stats[usgn] Contains the following members
  34. ------------------------------------------
  35. stats[usgn].name => Name of Player
  36. stats[usgn].kills => Number of Kills
  37. stats[usgn].death => Number of Deaths
  38. stats[usgn].time => Total amount of time played
  39.  
  40. ----------------------
  41. Setting userstats data
  42. ----------------------
  43. stats[usgn].name = name => Sets the name of Player to name
  44. stats[usgn].kills = kills => Sets the number of kills of Player
  45. stats[usgn].death = death => Sets the number of deaths of Player
  46. stats[usgn].time = time => Sets the total amount of time played
  47.  
  48. -----------------------
  49. Managing userstats data
  50. -----------------------
  51. stats.new(usgn, [name = name,] [kills = kills,] [death = death,] [time = time]) => Creates a new Player. USGN is required
  52. stats.remove(usgn) => Removes the Player @ USGN
  53. stats.remove("name = Player") => Removes the Player[S] with name of 'Player'
  54.  
  55. stats.save([name]) => Saves the userstats.dat file as name. (name is optional)
  56.  
  57. -------------------------------------------------------------------
  58. ===================================================================
  59. -------------------------------------------------------------------
  60. ---------------
  61. Database Models
  62. ---------------
  63. model -> userstats.Stats.model
  64. Contains the transformation functions to create SQL format representations of userstats
  65.  
  66. ------------------
  67. SQL Representation
  68. ------------------
  69. model.data => Contains auto-updated SQL representations of the userstats
  70.  
  71. ----------------------------------------------------------
  72. Model Functions => Requires MySQLdb (Else use save() only)
  73. ----------------------------------------------------------
  74. model.create_database([root = root_user,] [password = root_password])
  75. Creates the necessary MySQL database. user, and table dependencies. Does not require root or password
  76.  
  77. model.run()
  78. Updates the MySQL database
  79.  
  80. model.flush(root, password)
  81. Clears the MySQL table
  82.  
  83. model.save([name])
  84. Saves the SQL file as name.sql
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement