Bomb Money

Release your plugins here!
User avatar
Kill
Member
Posts: 88
Joined: Wed Aug 31, 2016 10:05 pm

Bomb Money

Postby Kill » Sat Sep 17, 2016 10:59 pm

About

Give money to bomb planter(bomb has to successfully explode) and to bomb defuser.
Supports translations (translation file is 'bombmoney.ini' and can be found inside the folder ../resource/source-python/translations/).


Cvars

The plugin will automatically generate a config file (can be found inside the folder ../cfg/source-python)

Code: Select all

// ######################################################################### //
//                       Bomb Money configuration file                       //
// ######################################################################### //

// Default Value: 1000
// Money to reward the bomb planter.
   bomb_plant_reward 1000


// Default Value: 1000
// Money to reward the bomb defuser.
   bomb_defuse_reward 1000


// Default Value: 1
// Reward bots too? can be 1 (true) or 0 (false).
   bomb_reward_bot 1


// Default Value: 1
// Reward the whole team? can be 1 or 0.
   bomb_reward_team 1


// Default Value: 0
// Different money amount? can be 1 or 0.
   bomb_reward_team_money 0


// Default Value: 1000
// Money to reward the player's team(Counter-Terrorist).
   bomb_team_reward_ct 1000


// Default Value: 1000
// Money to reward the player's team(Terrorist).
   bomb_team_reward_t 1000





Installation
Extract the zip
Drag and drop
In server or autoexec(or manually using the server console)

Code: Select all

sp plugin load bombmoney



Download
https://github.com/Hackmastr/bombmoney/ ... master.zip

Thanks to
  • iPlayer for his translations and his help!
  • Ayuto for helping
  • satoon101 for helping
Last edited by Kill on Sat Sep 24, 2016 7:53 pm, edited 9 times in total.
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: Bomb Money

Postby Ayuto » Sat Sep 17, 2016 11:14 pm

Nice! :smile:

Just wanted to let you know that you are missing a comma in line 36. Instead of this

Syntax: Select all

if GAME_NAME not in ('csgo'):

it should look like this:

Syntax: Select all

if GAME_NAME not in ('csgo',):
User avatar
iPlayer
Developer
Posts: 590
Joined: Sat Nov 14, 2015 8:37 am
Location: Moscow
Contact:

Re: Bomb Money

Postby iPlayer » Sat Sep 17, 2016 11:32 pm

Congratulations on the first published plugin!
Image /id/its_iPlayer
My plugins: Map Cycle • Killstreaker • DeadChat • Infinite Jumping • TripMines • AdPurge • Bot Damage • PLRBots • Entity AntiSpam

Hail, Companion. [...] Hands to yourself, sneak thief. Image
User avatar
Kill
Member
Posts: 88
Joined: Wed Aug 31, 2016 10:05 pm

Re: Bomb Money

Postby Kill » Sat Sep 17, 2016 11:52 pm

Ayuto wrote:Nice! :smile:

Just wanted to let you know that you are missing a comma in line 36. Instead of this

Syntax: Select all

if GAME_NAME not in ('csgo'):

it should look like this:

Syntax: Select all

if GAME_NAME not in ('csgo',):

Thanks, updated :)


iPlayer wrote:Congratulations on the first published plugin!

Thanks for all the help!
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: Bomb Money

Postby satoon101 » Sun Sep 18, 2016 12:37 am

Nice plugin!

A few notes:

  1. ConfigManager supports context management. This means you do not have to call write and execute yourself. Doing so is fine, but thought that you might not know about this. For your plugin, it would look something like:

    Syntax: Select all

    with ConfigManager(info.basename) as plugin_config:
    plugin_config.header = "Bomb Money configuration file"

    bomb_plant_reward = plugin_config.cvar(
    'bomb_plant_reward', 1000,
    'Money to reward the bomb planter.', ConVarFlags.DONTRECORD
    )
    bomb_defuse_reward = plugin_config.cvar(
    'bomb_defuse_reward', 1000,
    'Money to reward the bomb defuser.', ConVarFlags.DONTRECORD
    )

  2. Since your event functions do a lot of the same work, you could actually turn it into one function. Again, they way you have it is fine, just want to make sure you know your options. In this plugin, it would look something like:

    Syntax: Select all

    # ==============================================================================
    # >> Create Config, read it
    # ==============================================================================
    bomb_rewards = {}

    with ConfigManager(info.basename) as plugin_config:
    plugin_config.header = "Bomb Money configuration file"

    bomb_rewards['bomb_exploded'] = plugin_config.cvar(
    'bomb_exploded_reward', 1000,
    'Money to reward the bomb planter.', ConVarFlags.DONTRECORD
    )
    bomb_rewards['bomb_defused'] = plugin_config.cvar(
    'bomb_defused_reward', 1000,
    'Money to reward the bomb defuser.', ConVarFlags.DONTRECORD
    )


    # ==============================================================================
    # >> Translation
    # ==============================================================================
    lang_bombmoney = LangStrings(info.basename)


    @Event('bomb_exploded', 'bomb_defused')
    def _bomb_events(game_event):
    convar = bomb_rewards[game_event.name]
    player = Player.from_userid(game_event['userid'])
    _reward_money = convar.get_int()
    player.cash += _reward_money
    SayText2(lang_bombmoney[convar.name]).send(
    player.index,
    cp=CHAT_PREFIX,
    color=YELLOW_GREEN,
    money=_reward_money
    )

  3. Last, but not least, and the only thing that I think you absolutely should add, is checking that the player exists on the server still. It is certainly possible in the bomb_exploded event that the player that planted the bomb is no longer on the server. This will cause an error when you try to get the player's Player instance. That would be very difficult to happen in bomb_defused, as the event is fired right when the player defuses the bomb.

