- Description
This plugin is like CSGO: When you disconnect/suicide, it'll give a compensation with X value (changed by a cvar) to a random enemy player.
- Cvars
compensation_enable 1/0 - Turn on/off this plugin
compensation_first_money <ammount> - The first chance for the money you got.
compensation_second_money <ammount> - The second chance for the money you got.
- Change logs
Spoiler
10-31-2016 | v0.1
1. First release
11-01-2016 | v0.2
1. Some useless loops and formats changed.
11-07-2016 | v0.3
1. Changed the format for make all cvars ( Just optimization )
2. Added another ammount bonus : 600 ( controlled by cvar ). I watched csgo and see that have an chance for players got +600 too, so I added another cvar and a random chance between 0 and 1 for give 300 or 600 money.
3. Added an different message for the compensate player and your team.
11-23-2016 | v0.3
1. Random chance
* The random chance for the compensate player was 0 and 1. But i seen
on csgo that this chance is more hard than mine was.
Now the random chances is 0 and 5. The value 4, 3, 2, 1 and 0 will be 300, and the
value 5 will be 600.
2. A message for dead/disconnect player's team
* Before this update, the team of player dead/disconnect not got message of
their teammate that died in/disconnected from the server. So, i added a message.
11-23-2016 | v0.4
1. MultiLanguage
* Added now more languages to the plugin
public GiveCompensation( iDeadPlayer ) { //This should be placed on top of Event_DeathMsg and client_disconnect(). This would result in only 1 native call //if it was disabled instead of 2 (disconnect) to 4 (deathmsg) the way you have it now. if ( !get_pcvar_num( g_pPluginEnable ) ) return PLUGIN_HANDLED
new iPlayers[ 32 ] , iNumPlayers , iRandom , iMoneyBonus new szCompensateName[ 32 ] , szDeadName[ 32 ] , iCompensatePlayer
//Better off passing the opposite team in get_players(). It will save you multiple cs_get_user_team() native calls. //In addition, you can eliminate other condition checking (see below). get_players( iPlayers , iNumPlayers , "h" )
//This is not needed since it was my assumption that the money was for iDeadPlayers teammates. This is why //it checks for > 1 since there must be a player on his team besides himself. This can be changed to > 0. if ( iNumPlayers > 1 ) { //This loop is not needed since random() will always get a compensate player. Previously, I thought it was to //compensate teammates so it needed to check randoms until it found one that was != dead player. for ( new i = 0 ; i < iNumPlayers ; i++ ) { //With get_players() using opposite team, you can set the player id directly here: iCompensate = ... iRandom = iPlayers[ random( iNumPlayers ) ]
//With get_players() using opposite team, you do not need to check if random != dead player and you do //not need any team checking. if ( ( iRandom != iDeadPlayer ) && ( cs_get_user_team( iRandom ) != cs_get_user_team( iDeadPlayer ) ) ) { if ( HaveAnTeam( iRandom ) ) { iCompensatePlayer = iRandom break } } }
for ( new i = 0 ; i < iNumPlayers ; i++ ) { //With get_players() using opposite team, you do not need any team checking. if ( ( iPlayers[ i ] != iCompensatePlayer ) && ( cs_get_user_team( iRandom ) == cs_get_user_team ( iPlayers[ i ] ) ) ) { client_print_color( iPlayers[ i ] , GREY , "%s Your teammate %s was awarded^x04 +$%d^x01 compensation for the suicide of %s" , szPrefix , szCompensateName , iMoneyBonus , szDeadName ) } } } return PLUGIN_CONTINUE }
Spoiler
PHP Code:
public client_disconnect(id) { if ( get_pcvar_num( g_pPluginEnable ) && HaveAnTeam( id ) ) { GiveCompensation( id ) } }
public Event_DeathMsg() { if ( get_pcvar_num( g_pPluginEnable ) ) { new iKiller = read_data( 1 ) new iVictim = read_data( 2 )
for ( new i = 0 ; i < iNumPlayers ; i++ ) { if ( iPlayers[ i ] != iCompensatePlayer ) { client_print_color( iPlayers[ i ] , GREY , "%s Your teammate %s was awarded^x04 +$%d^x01 compensation for the suicide of %s" , szPrefix , szCompensateName , iMoneyBonus , szDeadName ) } } } }
1. Changed the format for make all cvars ( Just optimization )
2. Added another ammount bonus : 600 ( controlled by cvar ). I watched csgo and see that have an chance for players got +600 too, so I added another cvar and a random chance between 0 and 1 for give 300 or 600 money.
3. Added an different message for the compensate player and your team.
1. Changed the format for make all cvars ( Just optimization )
2. Added another ammount bonus : 600 ( controlled by cvar ). I watched csgo and see that have an chance for players got +600 too, so I added another cvar and a random chance between 0 and 1 for give 300 or 600 money.
3. Added an different message for the compensate player and your team.
Include only chatcolor.inc if amxx is not 1.8.3, with #ifdef directive.
Will avoid my work to remove it and compile on my amxx 1.8.3 for example
Like csgo, an enemy will receive the bonus every disconnect. But i dont recommend it for public server, this plugin is good for pug servers. But if you guys want him for public server, who is me for be against?