/**
* Last update:
* 2/1/2014
*
* Changes are:
* - VIP tag is assigned for VIPs on every map
* - VIP autoequipment and VIP armory doesn't work on awp_*, 35hp_* and aim_* maps
* - VIP autoequipment and VIP armory also doesn't work for the 1st round
* - added reset for round counter after Game Commencing / Game Restart
* - fixes and optimizations
*/
#include <amxmodx>
#include <cstrike>
#include <fun>
#include <fakemeta_util>
#define VIP_FLAG ADMIN_LEVEL_D // flag 'p'
const PRIMARY_WEAPONS_BIT_SUM = (1<<CSW_SCOUT)|(1<<CSW_XM1014)|(1<<CSW_MAC10)|(1<<CSW_AUG)|(1<<CSW_UMP45)|(1<<CSW_SG550)|(1<<CSW_GALIL)|(1<<CSW_FAMAS)|(1<<CSW_AWP)|(1<<
CSW_MP5NAVY)|(1<<CSW_M249)|(1<<CSW_M3)|(1<<CSW_M4A1)|(1<<CSW_TMP)|(1<<CSW_G3SG1)|(1<<CSW_SG552)|(1<<CSW_AK47)|(1<<CSW_P90)
new giRoundCounter, pRound, giMenu
new bool:gbDisableArmory // whether VIP autoequipment and VIP armory are disabled for that map
new bool:gbBombMap // whether there is bomb objective on the map
new giIsUsed // whether player has used VIP menu in the current round
// macro; %1 - variable being modified, %2 - player id
#define CheckUsed(%1) ( giIsUsed & ( 1 << (%1-1) ) )
#define SetUsed(%1) ( giIsUsed |= ( 1 << (%1-1) ) )
#define VIP_TAG (1<<2)
public plugin_init() {
register_plugin( "Vip_weapon", "1.60", "7eVen / Safety1st" )
register_event( "ResetHUD", "ResetHUD", "be" )
register_event( "HLTV", "Event_NewRound", "a", "1=0", "2=0" )
register_event( "TextMsg", "Event_NewGame", "a", "2=#Game_will_restart_in", "2=#Game_Commencing" )
register_message( get_user_msgid( "ScoreAttrib" ), "msgScoreAttrib" )
register_clcmd( "vipmenu", "vip_menu" )
register_clcmd( "say /vipmenu", "vip_menu" )
register_clcmd( "say /adminka", "adminka" )
register_clcmd( "say /vip","vipka" )
pRound = register_cvar("amx_vip_give", "3")
if( engfunc( EngFunc_FindEntityByString, -1, "classname", "func_bomb_target" ) )
gbBombMap = true
else if( engfunc( EngFunc_FindEntityByString, -1, "classname", "info_bomb_target" ) )
gbBombMap = true
new szMap[32]
get_mapname( szMap, charsmax(szMap) )
if( containi( szMap , "awp_" ) != -1 || containi( szMap , "35hp_" ) != -1 || containi( szMap , "aim_" ) != -1 )
gbDisableArmory = true
// build menu
giMenu = menu_create( "\r Оружейка \w[\y V.I.P \w]", "show_vipmenu" )
menu_additem( giMenu, "\wВзять \r[\y Famas \r]\r", "1" )
menu_additem( giMenu, "\wВзять \r[\y M4A1 \r]\r", "2" )
menu_additem( giMenu, "\wВзять \r[\y AK47 \r]\r", "3" )
menu_additem( giMenu, "\wВзять \r[\y AWP \r]\r", "4" )
menu_setprop( giMenu, MPROP_NUMBER_COLOR, "\y" )
menu_setprop( giMenu, MPROP_NEXTNAME, "Дальше" )
menu_setprop( giMenu, MPROP_BACKNAME, "Назад" )
menu_setprop( giMenu, MPROP_EXITNAME, "Выход" )
menu_setprop( giMenu, MPROP_EXIT,MEXIT_ALL )
}
drop_weapon(id) {
static weapons[32], i, num, weaponid, wname[32]
num = 0
get_user_weapons( id, weapons, num )
for( i = 0; i < num; i++ ) {
weaponid = weapons[i]
if( ( (1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM ) ) {
get_weaponname( weaponid, wname, 31 )
engclient_cmd( id, "drop", wname )
}
}
}
public vip_menu(id) {
if( !is_user_alive(id) )
return PLUGIN_HANDLED
if( !( get_user_flags(id) & VIP_FLAG ) ) {
ChatColor( id, "^1[ ^4V.I.P^1 ] Только для ^4[V.I.P]" )
return PLUGIN_HANDLED
}
if( gbDisableArmory ) {
ChatColor( id, "^1[ ^4V.I.P^1 ] На текущей карте оружейка отключена!" )
return PLUGIN_HANDLED
}
if( CheckUsed(id) ) {
ChatColor( id, "^1[ ^4V.I.P^1 ] Вы уже использовали. Подождите..." )
return PLUGIN_HANDLED
}
new iRound = get_pcvar_num(pRound)
if( giRoundCounter < iRound ) {
ChatColor( id, "^1[ ^4V.I.P^1 ] Доступно с %d раунда!", iRound )
return PLUGIN_HANDLED
}
menu_display( id, giMenu )
return PLUGIN_HANDLED
}
public show_vipmenu( id, giMenu, item ) {
if( item == MENU_EXIT || !is_user_alive(id) )
return PLUGIN_HANDLED
drop_weapon(id)
switch( ++item ) {
case 1: {
give_item( id, "weapon_famas" )
cs_set_user_bpammo( id , CSW_FAMAS, 90 )
}
case 2: {
give_item( id, "weapon_m4a1" )
cs_set_user_bpammo( id , CSW_M4A1, 90 )
}
case 3: {
give_item( id, "weapon_ak47" )
cs_set_user_bpammo( id , CSW_AK47, 90 )
}
case 4: {
give_item( id, "weapon_awp" )
cs_set_user_bpammo( id , CSW_AWP, 30 )
}
}
SetUsed(id)
return PLUGIN_HANDLED
}
public Event_NewRound() {
giRoundCounter++
giIsUsed = 0 // reset uses
}
public Event_NewGame() {
giRoundCounter = 0
}
public adminka(id) {
show_motd( id, "adminka.txt", "Покупка - Админки!" )
}
public vipka(id) {
show_motd( id, "vip.txt", "Покупка - V.I.P" )
}
public ResetHUD(id) {
if( gbDisableArmory )
return
if( giRoundCounter < 2 )
return
if( get_user_flags(id) & VIP_FLAG )
set_task( 0.5, "EquipVIP", id )
}
public EquipVIP(id) {
if( is_user_alive(id) ) {
cs_set_user_armor( id, 100, CsArmorType:CS_ARMOR_VESTHELM )
if( cs_get_user_team(id) == CS_TEAM_CT && gbBombMap && !cs_get_user_defuse(id) )
cs_set_user_defuse( id, .defusekit = 1 )
static const iPistols[] = { CSW_P228, CSW_ELITE, CSW_FIVESEVEN, CSW_USP, CSW_GLOCK18 }
for( new i = 0; i < 5; i++ ) {
if( fm_strip_user_gun( id, iPistols[i] ) )
break
}
give_item( id, "weapon_hegrenade" )
give_item( id, "weapon_flashbang" )
give_item( id, "weapon_flashbang" )
give_item( id, "weapon_smokegrenade" )
give_item( id, "weapon_deagle")
give_item( id, "ammo_50ae" )
give_item( id, "ammo_50ae" )
give_item( id, "ammo_50ae" )
give_item( id, "ammo_50ae" )
give_item( id, "ammo_50ae" )
}
}
public msgScoreAttrib(const MsgId, const MsgType, const MsgDest) { //xpaw's code
if ( get_user_flags(get_msg_arg_int(1)) & VIP_FLAG && !get_msg_arg_int(2) )
set_msg_arg_int( 2, ARG_BYTE, VIP_TAG )
}
ChatColor(const id, const input[], any:...) {
new count = 1, players[32], iPlayer
static msg[192], iMsgSayText
vformat(msg, 191, input, 3)
if ( !iMsgSayText )
iMsgSayText = get_user_msgid("SayText")
if (id)
players[0] = id
else
get_players(players, count, "ch")
for( new i = 0; i < count; i++ ) {
iPlayer = players[i]
message_begin(MSG_ONE_UNRELIABLE, iMsgSayText, _, iPlayer)
write_byte(iPlayer)
write_string(msg)
message_end()
}
}