Also, why the use of DONTRECORD? Just curious as I've never really seen anyone bother to use that flag before.
Image
User avatar
Kill
Member
Posts: 88
Joined: Wed Aug 31, 2016 10:05 pm

Re: Bomb Money

Postby Kill » Sun Sep 18, 2016 11:09 am

satoon101 wrote:Nice plugin!
...


Thanks!
DONTRECORD, I didn't test it, I thought it would not notify any change to the convar, but I was wrong, remove it, not using any convars.

Added player check, and a new convar

Syntax: Select all

// Default Value: 1
// Reward bots too? can be 1 (true) or 0 (false).
bomb_reward_bot 1
User avatar
iPlayer
Developer
Posts: 590
Joined: Sat Nov 14, 2015 8:37 am
Location: Moscow
Contact:

Re: Bomb Money

Postby iPlayer » Wed Sep 21, 2016 11:16 pm

Since you don't have a repo for this, I'll post Russian translations here

Syntax: Select all

[bomb_plant_reward]
en = "{cp} You have been given {color}{money}$\x01 for planting the bomb."
es = "{cp} Has ganado {color}{money}$\x01 por plantar la bomba."
ru = "{cp} Вам были начислены {color}${money}\x01 за установку бомбы."

[bomb_defuse_reward]
en = "{cp} You have been given {color}{money}$\x01 for defusing the bomb."
es = "{cp} Has ganado {color}{money}$\x01 por desactivar la bomba."
ru = "{cp} Вам были начислены {color}${money}\x01 за разминирование бомбы."

As I'm aware, dollar sign is usually followed by the number of cash, not vice versa.
Image /id/its_iPlayer
My plugins: Map Cycle • Killstreaker • DeadChat • Infinite Jumping • TripMines • AdPurge • Bot Damage • PLRBots • Entity AntiSpam

Hail, Companion. [...] Hands to yourself, sneak thief. Image
User avatar
Kill
Member
Posts: 88
Joined: Wed Aug 31, 2016 10:05 pm

Re: Bomb Money

Postby Kill » Sat Sep 24, 2016 7:23 pm

iPlayer wrote:Since you don't have a repo for this, I'll post Russian translations here

Syntax: Select all

[bomb_plant_reward]
en = "{cp} You have been given {color}{money}$\x01 for planting the bomb."
es = "{cp} Has ganado {color}{money}$\x01 por plantar la bomba."
ru = "{cp} Вам были начислены {color}${money}\x01 за установку бомбы."

[bomb_defuse_reward]
en = "{cp} You have been given {color}{money}$\x01 for defusing the bomb."
es = "{cp} Has ganado {color}{money}$\x01 por desactivar la bomba."
ru = "{cp} Вам были начислены {color}${money}\x01 за разминирование бомбы."

As I'm aware, dollar sign is usually followed by the number of cash, not vice versa.


Thanks!!


I've updated the plugin and added few stuff and new cvars,

Code: Select all

// ######################################################################### //
//                       Bomb Money configuration file                       //
// ######################################################################### //

// Default Value: 1000
// Money to reward the bomb planter.
   bomb_plant_reward 2000


// Default Value: 1000
// Money to reward the bomb defuser.
   bomb_defuse_reward 2000


// Default Value: 1
// Reward bots too? can be 1 (true) or 0 (false).
   bomb_reward_bot 0


// Default Value: 1
// Reward the whole team? can be 1 or 0.
   bomb_reward_team 0


// Default Value: 0
// Different reward than others? can be 1 or 0.
   bomb_reward_team_money 0


// Default Value: 1000
// Money to reward the player's team(Counter-Terrorist).
   bomb_team_reward_ct 1000


// Default Value: 1000
// Money to reward the player's team(Terrorist).
   bomb_team_reward_t 1000




Added a GitHub repo also.
MithatGuner
Junior Member
Posts: 7
Joined: Thu Jun 29, 2017 5:32 pm

Re: Bomb Money

Postby MithatGuner » Thu Jul 06, 2017 5:28 pm

Good Job, kill u are awesome.

Return to “Plugin Releases”

Who is online

Users browsing this forum: No registered users and 19 guests