PDA

View Full Version : [Example] Changing player score


raydan
12-20-2008, 04:16
Here is the sample plugin to using "IncrementFragCount" to change player score. As we know, we can use "m_iFrags" or "m_iDeaths" to change score and death in game scoreboard, but you can't see updated data in server info.

In this example, you can add/set/reset scroe/death value in scorebaord and server info

PS: setting too high score/death value, scoreboard can't show correct value, but server info still display the real one.


RegConsoleCmd("add_score", add_5_score); // add 5 score
RegConsoleCmd("add_death", add_5_death); // add 5 death

RegConsoleCmd("reset_score", reset_score); //reset score to 0
RegConsoleCmd("reset_death", reset_death); //reset death to 0

RegConsoleCmd("set_score", set_score_to_4321); // set score to 4321
RegConsoleCmd("set_death", set_death_to_4321); // set death to 4321


http://img397.**************/img397/3369/omg12345scoreag2.jpg

bl4nk
12-20-2008, 13:18
Can't you just change m_iScore for players in CS:S?

CrimsonGT
12-20-2008, 21:02
I am thinking maybe that doesnt change it in the server window outside of game that he posted, so thats what this extention does. Not sure though.

DJ Tsunami
12-21-2008, 04:56
Anything with new signatures is fun to play with :)

Forlix
01-11-2009, 11:11
Another solution, without all those "complicated" SDK calls:

Global variable:

new game_score_index;

On round_start:

game_score_index = CreateEntityByName("game_score");
DispatchSpawn(game_score_index);

When you want to update someones score (in this example decrease by one):


SetEntProp(client, Prop_Data, "m_iFrags", GetClientFrags(client)-1);
AcceptEntityInput(game_score_index, "ApplyScore", client, game_score_index);

Works perfectly with CS:S and server query.
Of course you can also only use game_score to increase or decrease, but the way above is more flexible - you only need one entity, can set the scores to your hearts content, and then simply trigger an update.