#include < amxmodx >
#include < amxmisc >
#include < fun >
#include < fakemeta >
#include < cstrike >
#include < hamsandwich >
#pragma semicolon 1
#define VERSION "0.0.1"
#define Max_Players 32
#define OFFSET_PRIMARYWEAPON 116
#define OFFSET_C4_SLOT 372
#define Weapon_Menu_Name "Fegyver Csomagok"
#define Next_Button "Következő"
#define Back_Button "Vissza"
#define Exit_Button "Kilépés"
#define Money_Hud ( 1 << 5 )
new g_iWPCT;
new g_iWPTE;
new pCvarMaxCTWps;
new pCvarMaxTEWps;
new pCvarWPBlock;
new pCvarFlash;
new pCvarHe;
new pCvarSmoke;
new pCvarKevlar;
new pCvarDefuser;
new pCvarPrefix;
new pCvarMoney;
new pCvarBlockBuy;
new pCvarUnAmmo;
new const g_szMessages [ ] [ ] =
{
"",
"Csapatonként csak két ember AWP-zhet!",
"^3%s^1 WP^4 csak^1 4v4-től használható!",
"A vásárlás letĂltva!",
"Te már választottál fegyvert!"
};
new const g_szWeaponMenuNames [ ] [ ] = {
"M4A1 Csomag",
"AK47 Csomag",
"AWP Csomag",
"M249 Csomag",
"AUG Csomag",
"Famas Csomag",
"Galil Csomag",
"MP5 Csomag",
"XM1014 Csomag",
"M3 Csomag",
"Scout Csomag"
};
new const g_szWeaponsName [ ] [ ] = {
"weapon_m4a1",
"weapon_ak47",
"weapon_awp",
"weapon_m249",
"weapon_aug",
"weapon_famas",
"weapon_galil",
"weapon_mp5navy",
"weapon_xm1014",
"weapon_m3",
"weapon_scout"
};
new const g_szPistolName [ ] = "weapon_deagle";
const DoNotReload = ( ( 1 << CSW_HEGRENADE ) | ( 1 << CSW_SMOKEGRENADE ) | ( 1 << CSW_FLASHBANG ) | ( 1 << CSW_KNIFE ) | ( 1 << CSW_C4 ) );
new const maxAmmo[ 31 ] = {
0,
52,
0,
90,
1,
32,
1,
100,
90,
1,
120,
100,
100,
90,
90,
90,
100,
120,
30,
120,
200,
32,
90,
120,
90,
2,
35,
90,
90,
0,
100
};
new g_szBuyCommands[ ][ ] =
{
"usp", "glock", "deagle", "p228", "elites", "fn57", "m3", "xm1014", "mp5", "tmp", "p90", "mac10", "ump45", "ak47",
"galil", "famas", "sg552", "m4a1", "aug", "scout", "awp", "g3sg1", "sg550", "m249", "vest", "vesthelm", "flash", "hegren",
"sgren", "defuser", "nvgs", "shield", "primammo", "secammo", "km45", "9x19mm", "nighthawk", "228compact", "12gauge",
"autoshotgun", "smg", "mp", "c90", "cv47", "defender", "clarion", "krieg552", "bullpup", "magnum", "d3au1", "krieg550",
"buyammo1", "buyammo2"
};
new const g_szMenuCommands[ ] [ ] =
{
"fegyo",
"say fegyo",
"say_team fegyo",
"fegyver",
"say fegyver",
"say_team fegyver",
"say /fegyo",
"say_team /fegyo",
"say /fegyver",
"say_team /fegyver"
};
new g_szChatPrefix[ 64 ];
new g_msgHideWeapon;
new g_bHasWeapon[ Max_Players ];
public plugin_init ( ) {
register_plugin( "Advanced Weapon Menu", VERSION, "#YouCantStopMe" );
RegisterHam( Ham_Spawn, "player", "func_OpenWeaponMenu", 1 );
pCvarMaxCTWps = register_cvar( "awm_max_ct_awp", "2" ); // Ct-nél 2 AWP-s lehet.
pCvarMaxTEWps = register_cvar( "awm_max_te_awp", "2" ); // Terroristáknál 2 AWP-s lehet.
pCvarWPBlock = register_cvar( "awm_allow_wp_player", "4" ); // Ha mindkét csapatban van 4-4 játékos akkor engedi az AWP-t
pCvarFlash = register_cvar( "awm_give_flash", "2" ); // Itt tudod beállítani ,hogy adjon-e füst gránátot. ( 0 = Nem ad ) Alap: 2 Flash gránát
pCvarHe = register_cvar( "awm_give_he", "1" ); // Itt tudod beállítani ,hogy adjon-e füst gránátot. ( 0 = Nem ad ) Alap: 1 Robanó gránát
pCvarSmoke = register_cvar( "awm_give_smoke", "0" ); // Itt tudod beállítani ,hogy adjon-e füst gránátot. ( 0 = Nem ad )
pCvarKevlar = register_cvar( "awm_give_kevlar", "2" ); // Itt tudod beállítani ,hogy adjon-e kevlárt. ( 0 = Nem Ad ) Alap: 2 ( Kevlár + Sisak )
pCvarDefuser = register_cvar( "awm_give_defuser", "1" ); // Itt tudod beállítani ,hogy adjon-e defusert. ( 0 = Nem Ad )
pCvarUnAmmo = register_cvar( "awm_unlimited_ammo", "1" ); // Itt tudod beállítani ,hogy elfoggyon-e a tár vagy ne. Alap: 1 ( Tehát nem fogy el a tár )
pCvarBlockBuy = register_cvar( "awm_block_buy", "1" ); // Itt tudod beállítani ,hogy tiltsa-e a vásárlást vagy ne. Alap 1 ( Tehát tiltva van ) ( 0 = Nincs tiltva )
pCvarMoney = register_cvar( "awm_set_money", "0" ); // Itt tudod beállítani ,hogy mennyi pénze legyen a játékosoknak. ( 0 = Nincs , eltűnik a hudról is ) Alap: 0
pCvarPrefix = register_cvar( "awm_prefix", "[golden]" ); // Itt tudod beállítani, hogy mi legyen a Fegyvermenü prefix-je.
g_msgHideWeapon = get_user_msgid( "HideWeapon" );
for( new i = 0; i < sizeof( g_szBuyCommands ); i++ )
register_clcmd( g_szBuyCommands[ i ], "cmd_BlockBuy" );
for( new i = 0; i < sizeof( g_szMenuCommands ); i++ )
register_clcmd( g_szMenuCommands[ i ], "cmd_ShowWeaponMenu" );
register_event( "ResetHUD", "onResetHUD", "b" );
register_event( "CurWeapon", "eCurWeapon", "be", "1=1" );
register_message( g_msgHideWeapon, "msgHideWeapon" );
register_logevent( "eRoundEnd", 2, "1=Round_End" );
}
public client_connect( iClient ) {
g_bHasWeapon[ iClient ] = false;
}
public client_disconnect( iClient ) {
g_bHasWeapon[ iClient ] = false;
}
public cmd_ShowWeaponMenu( iClient ) {
switch( g_bHasWeapon[ iClient ] ) {
case true:
{
get_pcvar_string( pCvarPrefix, g_szChatPrefix, charsmax( g_szChatPrefix ) );
ColorChat( iClient, "^3%s %s" , g_szChatPrefix, g_szMessages[ 4 ] );
return PLUGIN_HANDLED;
}
case false: func_OpenWeaponMenu( iClient );
}
return PLUGIN_HANDLED;
}
public cmd_BlockBuy( iClient ) {
if( !get_pcvar_num( pCvarBlockBuy ) )
return PLUGIN_CONTINUE;
get_pcvar_string( pCvarPrefix, g_szChatPrefix, charsmax( g_szChatPrefix ) );
ColorChat( iClient, "^3%s %s" , g_szChatPrefix, g_szMessages[ 3 ] );
return PLUGIN_HANDLED;
}
public eCurWeapon( iClient ) {
if( get_pcvar_num( pCvarUnAmmo ) ) {
if( is_user_alive( iClient ) ) {
new weapon = read_data( 2 );
if( !( DoNotReload & ( 1 << weapon ) ) ) {
cs_set_user_bpammo( iClient, weapon, maxAmmo[ weapon ] );
}
}
}
}
public onResetHUD( iClient ) {
if( !get_pcvar_num( pCvarMoney ) ) {
message_begin( MSG_ONE, g_msgHideWeapon, _, iClient );
write_byte( Money_Hud );
message_end( );
}
}
public msgHideWeapon( ) {
if( !get_pcvar_num( pCvarMoney ) ) {
set_msg_arg_int( 1, ARG_BYTE, get_msg_arg_int( 1 ) | Money_Hud );
}
}
public eRoundEnd ( ) {
g_iWPCT = 0;
g_iWPTE = 0;
}
public func_OpenWeaponMenu ( iClient ) {
if( !is_user_alive( iClient ) )
return;
cs_set_user_money( iClient, get_pcvar_num( pCvarMoney ) );
get_pcvar_string( pCvarPrefix, g_szChatPrefix, charsmax( g_szChatPrefix ) );
g_bHasWeapon[ iClient ] = false;
new szMenuTitle[ 121 ];
new szMenuItem[ 121 ];
format( szMenuTitle, charsmax( szMenuTitle ), "\r%s^n\w%s", g_szChatPrefix, Weapon_Menu_Name );
StripUserWeapons( iClient );
new menu = menu_create( szMenuTitle, "func_OpenWeaponMenu_handler" );
for( new i = 0; i < sizeof( g_szWeaponMenuNames ); i++ ) {
if( i != 2 ) {
format( szMenuItem, charsmax( szMenuItem ), "\w%s", g_szWeaponMenuNames[ i ] );
}
else {
switch( get_user_team( iClient ) )
{
case 1: format( szMenuItem, charsmax( szMenuItem ), "\w%s \y[Első %d embernek]", g_szWeaponMenuNames[ i ], get_pcvar_num( pCvarMaxTEWps ) );
case 2: format( szMenuItem, charsmax( szMenuItem ), "\w%s \y[Első %d embernek]", g_szWeaponMenuNames[ i ], get_pcvar_num( pCvarMaxCTWps ) );
default: continue;
}
}
menu_additem( menu, szMenuItem, _, 0 );
}
menu_setprop( menu, MPROP_EXIT, MEXIT_ALL );
menu_setprop( menu, MPROP_BACKNAME, Back_Button );
menu_setprop( menu, MPROP_NEXTNAME, Next_Button );
menu_setprop( menu, MPROP_EXITNAME, Exit_Button );
menu_display( iClient, menu );
}
public func_OpenWeaponMenu_handler( iClient, iMenu, iItem ) {
if( iItem == MENU_EXIT ) {
menu_destroy( iMenu );
return PLUGIN_HANDLED;
}
new data[ 6 ], szName[ 64 ];
new access, callback;
menu_item_getinfo( iMenu, iItem, access, data, charsmax( data ), szName, charsmax( szName ), callback );
get_pcvar_string( pCvarPrefix, g_szChatPrefix, charsmax( g_szChatPrefix ) );
if( iItem != 2 ) {
give_item( iClient, g_szWeaponsName[ iItem ] );
give_item( iClient, g_szPistolName );
ColorChat( iClient, "^3%s^1 ^4%s^1 csomagot választottad!", g_szChatPrefix ,g_szWeaponMenuNames[ iItem ] );
}
else {
new iTeams[ CsTeams ];
GetPlayerCount( iTeams );
if( iTeams[ CS_TEAM_T ] < get_pcvar_num( pCvarWPBlock )
|| iTeams[ CS_TEAM_CT ] < get_pcvar_num( pCvarWPBlock ) ) {
ColorChat( iClient, g_szMessages[ 2 ], g_szChatPrefix );
func_OpenWeaponMenu( iClient );
return PLUGIN_HANDLED;
}
new CsTeams:userTeam = cs_get_user_team( iClient );
if( userTeam == CS_TEAM_CT ) {
if( g_iWPCT < get_pcvar_num( pCvarMaxCTWps ) ) {
give_item( iClient, g_szWeaponsName[ iItem ] );
give_item( iClient, g_szPistolName );
ColorChat( iClient, "^3%s^1 ^4%s^1 csomagot választottad!", g_szChatPrefix, g_szWeaponMenuNames[ iItem ] );
g_iWPCT++;
}
else {
client_print( iClient, print_center, g_szMessages[ 1 ] );
func_OpenWeaponMenu ( iClient );
return PLUGIN_HANDLED;
}
}
if( userTeam == CS_TEAM_T ) {
if( g_iWPTE < get_pcvar_num( pCvarMaxTEWps ) ) {
give_item( iClient, g_szWeaponsName[ iItem ] );
give_item( iClient, g_szPistolName );
ColorChat( iClient, "^3%s^1 ^4%s^1 csomagot választottad!", g_szChatPrefix, g_szWeaponMenuNames[ iItem ] );
g_iWPTE++;
}
else {
client_print( iClient, print_center, g_szMessages[ 1 ] );
func_OpenWeaponMenu( iClient );
return PLUGIN_HANDLED;
}
}
}
give_item( iClient, "weapon_knife" );
give_player_stuff( iClient );
menu_destroy( iMenu );
return PLUGIN_HANDLED;
}
GetPlayerCount( iTeamPlayers[ CsTeams ] ) {
new iPlayers[ 32 ] , iPlayerCount;
get_players( iPlayers , iPlayerCount );
for ( new i = 0 ; i < iPlayerCount ; i++ )
iTeamPlayers[ cs_get_user_team( iPlayers[ i ] ) ]++;
}
stock give_player_stuff( iClient ) {
if( get_pcvar_num( pCvarFlash ) ) {
give_item( iClient, "weapon_flashbang" );
cs_set_user_bpammo( iClient, CSW_FLASHBANG, get_pcvar_num( pCvarFlash ) );
}
if( get_pcvar_num( pCvarHe ) ) {
give_item( iClient, "weapon_hegrenade" );
cs_set_user_bpammo( iClient, CSW_HEGRENADE, get_pcvar_num( pCvarHe ) );
}
if( get_pcvar_num( pCvarSmoke ) ) {
give_item( iClient, "weapon_smokegrenade" );
cs_set_user_bpammo( iClient, CSW_SMOKEGRENADE, get_pcvar_num( pCvarSmoke ) );
}
if( get_pcvar_num( pCvarKevlar ) ) {
switch( get_pcvar_num( pCvarKevlar ) ) {
case 1: give_item( iClient, "item_kevlar" );
case 2: give_item( iClient, "item_assaultsuit" );
default: return PLUGIN_CONTINUE;
}
}
if( get_pcvar_num( pCvarDefuser ) ) {
give_item( iClient, "item_thighpack" );
}
if( !get_pcvar_num( pCvarUnAmmo ) ) {
new weapons[ 32 ];
new weaponsnum;
get_user_weapons( iClient, weapons, weaponsnum );
for( new i = 0; i < weaponsnum; i++ )
if( is_user_alive( iClient ) )
if( maxAmmo[ weapons[ i ] ] > 0 )
cs_set_user_bpammo( iClient, weapons[ i ], maxAmmo[ weapons[ i ] ] );
}
g_bHasWeapon[ iClient ] = true;
return PLUGIN_CONTINUE;
}
//Stolen from CSDM Weapon Menu
stock StripUserWeapons( iClient ) {
new iC4Ent = get_pdata_cbase( iClient, OFFSET_C4_SLOT );
if( iC4Ent > 0 ) {
set_pdata_cbase( iClient, OFFSET_C4_SLOT, FM_NULLENT );
}
strip_user_weapons( iClient );
set_pdata_int( iClient, OFFSET_PRIMARYWEAPON, 0 );
if( iC4Ent > 0 ) {
set_pev( iClient, pev_weapons, pev( iClient, pev_weapons ) | ( 1 << CSW_C4 ) );
set_pdata_cbase( iClient, OFFSET_C4_SLOT, iC4Ent );
cs_set_user_bpammo( iClient, CSW_C4, 1 );
cs_set_user_plant( iClient, 1 );
}
return PLUGIN_HANDLED;
}
stock ColorChat( iClient, const input[], any:...)
{
new count = 1, players[ 32 ];
static msg[ 191 ];
vformat( msg, 190, input, 3 );
replace_all( msg, 190, "^x01" , "^1");
replace_all( msg, 190, "^x03" , "^3");
replace_all( msg, 190, "^x04" , "^4");
if ( iClient ) players[ 0 ] = iClient; 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( );
}
}
}
}
stock print_color(const id, const input[], any:...)
{
new count = 1, players[32]
static msg[191]
vformat(msg, 190, input, 3)
replace_all(msg, 190, "!g", "^4")
replace_all(msg, 190, "!y", "^1")
replace_all(msg, 190, "!t", "^3")
replace_all(msg, 190, "á", "á")
replace_all(msg, 190, "é", "Ă©")
replace_all(msg, 190, "í", "Ă")
replace_all(msg, 190, "ó", "Ăł")
replace_all(msg, 190, "ö", "ö")
replace_all(msg, 190, "ő", "Ĺ‘")
replace_all(msg, 190, "ú", "Ăş")
replace_all(msg, 190, "ü", "ĂĽ")
replace_all(msg, 190, "ű", "ű")
replace_all(msg, 190, "Á", "Ă")
replace_all(msg, 190, "É", "É")
replace_all(msg, 190, "Í", "ĂŤ")
replace_all(msg, 190, "Ó", "Ă“")
replace_all(msg, 190, "Ö", "Ă–")
replace_all(msg, 190, "Ő", "Ĺ")
replace_all(msg, 190, "Ú", "Ăš")
replace_all(msg, 190, "Ü", "Ăś")
replace_all(msg, 190, "Ű", "Ĺ°")
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()
}
}
}
return PLUGIN_HANDLED
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1038\\ f0\\ fs16 \n\\ par }
*/