Skip to content

Commit 2a2c493

Browse files
committed
CHANGES:
- Do no longer send teamkill messages to the admin-channel if the punishment plugin is active.
1 parent 7a98a09 commit 2a2c493

File tree

4 files changed

+43
-29
lines changed

4 files changed

+43
-29
lines changed

plugins/mission/info.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
from core import report, Side, Player, DataObjectFactory, Member, utils
44
from datetime import datetime, timezone
55
from psycopg.rows import dict_row
6+
from plugins.srs.commands import SRS
7+
from typing import cast
68

79

810
class Header(report.EmbedElement):
@@ -182,7 +184,7 @@ async def render(self, player: Player):
182184
self.add_field(name="Slot", value=player.unit_callsign)
183185

184186
self.add_field(name="Module", value=player.unit_display_name)
185-
srs_plugin = self.bot.cogs.get('SRS', None)
187+
srs_plugin = cast(SRS, self.bot.cogs.get('SRS'))
186188
if srs_plugin:
187189
srs_users = srs_plugin.eventlistener.srs_users.get(player.server.name, {})
188190
if player.name in srs_users:

plugins/mission/listener.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,7 @@ async def onGameEvent(self, server: Server, data: dict) -> None:
803803
('player ' + player2.name) if player2 else 'AI',
804804
data['arg2'] or 'Cannon/Bomblet')
805805
)
806+
806807
elif data['eventName'] == 'self_kill':
807808
player = server.get_player(id=data['arg1']) if data['arg1'] != -1 else None
808809
side = player.side if player else Side.UNKNOWN
@@ -821,9 +822,16 @@ async def onGameEvent(self, server: Server, data: dict) -> None:
821822
data['arg2'] or 'SCENERY', Side(data['arg6']).name,
822823
('player ' + player2.name) if player2 is not None else 'AI',
823824
data['arg5'] or 'SCENERY', data['arg7'] or 'Cannon/Bomblet'))
825+
824826
# report teamkills from players to admins (only on public servers)
825827
if server.is_public() and player1 and player2 and data['arg1'] != data['arg4'] \
826828
and data['arg3'] == data['arg6']:
829+
# do not report if the punishment plugin is active and teamkills are punished
830+
if self.bot.cogs.get('Punishment'):
831+
_config = self.get_config(server, plugin_name='Punishment')
832+
if any(x for x in _config.get('penalties', []) if x.get('event', "") == 'kill'):
833+
return
834+
827835
name = ('Member ' + player1.member.display_name) \
828836
if player1.member else ('Player ' + player1.display_name)
829837
message = f"{name} (ucid={player1.ucid}) is killing team members."

plugins/mission/players.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ async def render(self, server: Server, sides: list[Coalition]):
1212
Side.RED: {"names": [], "units": [], "SRS": []},
1313
Side.NEUTRAL: {"names": [], "units": [], "SRS": []}
1414
}
15-
srs_plugin = cast(SRS, self.bot.cogs.get('SRS', None))
15+
srs_plugin = cast(SRS, self.bot.cogs.get('SRS'))
1616
if srs_plugin:
1717
srs_users = srs_plugin.eventlistener.srs_users.get(server.name, {})
1818
else:

