iLLuSioN,Код:
/**
* 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 <amxmisc>
#include <cstrike>
#include <fun>
#include <fakemeta_util>
#define VIP_FLAG ADMIN_LEVEL_H
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)
new Trie:daysForId
new const menuTitle[] = "\yВаш статус \w[\rВип\w]"
new playersDaysLeft[33]
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( "say /vipmenu", "vip_menu" )
register_clcmd( "vipmenu", "vip_menu" )
pRound = register_cvar("amx_vip_give", "2")
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( menuTitle , "show_vipmenu" )
menu_additem( giMenu, "\yCV-47 \w[\rAK47\w]", "1" )
menu_additem( giMenu, "\yMaverick M4a1 Carbine \w[\rM16\w]", "2" )
menu_additem( giMenu, "\yMagnum Sniper Rifle \w[\rAWP\w]", "3" )
menu_additem( giMenu, "\yClarion 5.56 \w[\rFAMAS\w]", "4" )
menu_additem( giMenu, "\yIDF Defender \w[\rGALIL\w]", "5" )
menu_additem( giMenu, "\yKrieg 552 \w[\rSG552\w]", "6" )
menu_additem( giMenu, "\yBullpup \w[\rAUG\w]", "7" )
menu_setprop( giMenu, MPROP_NUMBER_COLOR, "\r" )
menu_setprop( giMenu, MPROP_NEXTNAME, "\yДальше" )
menu_setprop( giMenu, MPROP_BACKNAME, "\yНазад" )
menu_setprop( giMenu, MPROP_EXITNAME, "\yВыход" )
menu_setprop( giMenu, MPROP_EXIT,MEXIT_ALL )
}
public plugin_cfg(){
new configFile[512]
get_configsdir(configFile,511)
add(configFile,511,"/users.ini")
new f = fopen(configFile,"rt")
if(!f)
return
new buf[512],authId[36],less[10]
daysForId = TrieCreate()
while(!feof(f)){
fgets(f,buf,511)
if(!buf[0] || buf[0] == ';')
continue
parse(buf,authId,35,
less,9,
less,9,
less,9,
less,9)
TrieSetCell(daysForId,authId,str_to_num(less))
}
fclose(f)
}
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 client_authorized(id){
new name[32]
get_user_name(id,name,31)
if(!TrieGetCell(daysForId,name,playersDaysLeft[id]))
playersDaysLeft[id] = -1
}
public vip_menu(id) {
if( !is_user_alive(id) )
return PLUGIN_HANDLED
if( !( get_user_flags(id) & VIP_FLAG ) ) {
ChatColor( id, "^4[^3ProStrike^4] ^3У вас не достаточно прав для использования данной команды." )
return PLUGIN_HANDLED
}
if( gbDisableArmory ) {
ChatColor( id, "^4[^3ProStrike^4] ^4На текущей карте ^3Вип меню ^4отключено!" )
return PLUGIN_HANDLED
}
if( CheckUsed(id) ) {
ChatColor( id, "^4[^3ProStrike^4] ^3Вип меню ^4доступен^3 1 ^4раз за раунд." )
return PLUGIN_HANDLED
}
new iRound = get_pcvar_num(pRound)
if( giRoundCounter < iRound ) {
ChatColor( id, "^4[^3ProStrike^4] ^3Вип меню ^4доступен со ^3%d ^4раунда!", iRound )
return PLUGIN_HANDLED
}
if(playersDaysLeft[id] != -1){
new fmtMenuTitle[256]
formatex(fmtMenuTitle,255,"%s^n\yОсталось \w[\r%d\w] \yдней",
menuTitle,playersDaysLeft[id])
menu_setprop( giMenu, MPROP_TITLE, fmtMenuTitle)
}else
menu_setprop( giMenu, MPROP_TITLE, menuTitle)
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_ak47" )
cs_set_user_bpammo( id , CSW_AK47, 90 )
}
case 2: {
give_item( id, "weapon_m4a1" )
cs_set_user_bpammo( id , CSW_M4A1, 90 )
}
case 3: {
give_item( id, "weapon_awp" )
cs_set_user_bpammo( id , CSW_AWP, 30 )
}
case 4: {
give_item( id, "weapon_famas" )
cs_set_user_bpammo( id , CSW_FAMAS, 90 )
}
case 5: {
give_item( id, "weapon_galil" )
cs_set_user_bpammo( id, CSW_GALIL, 90 )
}
case 6: {
give_item( id, "weapon_sg552" )
cs_set_user_bpammo( id, CSW_SG552, 90 )
}
case 7: {
give_item( id, "weapon_AUG" )
cs_set_user_bpammo( id, CSW_AUG, 90 )
}
}
SetUsed(id)
return PLUGIN_HANDLED
}
public Event_NewRound() {
giRoundCounter++
giIsUsed = 0 // reset uses
}
public Event_NewGame() {
giRoundCounter = 0
}
public ResetHUD(id) {
if( gbDisableArmory )
return
if( giRoundCounter < 1 )
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()
}
}