Raised This Month: $51 Target: $400
 12% 

[EXTENSION] CalcPlayerScore (TF2)


Post New Thread Reply   
 
Thread Tools Display Modes
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, 1347 views)
File Type: zip CalcPlayerScore_source.zip (22.4 KB, 854 views)

Last edited by bl4nk; 10-22-2010 at 16:12.
bl4nk is offline
DontWannaName
Veteran Member
Join Date: Jun 2007
Location: VALVe Land, WA
Old 09-11-2008 , 03:17   Re: [EXTENSION] CalcPlayerScore (TF2)
Reply With Quote #2

Will this allow this http://forums.alliedmods.net/showthread.php?p=660327 to have TF2 support?
__________________

DontWannaName is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 09-11-2008 , 09:13   Re: [EXTENSION] CalcPlayerScore (TF2)
Reply With Quote #3

It could, yes. The plugin would just have to save the value of m_iScore for the player, and then use one of the native functions I provided to get the desired result.
bl4nk is offline
strontiumdog
Veteran Member
Join Date: Jan 2007
Location: BC, Canada
Old 09-11-2008 , 09:31   Re: [EXTENSION] CalcPlayerScore (TF2)
Reply With Quote #4

Good job Bl4nkeh!
__________________
Plugins | TheVille
Zombie Mod for DoD:S - l4dod.theville.org
strontiumdog is offline
L. Duke
Veteran Member
Join Date: Apr 2005
Location: Walla Walla
Old 09-11-2008 , 10:20   Re: [EXTENSION] CalcPlayerScore (TF2)
Reply With Quote #5

Nice bl4nk! I ran into this issue with the TF2NADES plugin, but decided on a workaround rather than trying to figure out an extension like this.

This will be appreciated by lots of plugin authors!
__________________
"Good grammar is essential, Robin."
- Batman
L. Duke is offline
strontiumdog
Veteran Member
Join Date: Jan 2007
Location: BC, Canada
Old 09-11-2008 , 10:50   Re: [EXTENSION] CalcPlayerScore (TF2)
Reply With Quote #6

It certainly will.....
__________________
Plugins | TheVille
Zombie Mod for DoD:S - l4dod.theville.org
strontiumdog is offline
exvel
SourceMod Donor
Join Date: Jun 2006
Location: Russia
Old 09-11-2008 , 11:39   Re: [EXTENSION] CalcPlayerScore (TF2)
Reply With Quote #7

What about DoD? Does it work for other OB games?
__________________
For admins: My plugins

For developers: Colors library
exvel is offline
Send a message via ICQ to exvel
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 09-11-2008 , 12:45   Re: [EXTENSION] CalcPlayerScore (TF2)
Reply With Quote #8

I don't play DOD:S so I'm not sure how the scoring system works.
bl4nk is offline
exvel
SourceMod Donor
Join Date: Jun 2006
Location: Russia
Old 09-11-2008 , 13:35   Re: [EXTENSION] CalcPlayerScore (TF2)
Reply With Quote #9

Extension crashes server. Tried to add bot - got crash. Tried to connect to my own server - got crash.
SourceMod v1.0.4
SourceMod v1.1.0
__________________
For admins: My plugins

For developers: Colors library

Last edited by exvel; 09-11-2008 at 13:57.
exvel is offline
Send a message via ICQ to exvel
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 09-11-2008 , 14:33   Re: [EXTENSION] CalcPlayerScore (TF2)
Reply With Quote #10

Hmm, looks like the extension has problems on Windows. I'll take a look at it and see why.
bl4nk is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:51.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode