[CSGO] Getting and setting player score

Please post any questions about developing your plugin here. Please use the search function before posting!
User avatar
VinciT
Senior Member
Posts: 331
Joined: Thu Dec 18, 2014 2:41 am

[CSGO] Getting and setting player score

Postby VinciT » Mon Nov 13, 2017 1:40 am

I'm trying to change the score of a player (last column on the scoreboard), but I'm not sure how to do it.
Any ideas?
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: [CSGO] Getting and setting player score

Postby L'In20Cible » Mon Nov 13, 2017 1:50 am

Player.kills/deaths

Syntax: Select all

player = Player(index)
player.kills = 0
player.deaths = 999
print(f'{player.name} is a noob, check the scoreboard!')
User avatar
VinciT
Senior Member
Posts: 331
Joined: Thu Dec 18, 2014 2:41 am

Re: [CSGO] Getting and setting player score

Postby VinciT » Mon Nov 13, 2017 2:19 am

Is there no way to directly change the score, without changing the player's kills?
When I change the player's assists, the score doesn't update, so I'm trying to correct that by changing the score itself.
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: [CSGO] Getting and setting player score

Postby L'In20Cible » Mon Nov 13, 2017 2:20 am

What is your code?
User avatar
VinciT
Senior Member
Posts: 331
Joined: Thu Dec 18, 2014 2:41 am

Re: [CSGO] Getting and setting player score

Postby VinciT » Mon Nov 13, 2017 2:57 am

Here's the code:

Syntax: Select all

#assists_test.py
from players.entity import Player

from commands import CommandReturn
from commands.client import ClientCommand


@ClientCommand('add_assist')
def _add_assist(command, index):
player = Player(index)
player.assists += 1
return CommandReturn.BLOCK
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: [CSGO] Getting and setting player score

Postby satoon101 » Mon Nov 13, 2017 3:04 am

I know that the score is based off of kills and assists, but possibly also includes bomb detonations/defusals and hostage rescues. So, I'm not sure that modifying kills or assists would automatically change the score. I have looked into this a little, but I haven't figured out how to get/set the score in a plugin.
Image
User avatar
VinciT
Senior Member
Posts: 331
Joined: Thu Dec 18, 2014 2:41 am

Re: [CSGO] Getting and setting player score

Postby VinciT » Mon Nov 13, 2017 3:35 am

I just found this in SourceMod. Although I'm not sure how to do the exact same thing in SP.

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 29 guests