Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Module USERSTATS Documentation
- Dependencies: MySQLdb (Google MySQLdb and click on the first link)
- 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
- 2. Stop CS2D
- 3. Run the demo.py file
- 4. Modify demo.py to do what you need to do.
- 5. Change userstats.dat.backup to userstats.dat
- ---------------------
- Using userstats.Stats
- ---------------------
- Stats.filename = filename => Creates the Stats.stats object
- Stats.login(username, [password]) => Logs in to the local MySQL Server
- Stats.run() => Saves a copy of the userstats.dat and userstats.sql file
- as well as updating the MySQL database
- ====================================================
- ----------------------
- Getting userstats data
- ----------------------
- stats -> userstats.Stats.stats
- Contains all of the userstats data of the given file.
- ----------------------
- stats[usgn] => Player
- stats(usgn = usgn) => Player
- stats(name = 'Player') => [Player, Player2, ...]
- stats.usgn_usgn => Player
- ------------------------------------------
- stats[usgn] Contains the following members
- ------------------------------------------
- stats[usgn].name => Name of Player
- stats[usgn].kills => Number of Kills
- stats[usgn].death => Number of Deaths
- stats[usgn].time => Total amount of time played
- ----------------------
- Setting userstats data
- ----------------------
- stats[usgn].name = name => Sets the name of Player to name
- stats[usgn].kills = kills => Sets the number of kills of Player
- stats[usgn].death = death => Sets the number of deaths of Player
- stats[usgn].time = time => Sets the total amount of time played
- -----------------------
- Managing userstats data
- -----------------------
- stats.new(usgn, [name = name,] [kills = kills,] [death = death,] [time = time]) => Creates a new Player. USGN is required
- stats.remove(usgn) => Removes the Player @ USGN
- stats.remove("name = Player") => Removes the Player[S] with name of 'Player'
- stats.save([name]) => Saves the userstats.dat file as name. (name is optional)
- -------------------------------------------------------------------
- ===================================================================
- -------------------------------------------------------------------
- ---------------
- Database Models
- ---------------
- model -> userstats.Stats.model
- Contains the transformation functions to create SQL format representations of userstats
- ------------------
- SQL Representation
- ------------------
- model.data => Contains auto-updated SQL representations of the userstats
- ----------------------------------------------------------
- Model Functions => Requires MySQLdb (Else use save() only)
- ----------------------------------------------------------
- model.create_database([root = root_user,] [password = root_password])
- Creates the necessary MySQL database. user, and table dependencies. Does not require root or password
- model.run()
- Updates the MySQL database
- model.flush(root, password)
- Clears the MySQL table
- model.save([name])
- Saves the SQL file as name.sql
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement