View Single Post
Author Message
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 09-11-2008 , 01:55   [EXTENSION] CalcPlayerScore (TF2)
Reply With Quote #1

CalcPlayerScore
v1.2.0

WARNING: This extension can (more than likely it will) screw up your stats permanently. Use with caution!

Description:
Modify players' scores using a variety of methods.

Installation:
Download the CalcPlayerScore.zip located at the bottom of the post and extract it to the base of your TF2 mod folder.

CVars:
cps_version - CalcPlayerScore version.

Commands:
sm_addscore <#userid|name> <points> - Add x points to the player's score.
sm_setscore <#userid|name> <score> - Set the player's score to x.
sm_setscoremod <#userid|name> <score> - Set the player's score modifier to x.

Forwards:
PHP Code:
/**
 * @brief Called when a player's score is being calculated.
 *
 * @param client        Client index of the player.
 * @param score         The player's unmodified score.
 * @return              The player's desired score.
 */
forward OnCalcPlayerScore(clientscore); 


Notes:
  • This extension works by hooking CalcPlayerScore and adding a score modifier to the default returned value, in turn making the score appear to be something it's truely not.
  • You can directly set that score modifier by using sm_setscoremod or you can add/subtract to it using sm_addscore.
  • If you want to set the player's score to something specific (say 1337), you can use sm_setscore to do that (setting that to -1 sets their score to the normal value - taking into account the score modifier, of course).
  • The score modifier is reset for each player on map change. This is a precaution just in case a player leaves and a new players joins in their place, or if the player reconnects with a different client index.
  • This extension will have problems with my RunTeamLogic extension. You can not (at this time) run both at once. In the future I might make it so they can work together, but for now they will not.
Thanks to:
pRED* for the detour code.
Nephyrin for helping me figure out a crash on map change.
CrimsonGT for finding the reason that this extension crashed on Windows.

Changelog:
  • 1.0.0
    • Initial release.
  • 1.1.0
    • Linux only (for the time being).
    • Removed score system from the extension and moved it to the plugin.
    • Scores actually set now (an untested last minute change screwed it up before).
    • Removed the natives and added the OnCalcPlayerScore forward.
  • 1.2.0
    • Windows version released
    • Changed a few minor things in the plugin, all commands and such remain the same
    • Added a few extra checks to prevent modifying the wrong player's score
Attached Files
File Type: zip CalcPlayerScore.zip (104.3 KB, 1356 views)
File Type: zip CalcPlayerScore_source.zip (22.4 KB, 859 views)

Last edited by bl4nk; 10-22-2010 at 16:12.
bl4nk is offline