Page 1 of 1

Bomb Money

Posted: Sat Sep 17, 2016 10:59 pm
by Kill
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

Re: Bomb Money

Posted: Sat Sep 17, 2016 11:14 pm
by Ayuto
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',):

Re: Bomb Money

Posted: Sat Sep 17, 2016 11:32 pm
by iPlayer
Congratulations on the first published plugin!

Re: Bomb Money

Posted: Sat Sep 17, 2016 11:52 pm
by Kill
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!

Re: Bomb Money

Posted: Sun Sep 18, 2016 12:37 am
by satoon101
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.

Re: Bomb Money

Posted: Sun Sep 18, 2016 11:09 am
by Kill
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

Re: Bomb Money

Posted: Wed Sep 21, 2016 11:16 pm
by iPlayer
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.

Re: Bomb Money

Posted: Sat Sep 24, 2016 7:23 pm
by Kill
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.

Re: Bomb Money

Posted: Thu Jul 06, 2017 5:28 pm
by MithatGuner
Good Job, kill u are awesome.