Skip to content

Instantly share code, notes, and snippets.

@kristiker
Last active August 12, 2018 21:02
Show Gist options
  • Save kristiker/5f04f6bfc667c6d58acc7ecedf6483f4 to your computer and use it in GitHub Desktop.
Save kristiker/5f04f6bfc667c6d58acc7ecedf6483f4 to your computer and use it in GitHub Desktop.
#include <amxmodx>
#include <cstrike>
#define NAME "Show team's money & primary weapons"
#define VERSION "1.4"
#define AUTHOR "kristi"
//#pragma tabsize 0
#pragma semicolon 1
const CSW_ALL_PRIMARYWEAPONS = ((1 << CSW_AK47)|(1 << CSW_AUG)|(1 << CSW_GALIL)|(1 << CSW_AWP) |
(1 << CSW_M4A1)|(1 << CSW_SCOUT)|(1 << CSW_GALIL)|(1 << CSW_SG550) |
(1 << CSW_SG552)|(1 << CSW_FAMAS)|(1 << CSW_AUG)|(1 << CSW_G3SG1) |
(1 << CSW_M249)|(1 << CSW_M3)|(1 << CSW_MP5NAVY)|(1 << CSW_MAC10) |
(1 << CSW_P90)|(1 << CSW_TMP)|(1 << CSW_UMP45)|(1 << CSW_XM1014) );
const TASK_ShowMoneyWpns = 1337;
new const teams[][] =
{
"TERRORIST",
"CT"
};
new g_HudSyncThing;
new pcvar, pcvar2;
public plugin_init()
{
register_plugin(NAME, VERSION, AUTHOR);
register_event("HLTV", "OnEvent_NewRound", "a", "1=0", "2=0");
register_clcmd("say /money", "OnClcmd_money");
register_clcmd("say_team /money", "OnClcmd_money");
// set to how many seconds do you want to show HUD message
// or set it to 1 to use mp_freezetime value
// 0 disables the plugin
pcvar = register_cvar("amx_showteammoney", "1");
pcvar2 = get_cvar_pointer("mp_freezetime");
g_HudSyncThing = CreateHudSyncObj();
}
public OnClcmd_money(client)
{
if(!get_pcvar_num(pcvar))
return PLUGIN_HANDLED;
client_print(client, print_chat, "Your team's money & weapons.");
show_info_to(client, cs_get_user_team(client));
return PLUGIN_CONTINUE;
}
public OnEvent_NewRound()
{
new value = get_pcvar_num(pcvar);
new freezetimeValue = get_pcvar_num(pcvar2);
remove_task(TASK_ShowMoneyWpns);
if(value)
{
show_info();
set_task(1.0, "show_info", TASK_ShowMoneyWpns, .flags = "a", .repeat = (value = 1) ? freezetimeValue : value);
}
}
public show_info()
{
show_info_to(.Team = CS_TEAM_T);
show_info_to(.Team = CS_TEAM_CT);
}
show_info_to(client = 0, CsTeams:Team)
{
new a[32], n, i, id;
get_players(a, n, "e", teams[Team - 1]);
if(n < 2) return;
static message[1024];
new playerName[13], playerPrimWpn[32], playerMoney;
new len, wpnId;
len = formatex(message, charsmax(message), "Your team's money & weapons:^n");
for(i = 0; i < n; i++)
{
id = a[i];
playerName[0] = playerPrimWpn[7] = playerMoney = EOS;
wpnId = get_primary_weapon(id);
if(wpnId)
{
get_weaponname(wpnId, playerPrimWpn, charsmax(playerPrimWpn));
strtoupper(playerPrimWpn);
}
get_user_name(id, playerName, 12);
playerMoney = cs_get_user_money(id);
len += formatex(message[len], charsmax(message) - len, "%s: $%d - %s^n", playerName, playerMoney, playerPrimWpn[7]);
}
if(!client)
{
set_hudmessage(10, 150, 11, 0.05, 0.35, 0, 0.02, 1.1, 0.1, 0.2, 2);
for(i = 0; i < n; i++)
{
ShowSyncHudMsg(a[i], g_HudSyncThing, message);
}
}
else
{
set_hudmessage(10, 150, 11, 0.05, 0.35, 0, 0.02, 5.0, 0.1, 0.2, 2);
ShowSyncHudMsg(client, g_HudSyncThing, message);
}
}
get_primary_weapon(id)
{
new weapons[32], weaponsNum, weapon;
get_user_weapons(id, weapons, weaponsNum);
for(new i; i < weaponsNum; i++)
{
weapon = weapons[i];
if((1 << weapon) & CSW_ALL_PRIMARYWEAPONS)
{
return weapon;
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment