Here's an adjusted version. I also added some cvars so you can easily modify the prefix, health and armor values. Once again, untested.
PHP Code:
#include <amxmodx>
#include <fun>
#include <cstrike>
#pragma semicolon 1
#define pluginName "RandomPlayerBenefits"
#define pluginVersion "1.0.0"
#define pluginAuthor "LadderGoat"
#define taskID 20874
new messagePrefix;
new terroristHealth;
new terroristArmor;
new counterTerroristHealth;
new counterTerroristArmor;
public plugin_init()
{
register_plugin(pluginName, pluginVersion, pluginAuthor);
register_logevent("roundStart", 2, "1=Round_Start");
register_logevent("roundEnd", 2, "1=Round_End");
messagePrefix = register_cvar("rpb_prefix", "AMXx");
terroristHealth = register_cvar("rpb_thealth", "200");
terroristArmor = register_cvar("rpb_tarmor", "100");
counterTerroristHealth = register_cvar("rpb_cthealth", "250");
counterTerroristArmor = register_cvar("rpb_ctarmor", "150");
}
public roundStart()
{
if(task_exists(taskID))
remove_task(taskID);
set_task(60.0, "randomPlayerSelection" ,taskID);
}
public roundEnd()
{
if(task_exists(taskID))
remove_task(taskID);
}
public randomPlayerSelection()
{
new tPlayers[MAX_PLAYERS], tPlayerCount, ctPlayers[MAX_PLAYERS], ctPlayerCount;
new playerName[MAX_NAME_LENGTH];
new teamSelector = random(1);
new chatPrefix[9]; // 10 characters for a prefix should be more than enough.
get_players(tPlayers, tPlayerCount, "ae", "TERRORIST");
get_players(ctPlayers, ctPlayerCount, "ae", "CT");
get_pcvar_string(messagePrefix, chatPrefix, charsmax(chatPrefix));
if(teamSelector == 0 && tPlayerCount)
{
new tHealth = get_pcvar_num(terroristHealth);
new tArmor = get_pcvar_num(terroristArmor);
new randomTerrorist = tPlayers[random(tPlayerCount)];
set_user_health(randomTerrorist, get_user_health(randomTerrorist) + 200);
set_user_armor(randomTerrorist, get_user_armor(randomTerrorist) + 100);
get_user_name(randomTerrorist, playerName, charsmax(playerName));
client_print_color(0, print_team_red, "^4[%s]^3 %s^1 was randomly picked and received an extra %i health and %i armor.", chatPrefix, playerName, tHealth, tArmor);
}
else if(teamSelector == 1 && ctPlayerCount)
{
new ctHealth = get_pcvar_num(counterTerroristHealth);
new ctArmor = get_pcvar_num(counterTerroristArmor);
new randomCt = ctPlayers[random(ctPlayerCount)];
set_user_health(randomCt, get_user_health(randomCt) + ctHealth);
set_user_armor(randomCt, get_user_armor(randomCt) + ctArmor);
get_user_name(randomCt, playerName, charsmax(playerName));
client_print_color(0, print_team_blue, "^4[%s]^3 %s^1 was randomly picked and received an extra %i health and %i armor.", chatPrefix, playerName, ctHealth, ctArmor);
}
}
__________________