Another plugin request

I would like a plugin which give money each round. If a file can store the amount to give and a sentence, it will be better
Thanks you
Syntax: Select all
# ../addons/source-python/plugins/<plugin_name>/<plugin_name>.py
# =============================================================================
# >> IMPORTS
# =============================================================================
# Source.Python Imports
# Config
from config.manager import ConfigManager
# Cvars
from cvars.flags import ConVarFlags
# Events
from events import Event
# Filters
from filters.players import PlayerIter
# Messages
from messages import SayText2
# Translations
from translations.strings import LangStrings
# =============================================================================
# >> GLOBAL VARIABLES
# =============================================================================
# Get the translation strings
config_strings = LangStrings('<plugin_name>')
# Get the message to send
message = SayText2(message=config_strings['chat'])
# =============================================================================
# >> CONFIGURATION
# =============================================================================
# Create the config file
with ConfigManager('<plugin_name>') as config:
# Create the cash amount convar
cash_amount = config.cvar(
'round_cash_amount', 100, ConVarFlags.NONE,
'Amount of cash to add to each player at the start of each round.')
# =============================================================================
# >> GAME EVENTS
# =============================================================================
@Event('round_start')
def give_cash(game_event):
# Get the cash amount
amount = cash_amount.get_int()
# Loop through all living players
for player in PlayerIter('alive', return_types='player'):
# Give the current player the cash amount
player.cash += amount
# Send the message to all players
message.send(amount=amount)
Syntax: Select all
# ../resource/source-python/translations/<plugin_name>.ini
[chat]
en = "You were given $$$amount."
Syntax: Select all
player.cash += amount
Syntax: Select all
player.cash = min(player.cash+amount, 16000)
Predz wrote:Change:Syntax: Select all
player.cash += amount
To:Syntax: Select all
player.cash = min(player.cash+amount, 16000)
Will make it so no matter the situation, when cash is given that the player's cash will never exceed $16000.
Syntax: Select all
# ../addons/source-python/plugins/GiveCash/GiveCash.py
# =============================================================================
# >> IMPORTS
# =============================================================================
# Source.Python Imports
# Config
from config.manager import ConfigManager
# Cvars
from cvars.flags import ConVarFlags
# Events
from events import Event
# Filters
from filters.players import PlayerIter
# Messages
from messages import SayText2
# Translations
from translations.strings import LangStrings
# =============================================================================
# >> GLOBAL VARIABLES
# =============================================================================
# Get the translation strings
#config_strings = LangStrings('GiveCash')
# Get the message to send
#message = SayText2(message=config_strings['chat'])
# =============================================================================
# >> CONFIGURATION
# =============================================================================
# Create the config file
with ConfigManager('GiveCash') as config:
# Create the cash amount convar
cash_amount = config.cvar(
'round_cash_amount', 100, ConVarFlags.NONE,
'Amount of cash to add to each player at the start of each round.')
# =============================================================================
# >> GAME EVENTS
# =============================================================================
@Event('round_start')
def give_cash(game_event):
# Get the cash amount
amount = cash_amount.get_int()
# Loop through all living players
for player in PlayerIter('alive', return_types='player'):
# Give the current player the cash amount
player.cash += min(player.cash+amount, 16000)
# Send the message to all players
message.send(amount=amount)
Syntax: Select all
player.cash = min(player.cash+amount, 16000)
Syntax: Select all
player.cash += min(player.cash+amount, 16000)
Syntax: Select all
# ../addons/source-python/plugins/GiveCash/GiveCash.py
# =============================================================================
# >> IMPORTS
# =============================================================================
# Source.Python Imports
# Config
from config.manager import ConfigManager
# Cvars
from cvars.flags import ConVarFlags
# Events
from events import Event
# Filters
from filters.players import PlayerIter
# Messages
from messages import SayText2
# Translations
from translations.strings import LangStrings
# =============================================================================
# >> GLOBAL VARIABLES
# =============================================================================
# Get the translation strings
config_strings = LangStrings('GiveCash')
# Get the message to send
message = SayText2(message=config_strings['chat'])
# =============================================================================
# >> CONFIGURATION
# =============================================================================
# Create the config file
with ConfigManager('GiveCash') as config:
# Create the cash amount convar
cash_amount = config.cvar(
'round_cash_amount', 100, ConVarFlags.NONE,
'Amount of cash to add to each player at the start of each round.')
# =============================================================================
# >> GAME EVENTS
# =============================================================================
@Event('round_start')
def give_cash(game_event):
# Get the cash amount
amount = cash_amount.get_int()
# Loop through all living players
for player in PlayerIter('alive', return_types='player'):
# Give the current player the cash amount
player.cash = min(player.cash+amount, 16000)
# Send the message to all players
message.send(amount=amount)
Syntax: Select all
# ../addons/source-python/plugins/GiveCash/GiveCash.py
# =============================================================================
# >> IMPORTS
# =============================================================================
# Source.Python Imports
# Config
from config.manager import ConfigManager
# Cvars
from cvars.flags import ConVarFlags
# Events
from events import Event
# Filters
from filters.players import PlayerIter
# Messages
from messages import SayText2
# Translations
from translations.strings import LangStrings
# =============================================================================
# >> GLOBAL VARIABLES
# =============================================================================
# Get the translation strings
message_strings = LangStrings('GiveCash')
# Store the give message instance
give_message = SayText2(message=message_strings['Give'])
# Store the max cash message instance
max_message = SayText2(message=message_strings['Max'])
# =============================================================================
# >> CONFIGURATION
# =============================================================================
# Create the config file
with ConfigManager('GiveCash') as config:
# Create the cash amount convar
cash_amount = config.cvar(
'round_cash_amount', 100, ConVarFlags.NONE,
'Amount of cash to add to each player at the start of each round.')
# =============================================================================
# >> GAME EVENTS
# =============================================================================
@Event('round_start')
def give_cash(game_event):
# Get the cash amount
amount = cash_amount.get_int()
# Loop through all living players
for player in PlayerIter('alive', return_types='player'):
# Get the amount to add to the current player
give_amount = min(player.cash + amount, 16000) - player.cash
# Does the player need any cash?
if give_amount:
# Give the current player the cash amount
player.cash += give_amount
# Send the give message to the player
give_message.send(player.index, amount=give_amount)
# Does the player already have max cash?
else:
# Send the max cash message to the player
max_message.send(player.index)
Syntax: Select all
# ../resource/source-python/translations/GiveCash.ini
[Give]
en = "You were given $$$amount."
[Max]
en = "You are already at max cash, none given."
Users browsing this forum: Bing [Bot] and 75 guests