Kod:
#include <amxmodx>
#include <cstrike>
#include <reapi>
enum _: szInfoKeys {
szName, szVersion, szAuthor, szTag
}
new const szInfo[szInfoKeys][] = {
"New Plugin Test", "v0.0.1", "Anonim", "TeamBalance"
}
new gBalanceMoneyQuantity, gBalanceDifferenceNumber, bool: gActivity;
public plugin_init() {
register_plugin(szInfo[szName], szInfo[szVersion], szInfo[szAuthor]);
gBalanceMoneyQuantity = register_cvar("denge_para_miktar", "5000");
gBalanceDifferenceNumber = register_cvar("denge_fark_sayi", "5");
RegisterHookChain(RG_RoundEnd, "RoundEnd", true);
}
public RoundEnd() {
if(gActivity)
return PLUGIN_HANDLED;
new remainingTeam[10], szPlayers[32], szNum, szNo;
new minimumNumber = min(get_member_game(m_iNumCTWins), get_member_game(m_iNumTerroristWins));
copy(remainingTeam, charsmax(remainingTeam), minimumNumber == get_member_game(m_iNumCTWins) ?
"CT" : minimumNumber == get_member_game(m_iNumTerroristWins) ? "TERRORIST" : "");
new balanceDifference = get_member_game(m_iNumCTWins) - get_member_game(m_iNumTerroristWins);
balanceDifference = balanceDifference < 0 ? -balanceDifference : balanceDifference;
if(balanceDifference >= get_pcvar_num(gBalanceDifferenceNumber)) {
get_players(szPlayers, szNum, "e", remainingTeam);
for(new i = 0; i < szNum; i++) {
szNo = szPlayers[i];
cs_set_user_money(szNo, cs_get_user_money(szNo) + get_pcvar_num(gBalanceMoneyQuantity));
for(new j = 0; j < 4; j++)
color_chat(szNo, "^1[^3 %s ^1] ^4Takimlarin esitlenmesi icin takiminiza ^1[^3 %i$ ^1] ^4Verildi^1.", szInfo[szTag], get_pcvar_num(gBalanceMoneyQuantity));
}
gActivity = true;
set_task(300.0, "Reset");
}
return PLUGIN_CONTINUE;
}
public Reset() {
gActivity = false;
}
stock color_chat(const id, const input[], any:...) {
new count = 1, players[32];
static msg[191];
vformat(msg, 190, input, 3);
replace_all(msg, 190, "!n", "^x01");
replace_all(msg, 190, "!g", "^x04");
replace_all(msg, 190, "!t", "^x03");
if (id) players[0] = id; else get_players(players, count, "ch");
for (new i = 0; i < count; i++) {
if (is_user_connected(players[i])) {
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i]);
write_byte(players[i]);
write_string(msg);
message_end();
}
}
}