plugins/punishment/README.md

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Plugin Punishment
2-
The DCSServerBot auto-ban, auto-kick, auto-move-back-to-spectators module, based on the players behaviour and the
2+
The DCSServerBot auto-ban, auto-kick, auto-move-back-to-spectators module, based on the player's behavior and the
33
configuration described in here.<br>
44
The ideas of this plugin are based on [Slmod](https://github.com/mrSkortch/DCS-SLmod). Thanks to Speed for his awesome solution!
55

@@ -14,7 +14,7 @@ The plugin itself is configured with a file named config/plugins/punishment.yaml
1414
```yaml
1515
DEFAULT:
1616
penalties: # These are the penalty points to use.
17-
- event: kill # If you kill a human player, you get 30 points, 18 in case of an AI.
17+
- event: kill # If you team-kill a human player, you get 30 points, 18 in the case of an AI.
1818
human: 30
1919
AI: 18
2020
action: move_to_spec
@@ -35,30 +35,30 @@ DEFAULT:
3535
default: 30
3636
reason: Respawning when being shot at
3737
forgive: 30 # People can forgive others in-between of 30 seconds (default) with the .forgive in-game chat command.
38-
punishments: # list of punishments, based on the users penalty points
38+
punishments: # list of punishments, based on the user's penalty points
3939
- points: 100 # we temp-ban the player when they reached 100 points.
4040
action: ban
4141
days: 3 # ban-time in days. default: 3
42-
- points: 60 # we kick them from the server, when their points reached 60
42+
- points: 60 # we kick them from the server when their points reached 60
4343
action: kick
44-
- points: 40 # we move them to spectators, when they have 40 points
44+
- points: 40 # we move them to spectators when they have 40 points
4545
action: move_to_spec
46-
- penalty: 10 # we take away credits from them, if they have 10 points
46+
- penalty: 10 # we take away credits from them if they have 10 points
4747
action: credits
48-
points: 12 # amount of credits to take
48+
points: 12 # number of credits to take
4949
- points: 1 # we warn them with each penalty point they got
5050
action: warn
51-
flightHoursWeight: # If you want to treat people that are frequent flyers on your server differently you can do this here
51+
flightHoursWeight: # If you want to treat people that are frequent flyers on your server differently, you can do this here
5252
- time: 0 # New joiners will get 1.4x the penalty points as described below
5353
weight: 1.4
54-
- time: 3 # people that were flying for at least 3 hours on your servers, get the described penalty points 1:1
54+
- time: 3 # people that were flying for at least 3 hours on your servers get the described penalty points 1:1
5555
weight: 1
5656
- time: 10 # people that flew longer than 10 hours get only 0.7x the penalty points (70%)
5757
weight: 0.7
5858
decay: # This describes how points should vanish over time
5959
- days: 0 # on the initial day, we do not do anything
6060
weight: 1
61-
- days: 3 # after 3 day, 75% of the points will still be there (25% will be wiped)
61+
- days: 3 # after 3 days, 75% of the points will still be there (25% will be wiped)
6262
weight: 0.75
6363
- days: 30 # after 30 days, an additional 75% of the points will be wiped (25% will still be there)
6464
weight: 0.25
@@ -74,20 +74,23 @@ DCS.dcs_serverrelease:
7474
- 'Moderators' # Do not punish your own moderators (Discord role, not bot role!) on this server
7575
```
7676
### Penalties
77-
The number of penalty points that a player "earns", is configured here. Collisions are hits where the players aircraft is being used as a weapon.
78-
You can add own events that you can use from inside the mission environment (see below), like the example here with "zone-bombing".<br/>
79-
If you use the inline "action"-element, you can already trigger any action like a "move_to_spec" or "credits" when someone
80-
FFs or kills a team member.
77+
The number of penalty points that a player "earns" is configured here.
78+
Collisions are hits where the player's aircraft is being used as a weapon.
79+
You can add your own events that you can use from inside the mission environment (see below), like the example here
80+
with "zone-bombing".<br/>
81+
If you use the inline "action"-element, you can already trigger any action like a "move_to_spec" or "credits" when
82+
someone FFs or kills a team member.
8183
8284
> [!NOTE]
83-
> Multiple events, that happen in-between a minute, are calculated as a single event. This is on purpose, to avoid too
84-
> many punishments when a user unintentionally dropped a CBU onto something or strafed multiple targets in one run.
85+
> Multiple events that happen in-between a minute are calculated as a single event.
86+
> This is on purpose, to avoid too many punishments when a user unintentionally dropped a CBU onto something or
87+
> strafed multiple targets in one run.
8588
8689
### Punishments
8790
Each point level can trigger a specific action. When the user hits this limit by gathering penalties, the specific
8891
action is being triggered. Actions are triggered at least every minute. So there might be a slight delay in being a bad
89-
pilot and getting punished. That allows victims to -forgive the dedicated act. A ban is temporary and punishment points
90-
can decay over time (see below).<br/>
92+
pilot and getting punished. That allows victims to `-forgive` the dedicated act.
93+
A ban is temporary, and punishment points can decay over time (see below).<br/>
9194

9295
In conjunction with the [CreditSystem](../creditsystem/README.md) plugin, you can use "credits" as a punishment and take away credit points
9396
from players if they misbehave. A campaign has to be running for this to happen.
@@ -105,16 +108,16 @@ Weight punishment by flight hours. This will be the sum of flight hours over all
105108

106109
### Decay
107110
Penalty points will decrease over time. This is configured here.
108-
Decay can only be configured once, so there is no need for a server specific configuration. All other elements can be configured for every server instance differently.
111+
Decay can only be configured once, so there is no need for a server-specific configuration. All other elements can be configured for every server instance differently.
109112

110113
> [!WARNING]
111114
> If you change the decay function, the existing penalties might not decay anymore, depending on how you adjust the
112115
> values. This is unfortunately an issue with how I implemented it.
113-
> You can reset your penalties in your database by using this SQL:
116+
> You can reset all the penalties in your database by using this SQL:
114117
> ```sql
115118
> DELETE FROM pu_events;
116119
> ```
117-
> After that, every new punishment will decay according to your new decay function.
120+
> After that, every new punishment will decay, according to your new decay function.
118121

119122
## Discord Commands
120123
| Command | Parameter | Channel | Role | Description |
@@ -129,8 +132,8 @@ Decay can only be configured once, so there is no need for a server specific con
129132
| -forgive | | all | Forgive the last actions that happened to your player. |
130133
| -penalty | | all | Shows your penalty points. |
131134

132-
## How to use the penalty system inside of missions
133-
To use the penalty system inside of missions, you can use this lua-function:
135+
## How to use the penalty system inside missions
136+
To use the penalty system inside missions, you can use this lua-function:
134137
```lua
135138
--[[
136139
eventName, the event according to the penalties table
@@ -141,17 +144,18 @@ dcsbot.punish(eventName, initiator, target)
141144
```
142145
Following the example above, a possible call could be:
143146
```lua
144-
[...]
147+
-- ...
145148
if condition then
146149
player = event.initiator.unit:getPlayerName()
147150
dcsbot.punish('zone-bombing', player)
148151
end
149-
[...]
152+
-- ...
150153
```
151154

152-
### How to disable punishments inside of missions
155+
### How to disable punishments inside missions
153156
Sometimes you don't want your mission to punish users at all, but you don't want to configure your server to
154-
disable them forever. To do so, you can just disable the punishments from inside your mission:
157+
disable them forever.
158+
To do so, you can disable the punishments from inside your mission:
155159
```lua
156160
if dcsbot then
157161
dcsbot.disablePunishments()

0 commit comments

Comments
 (0)