Здравствуйте подскажите как сделать авто открытие вип меню в начале каждого раунда
Вложения
-
11.6 KB Просмотры: 23
public CBasePlayer__Spawn_Post( id ) {
if( !is_user_alive( id ) || !(get_user_flags(id) & get_admin_flag())) {
return HAM_HANDLED;
}
set_task(0.2,"taskSpawn",id);
message_begin( MSG_ALL, g_iMSG_ScoreAttrib );
write_byte( id );
write_byte( 4 );
message_end( );
+ GoldVIp(id);
return HAM_IGNORED;
}
public NewRound() {
gRound++;
+ static maxplayers
+ if( !maxplayers )
+ {
+ maxplayers = get_maxplayers()
+ }
- for(new id=1;id<=get_maxplayers();id++) {
+ for(new id = 1; id <= maxplayers; id++) {
weaponBlock[id][0] = 0;
weaponBlock[id][1] = 0;
+ if(gRound >= 2)
+ {
+ GoldVIp(id);
+ }
}
}
public CBasePlayer__Spawn_Post( id ) {
if( !is_user_alive( id ) || !(get_user_flags(id) & get_admin_flag())) {
return HAM_HANDLED;
}
set_task(0.2,"taskSpawn",id);
message_begin( MSG_ALL, g_iMSG_ScoreAttrib );
write_byte( id );
write_byte( 4 );
message_end( );
if(gRound >= 1)
GoldVIp(id);
return HAM_IGNORED;
}
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <fakemeta>
#include <engine>
#include <fun>
#include <cstrike>
#include <reapi>
#define PLUGIN "GoldMenu"
#define VERSION "1.1"
#define AUTHOR "Sokrat"
const MIN_ROUND = 1 // После какого раунда будет доступ к меню
const ACCESS_FLAG = ADMIN_LEVEL_H // Флаг доступа
//Для проверки слотов.
#define PRIMARY_WEAPONS ((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))
#define SECONDARY_WEAPONS ((1<<CSW_P228) | (1<<CSW_ELITE) | (1<<CSW_FIVESEVEN) | (1<<CSW_USP) | (1<<CSW_GLOCK18) | (1<<CSW_DEAGLE))
#define EV_INT_WEAPONKEY EV_INT_impulse
const MENU_LENGTH = 512;
new CHATTAG[] = "^3[^4VIP^3]";
//Для работы меню выбора оружия.
enum _:STRWEAPON {
WEAPON_RBLOCK,
WEAPON_COST,
WEAP_PRIMARY,
WEAP_ID,
WEAP_CSW,
WEAP_TEXT[14],
WEAP_NAME[20],
WEAP_CLIP,
WEAP_AMMO,
Float:WEAP_DAMAGE,
WEAP_OLDMODELS[64],
WEAP_V[64],
WEAP_P[64],
WEAP_W[64]
}
new gArrWeapon[][STRWEAPON] = {
//Золотое
{ 2,5000,1, 1228,CSW_AK47, "ak47" ,"weapon_ak47" , 30,90, 1.5 ,"models/w_ak47.mdl" ,"models/goldsweaps/v_ak47.mdl" ,"models/goldsweaps/p_ak47.mdl" ,"models/goldsweaps/w_ak47.mdl" },
{ 2,5000,1, 1222,CSW_M4A1, "m4a1" ,"weapon_m4a1" , 30,90, 1.5 ,"models/w_m4a1.mdl" ,"models/goldsweaps/v_m4a1.mdl" ,"models/goldsweaps/p_m4a1.mdl" ,"models/goldsweaps/w_m4a1.mdl" },
{ 0,1500,0, 1226,CSW_DEAGLE,"deagle","weapon_deagle", 7,35 , 1.0 ,"models/w_deagle.mdl" ,"models/v_deagle.mdl" ,"models/p_deagle.mdl" ,"models/w_deagle.mdl" }
}
new g_has_weapon[sizeof gArrWeapon][33]; //Для записи у кого есть данное оружие, на случай модификации по другим параметрам что бы упростить установку модели.
const m_iKevlar=112;
//Блокировка VIP меню на этих картах
new gMapArr[][] = {
"$2000$",
"1hp",
"1hp_2",
"20hp",
"2pro_awp",
"35hp-_-",
"35hp_2",
"35hp_2_winter",
"aim_ak-47",
"awp4one",
"awp_india",
"awp_india2"
}
new bool:gBlock = false;
new weaponBlock[33][2];
new g_iMSG_ScoreAttrib;
public plugin_precache() { //Кешируем звуки.
//Кешируем все модели.
for(new weap=0;weap<sizeof(gArrWeapon);weap++) {
precache_model(gArrWeapon[weap][WEAP_V]);
precache_model(gArrWeapon[weap][WEAP_P]);
precache_model(gArrWeapon[weap][WEAP_W]);
}
}
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR);
new MapName[32]
get_mapname(MapName,31)
for(new i=0;i<sizeof(gMapArr);i++) {
if(equali(MapName,gMapArr[i])) {
gBlock = true;
}
}
register_forward(FM_SetModel, "fw_SetModel");
for(new weap=0;weap<sizeof(gArrWeapon);weap++) {
RegisterHam(Ham_Item_Deploy, gArrWeapon[weap][WEAP_NAME], "Item_Deploy_Post", 1);
RegisterHam(Ham_Item_AddToPlayer, gArrWeapon[weap][WEAP_NAME], "fw_AddToPlayer")
}
RegisterHam(Ham_TakeDamage,"player","TakeDamage",0)
register_menu("MenuId", 1023, "MenuFunc");
register_event("HLTV", "NewRound", "a", "1=0", "2=0")
RegisterHam( Ham_Spawn, "player", "CBasePlayer__Spawn_Post", .Post = true );
g_iMSG_ScoreAttrib = get_user_msgid( "ScoreAttrib" );
register_clcmd("vipmenu","GoldVIp"); //Команда вызова меню.
}
public NewRound() {
for (new id = 1; id <= MaxClients; id++) {
weaponBlock[id][0] = 0;
weaponBlock[id][1] = 0;
}
}
enum _:TOTAL_TEAMS {//Команда игрока.
TEAM_NULL,
TEAM_T,
TEAM_CT,
TEAM_SPEC
};
stock Player_GetTeam(id) { //Проверяем команду игрока.
return (pev_valid(id) != 2) ? 0 : get_pdata_int(id, 114,5);
}
public client_putinserver(id) {
for(new i=0;i<sizeof(gArrWeapon);i++) {
g_has_weapon[i][id] = false;
}
weaponBlock[id][0] = 0;
weaponBlock[id][1] = 0;
}
public GoldVIp(id) {
static menu[512], len;
len = 0;
if(gBlock) {
client_print_color(id, 0, "%s ^3На этой карте меню не работает.", CHATTAG);
return PLUGIN_HANDLED;
}
if(~get_user_flags(id) & ACCESS_FLAG) {
client_print_color(id, 0, "%s ^3Меню доступно только VIP.", CHATTAG);
return PLUGIN_HANDLED;
}
if(!bIsAvailable()) {
client_print_color(id, 0, "%s ^3Меню доступно только со 2 раунда.", CHATTAG);
return PLUGIN_HANDLED;
}
len = formatex(menu[len], charsmax(menu) - len, "\d[\rVIP меню\d]^n^n");
len += formatex(menu[len], charsmax(menu) - len, "\r1. \yЗолотой\d[\rAk47\d] \w- \yВзять^n");
len += formatex(menu[len], charsmax(menu) - len, "\r2. \yЗолотая \d[\rM4A1\d] \w- \yВзять^n");
len += formatex(menu[len], charsmax(menu) - len, "^n\r0. \d[\yЗакрыть\d]" );
new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2
show_menu(id, keys, menu, -1, "MenuId");
return PLUGIN_HANDLED;
}
public MenuFunc(id,key) {
if(key == 9)
return PLUGIN_HANDLED;
if(~get_user_flags(id) & ACCESS_FLAG) {
client_print_color(id, 0, "%s ^3Меню доступно только VIP.", CHATTAG);
return PLUGIN_HANDLED;
}
if(!is_user_alive(id)) {
client_print_color(id, 0, "%s ^3Вы должны быть живы что бы взять оружие.", CHATTAG);
return PLUGIN_HANDLED;
}
if (weaponBlock[id][key]) {
client_print_color(id, 0, "%s ^3Вы уже брали это оружие в этом раунде.", CHATTAG);
return PLUGIN_HANDLED;
}
weaponBlock[id][key] = 1;
if(gArrWeapon[key][WEAP_PRIMARY] > 0) drop_primary(id);
else drop_secondary(id);
g_has_weapon[key][id] = true;
fm_give_item(id,key);
return PLUGIN_HANDLED;
}
public TakeDamage(victim, inflictor, attacker, Float:damage){ //Нанесение урона.
if(!is_user_connected(attacker) || victim == attacker || !victim)
return;
new iWeaponUsed = get_user_weapon( attacker ,_,_)
for(new iweap = 0;iweap<sizeof(gArrWeapon);iweap++) {
if(iWeaponUsed == gArrWeapon[iweap][WEAP_CSW]) {
if(g_has_weapon[iweap][attacker]) {
SetHamParamFloat(4, damage * gArrWeapon[iweap][WEAP_DAMAGE])
break;
}
}
}
}
public fw_AddToPlayer(ent, id) { //Ловим косание с оружием.
if(!is_user_alive(id))
return HAM_IGNORED;
new weapon = cs_get_weapon_id(ent);
for(new iweap = 0;iweap<sizeof(gArrWeapon);iweap++) {
if(weapon == gArrWeapon[iweap][WEAP_CSW]) {
if(entity_get_int(ent, EV_INT_WEAPONKEY) == gArrWeapon[iweap][WEAP_ID]) {
g_has_weapon[iweap][id] = true;
entity_set_int(ent, EV_INT_WEAPONKEY, 0);
}
}
}
return HAM_IGNORED;
}
stock drop_primary(id) {
new weapons[ 32 ], num;
get_user_weapons( id, weapons, num );
for( new i = 0; i < num; i++ ) {
if( PRIMARY_WEAPONS & (1<<weapons[ i ]) ) {
static wname[ 32 ];
get_weaponname( weapons[ i ], wname, sizeof wname - 1 );
engclient_cmd( id, "drop", wname );
}
}
}
stock drop_secondary(id) {
new weapons[ 32 ], num;
get_user_weapons( id, weapons, num );
for( new i = 0; i < num; i++ ) {
if( SECONDARY_WEAPONS & (1<<weapons[ i ]) ) {
static wname[ 32 ];
get_weaponname( weapons[ i ], wname, sizeof wname - 1 );
engclient_cmd( id, "drop", wname );
}
}
}
stock fm_give_item(index, num) {
new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, gArrWeapon[num][WEAP_NAME]))
if (!pev_valid(ent))return 0;
new Float:origin[3];
pev(index, pev_origin, origin);
set_pev(ent, pev_origin, origin);
set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN);
dllfunc(DLLFunc_Spawn, ent);
new save = pev(ent, pev_solid);
dllfunc(DLLFunc_Touch, ent, index);
new wEnt = get_weapon_ent(index, gArrWeapon[num][WEAP_CSW]);
if(pev_valid(wEnt)) {
cs_set_weapon_ammo(wEnt, gArrWeapon[num][WEAP_CLIP])
cs_set_user_bpammo (index, gArrWeapon[num][WEAP_CSW], gArrWeapon[num][WEAP_AMMO])
}
if(pev(ent, pev_solid) != save)return ent;
engfunc(EngFunc_RemoveEntity, ent);
return -1;
}
stock get_weapon_ent(id,wpnid=0,wpnName[]="") {
static newName[32]
if(wpnid) get_weaponname(wpnid,newName,31)
else formatex(newName,31,"%s",wpnName)
if(!equal(newName,"weapon_",7))
format(newName,31,"weapon_%s",newName)
new ent
while((ent = engfunc(EngFunc_FindEntityByString,ent,"classname",newName)) && pev(ent,pev_owner) != id) {}
return ent
}
public fw_SetModel(entity, model[]) {
if(!is_valid_ent(entity))
return FMRES_IGNORED;
static szClassName[33];
entity_get_string(entity, EV_SZ_classname, szClassName, charsmax(szClassName));
if(!equal(szClassName, "weaponbox"))
return FMRES_IGNORED;
static iOwner;
iOwner = entity_get_edict(entity, EV_ENT_owner);
static iweaponID;
for(new iweap = 0;iweap<sizeof(gArrWeapon);iweap++) {
if(equal(model, gArrWeapon[iweap][WEAP_OLDMODELS])) {
iweaponID = find_ent_by_owner(-1, gArrWeapon[iweap][WEAP_NAME], entity);
if(!is_valid_ent(iweaponID))
return FMRES_IGNORED;
if(g_has_weapon[iweap][iOwner]) {
g_has_weapon[iweap][iOwner] = false;
entity_set_int(iweaponID, EV_INT_WEAPONKEY, gArrWeapon[iweap][WEAP_ID]);
entity_set_int(entity, EV_INT_WEAPONKEY, gArrWeapon[iweap][WEAP_ID]);
entity_set_model(entity, gArrWeapon[iweap][WEAP_W]);
return FMRES_SUPERCEDE;
}
}
}
return FMRES_IGNORED;
}
public Item_Deploy_Post(ent) {
const XO_WEAPON = 4
const m_pPlayer = 41
new id = get_pdata_cbase( ent, m_pPlayer, XO_WEAPON );
replace_weapon_models(id);
}
replace_weapon_models(id) {
new weapon = get_pdata_int(get_pdata_cbase(id, 373, 5), 43, 4)
for(new iweap = 0;iweap<sizeof(gArrWeapon);iweap++) {
if(weapon == gArrWeapon[iweap][WEAP_CSW]) {
if(g_has_weapon[iweap][id]) {
set_pev(id, pev_viewmodel2, gArrWeapon[iweap][WEAP_V]);
set_pev(id, pev_weaponmodel2, gArrWeapon[iweap][WEAP_P]);
}
}
}
}
public CBasePlayer__Spawn_Post( id ) {
if(!is_user_alive(id) || ~get_user_flags(id) & ACCESS_FLAG) {
return HAM_HANDLED;
}
set_task(0.2,"taskSpawn",id);
if(bIsAvailable())
GoldVIp(id)
message_begin( MSG_ALL, g_iMSG_ScoreAttrib );
write_byte( id );
write_byte( 4 );
message_end( );
return HAM_IGNORED;
}
public taskSpawn(id) {
if(is_user_alive(id)) {
if(!gBlock) {
drop_secondary(id);
g_has_weapon[2][id] = true;
fm_give_item(id,2);
rg_give_item(id, "weapon_hegrenade", GT_APPEND);
rg_give_item(id, "weapon_flashbang", GT_APPEND);
rg_give_item(id, "weapon_flashbang", GT_APPEND);
rg_give_item(id, "weapon_smokegrenade", GT_APPEND);
rg_set_user_armor(id, 100, ARMOR_VESTHELM);
}
}
}
stock bool:bIsAvailable() return (get_member_game(m_iTotalRoundsPlayed) >= MIN_ROUND)