|
Senior Member
Join Date: Jun 2006
Location: Staples Center, Los Ange
|

08-25-2008
, 20:48
Hide Menu option not working
|
#1
|
I have a plugin that is similar to CSDM Equip menu. It is a class system that fits the theme of pRED's BF2 Rank Mod.
For the most part, it works. However, I got a very annoying problem. Like the CSDM Equip menu, the user i given three options, New Weapons, Previous Weapons and Previous weapons + Hide menu. For the plugin I have, the first two options work fine. However, the third fuction doesn't hide your menu or give you you're prvious set automaically, you must press the option again to get the set of weapons.
There rae a bunch of other little bugs in here too. Don't pay much attention to them; my main concern is the hide menu.
Code:
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <fakemeta>
#include <cstrike>
#include <csx>
#include <xs>
//#pragma dynamic 65536
stock const PLUGIN_NAME[] = "Bf2 DeathMatch";
stock const PLUGIN_VERSION[] = "0.09";
stock const PLUGIN_AUTHOR[] = "SAMURAI";
stock const gUserClasses[][] =
{
"Rifleman",
"Sniper",
"Infantry",
"Combat",
"Heavy Support",
"Special Forces",
"Tactical Ops",
"Assault",
"Medic",
"Demolition Squad",
"Recon",
"Engineer",
"Anti-Tank"
}
//stock const gHostageSoundsAndModels[][] =
//{
// "models/scientist.mdl",
// "hostage/hos1.wav",
// "hostage/hos2.wav",
// "hostage/hos3.wav",
// "hostage/hos4.wav",
// "hostage/hos5.wav"
//}
// task ids
#define TASK_RESPAWN 300
#define TASK_CHECK_RESPAWN 400
#define TASK_CHECK_RESPAWN2 1100
#define TASK_REMOVE_PROTECTION 700
// clases
#define CLASS_NOTHING 0
#define CLASS_RIFLEMAN 4090
#define CLASS_SNIPER 4091
#define CLASS_INFANTRY 4092
#define CLASS_COMBAT 4093
#define CLASS_HEAVYSUPPORT 4094
#define CLASS_SPECIALFORCES 4095
#define CLASS_TACTICALOPS 4096
#define CLASS_ASSAULT 4097
#define CLASS_MEDIC 4098
#define CLASS_DEMOLITIONSQUAD 4099
#define CLASS_RECON 5000
#define CLASS_ENGINEER 5001
#define CLASS_ANTITANK 5002
new gHasThisClass[33] = CLASS_NOTHING;
new gIsRifleManCT[33] = 0;
new gIsRifleManTE[33] = 0;
new gIsSniperCT[33] = 0;
new gIsSniperTE[33] = 0;
new gIsInfantryCT[33] = 0;
new gIsInfantryTE[33] = 0;
new gIsCombatCT[33] = 0;
new gIsCombatTE[33] = 0;
new gIsHeavySupportCT[33] = 0;
new gIsHeavySupportTE[33] = 0;
new gIsSpecialForcesCT[33] = 0;
new gIsSpecialForcesTE[33] = 0;
new gIsTacticalOpsCT[33] = 0;
new gIsTacticalOpsTE[33] = 0;
new gIsAssaultCT[33] = 0;
new gIsAssaultTE[33] = 0;
new gIsMedicCT[33] = 0;
new gIsMedicTE[33] = 0;
new gIsDemolitionSquadCT[33] = 0;
new gIsDemolitionSquadTE[33] = 0;
new gIsReconCT[33] = 0;
new gIsReconTE[33] = 0;
new gIsEngineerCT[33] = 0;
new gIsEngineerTE[33] = 0;
new gIsAntiTankCT[33] = 0;
new gIsAntiTankTE[33] = 0;
// this shit is used on KeyValue forward, when is removed the hostages
new bool:hostageMade;
// medkit stuff
stock const gMedKitModel[] = "models/w_medkit.mdl";
new const gMeditKitClassName[] = "bf2_amxx_medkit";
new gCreatedMedKitsNum[33] = 0;
// sandbags stuff
new const gSandbagsClassname[] = "bf2dm_sandbags_amxx";
stock const gSandbagsModel[] = "models/pallet_with_bags.mdl";
new gCreatedSandbagsNum[33] = 0;
// demo squad class count for nades
new gRecivedHeNADE[33] = 0;
// max spawns
#define MAX_SPAWNS 128
// from fakemeta_util
#define fm_find_ent_by_class(%1,%2) engfunc(EngFunc_FindEntityByString, %1, "classname", %2)
// stuff for spawns, files to load spawns;
new spawnCount, sfLineData[81], Float:spawns[MAX_SPAWNS][9], cfgDir[32], csdmSpawnCount;
// PCVARS
new hkit_health_give, bf2dm_rmv_protect, bf2dm_render_color, bf2dm_max_medkits,bf2dm_max_henades,
pmax_rifleman, pmax_sniper, pmax_infantry, pmax_combat, pmax_heavysupport, pmax_specialforces, pmax_tacticalops,
pmax_assault, pmax_medic, pmax_demolitionsquad, pmax_recon, pmax_engineer, pmax_antitank, bf2dm_respawn,
bf2dm_sandbgas_health, max_eng_sandbags,
rifleman_scout_bpammo,rifleman_tmp_bpammo,rifleman_deagle_bpammo,
sniper_awp_bpammo,sniper_fiveseven_bpammo,
infantry_famas_bpammo,infantry_usp_bpammo,
combat_ak47_bpammo, combat_p228_bpammo,
heavysupport_m249_bpammo, heavysupport_elites_bpammo,
specialforces_m3_bpammo, specialforces_tmp_bpammo, specialforces_deagle_bpammo,
tacticalops_xm1014_bpammo, tacticalops_mac10_bpammo, tacticalops_p228_bpammo,
assault_m4a1_bpammo, assault_usp_bpammo,
medic_p90_bpammo, medic_deagle_bpammo,
demosquad_ump45_bpammo, demosquad_usp_bpammo,
recon_mp5_bpammo, recon_fiveseven_bpammo,
engineer_p90_bpammo, engineer_deagle_bpammo,
antitank_deagle_bpammo;
//antitank_rpg_bpammo;
// stuff for remove dropped weapon on death
new g_entid[33], g_maxents;
// thisone helps to see if user selected to hide menu
new gHasChoosedHideOrNO[33] = 0;
// msg icon and msg SayText lol
new g_msgid_icon, msgSayText;
// make a copy of menu if someone choose previuos class with hide menu
new gCopyOfHideMenu;
// menuz
new PrincipalMenu, menu1, sandbagsMenu;
new gUsedRespawnCommand[33] = 0, gRespawnByTASKinServer[33] =0;
// //
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* AMXMODX PLUGIN */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
public plugin_init()
{
register_plugin(PLUGIN_NAME,PLUGIN_VERSION,PLUGIN_AUTHOR);
// register cvars
bf2dm_register_cvars();
register_forward(FM_Touch,"FORWARD_TOUCH");
register_forward(FM_SetModel,"FORWARD_SET_MODEL");
register_forward(FM_PlayerPreThink,"FORWARD_PLAYER_PRETHINK");
if(get_pcvar_num(bf2dm_respawn))
register_forward(FM_KeyValue, "FORWARD_KEY_VALUE", 1);
if(get_pcvar_num(bf2dm_respawn))
{
// block round time
set_msg_block(get_user_msgid("RoundTime"), BLOCK_SET); // block round time
set_msg_block(get_user_msgid("ClCorpse"), BLOCK_SET);
}
// clcmds
register_clcmd("say class","bring_back_menu",-1);
register_clcmd("say /class","bring_back_menu",-1);
register_clcmd("say_team /class","bring_back_menu",-1);
register_clcmd("say_team class","bring_back_menu",-1);
register_clcmd("say /sandbags","CLCMD_SAY_SANDBAGS",-1);
register_clcmd("say sandbags","CLCMD_SAY_SANDBAGS",-1);
register_clcmd("say_team /sandbags","CLCMD_SAY_SANDBAGS",-1);
register_clcmd("say_team sandbags","CLCMD_SAY_SANDBAGS",-1);
if(get_pcvar_num(bf2dm_respawn))
{
register_clcmd("say respawn","CLIENT_COMMAND_RESPAWN",-1);
register_clcmd("say /respawn","CLIENT_COMMAND_RESPAWN",-1);
register_clcmd("say_team respawn","CLIENT_COMMAND_RESPAWN",-1);
register_clcmd("say_team /respawn","CLIENT_COMMAND_RESPAWN",-1);
}
// events
register_event("HLTV","event_new_round","a","1=0","2=0");
register_event("DeathMsg","event_deathmsg","a");
register_event("CurWeapon","event_curweapon","b","1=1");
if(!get_pcvar_num(bf2dm_respawn))
register_event("ResetHUD","event_reset_hud","b");
if(get_pcvar_num(bf2dm_respawn))
register_message(g_msgid_icon, "message_status_icon");
// block from buy, you don't have time for that
//register_clcmd("buy", "block_user_buy");
//register_clcmd("buyammo1", "block_user_buy");
//register_clcmd("buyammo2", "block_user_buy");
//register_clcmd("buyequip", "block_user_buy");
//register_clcmd("cl_autobuy", "block_user_buy");
//register_clcmd("cl_rebuy", "block_user_buy");
//register_clcmd("cl_setautobuy", "block_user_buy");
//register_clcmd("cl_setrebuy", "block_user_buy");
// FROM HERE SPAWN STUFF
static mapName[32], csdmFile[64];
get_configsdir(cfgDir,31);
get_mapname(mapName,31);
formatex(csdmFile,63,"%s/csdm/%s.spawns.cfg",cfgDir,mapName);
// collect CSDM spawns
if(file_exists(csdmFile))
{
new csdmData[10][6];
new file = fopen(csdmFile,"rt");
while(file && !feof(file))
{
fgets(file,sfLineData,63);
// invalid spawn
if(!sfLineData[0] || str_count(sfLineData,' ') < 2)
continue;
// BREAK IT UP!
parse(sfLineData,csdmData[0],5,csdmData[1],5,csdmData[2],5,csdmData[3],5,csdmData[4],5,csdmData[5],5,csdmData[6],5,csdmData[7],5,csdmData[8],5,csdmData[9],5);
// origin
spawns[spawnCount][0] = floatstr(csdmData[0]);
spawns[spawnCount][1] = floatstr(csdmData[1]);
spawns[spawnCount][2] = floatstr(csdmData[2]);
// angles
spawns[spawnCount][3] = floatstr(csdmData[3]);
spawns[spawnCount][4] = floatstr(csdmData[4]);
spawns[spawnCount][5] = floatstr(csdmData[5]);
// vangles
spawns[spawnCount][6] = floatstr(csdmData[7]);
spawns[spawnCount][7] = floatstr(csdmData[8]);
spawns[spawnCount][8] = floatstr(csdmData[9]);
spawnCount++;
csdmSpawnCount++;
if(spawnCount >= MAX_SPAWNS) break;
}
if(file) fclose(file);
}
else
{
new ent, Float:spawnData[3];
while((ent = fm_find_ent_by_class(ent,"info_player_deathmatch")) != 0)
{
// origin
pev(ent,pev_origin,spawnData);
spawns[spawnCount][0] = spawnData[0];
spawns[spawnCount][1] = spawnData[1];
spawns[spawnCount][2] = spawnData[2];
// angles
pev(ent,pev_angles,spawnData);
spawns[spawnCount][3] = spawnData[0];
spawns[spawnCount][4] = spawnData[1];
spawns[spawnCount][5] = spawnData[2];
// vangles
spawns[spawnCount][6] = spawnData[0];
spawns[spawnCount][7] = spawnData[1];
spawns[spawnCount][8] = spawnData[2];
spawnCount++;
if(spawnCount >= MAX_SPAWNS) break;
}
ent = 0;
while((ent = fm_find_ent_by_class(ent,"info_player_start")) != 0)
{
// origin
pev(ent,pev_origin,spawnData);
spawns[spawnCount][0] = spawnData[0];
spawns[spawnCount][1] = spawnData[1];
spawns[spawnCount][2] = spawnData[2];
// angles
pev(ent,pev_angles,spawnData);
spawns[spawnCount][3] = spawnData[0];
spawns[spawnCount][4] = spawnData[1];
spawns[spawnCount][5] = spawnData[2];
// vangles
spawns[spawnCount][6] = spawnData[0];
spawns[spawnCount][7] = spawnData[1];
spawns[spawnCount][8] = spawnData[2];
spawnCount++;
if(spawnCount >= MAX_SPAWNS) break;
}
}
// get ents :D
g_maxents = global_get(glb_maxEntities);
// messages
g_msgid_icon = get_user_msgid("StatusIcon");
msgSayText = get_user_msgid("SayText");
}
// All Plugin Cvars //
public bf2dm_register_cvars()
{
bf2dm_respawn = register_cvar("bf2dm_respawn","0");
hkit_health_give = register_cvar("bf2dm_healthkit_give","30");
bf2dm_rmv_protect = register_cvar("bf2dm_remove_protect","2");
bf2dm_render_color = register_cvar("bf2dm_rgb_colors","255 0 255");
bf2dm_max_medkits = register_cvar("bf2dm_max_medkits","5");
bf2dm_max_henades = register_cvar("bf2dm_max_dmsquad_nades","5");
max_eng_sandbags = register_cvar("bf2dm_eng_maxsandbags","5");
bf2dm_sandbgas_health = register_cvar("bf2dm_eng_sandbagshp","75");
pmax_rifleman = register_cvar("bf2dm_max_rifleman_team","999");
pmax_sniper = register_cvar("bf2dm_max_sniper_team","999");
pmax_infantry = register_cvar("bf2dm_max_infantry_team","999");
pmax_combat = register_cvar("bf2dm_max_combat_team","999");
pmax_heavysupport = register_cvar("bf2dm_max_heavysupport_team","999");
pmax_specialforces = register_cvar("bf2dm_max_specialforces_team","999");
pmax_tacticalops = register_cvar("bf2dm_max_tacticalops_team","999");
pmax_assault = register_cvar("bf2dm_max_assault_team","999");
pmax_medic = register_cvar("bf2dm_max_medic_team","999");
pmax_demolitionsquad = register_cvar("bf2dm_max_demosquad_team","999");
pmax_recon = register_cvar("bf2dm_max_recon_team","999");
pmax_engineer = register_cvar("bf2dm_max_engineer_team","999");
pmax_antitank = register_cvar("bf2dm_max_antitank_team","999");
rifleman_scout_bpammo = register_cvar("bf2dm_rifleman_scout_bpammo","130");
rifleman_tmp_bpammo = register_cvar("bf2dm_rifleman_tmp_bpammo","180");
rifleman_deagle_bpammo = register_cvar("bf2dm_rifleman_deagle_bpammo","21");
sniper_awp_bpammo = register_cvar("bf2dm_sniper_awp_bpammo","5");
sniper_fiveseven_bpammo = register_cvar("bf2dm_sniper_fiveseven_bpammo","200");
infantry_famas_bpammo = register_cvar("bf2dm_infantry_famas_bpammo","175");
infantry_usp_bpammo = register_cvar("bf2dm_infantry_usp_bpammo","120");
combat_ak47_bpammo = register_cvar("bf2dm_combat_ak47_bpammo","180");
combat_p228_bpammo = register_cvar("bf2dm_combat_p228_bpammo","80");
heavysupport_m249_bpammo = register_cvar("bf2dm_heavysupport_m249_bpammo","254");
heavysupport_elites_bpammo = register_cvar("bf2dm_heavysupport_elites_bpammo","90");
specialforces_m3_bpammo = register_cvar("bf2dm_specialforces_m3_bpammo","40");
specialforces_tmp_bpammo = register_cvar("bf2dm_specialforces_tmp_bpammo","180");
specialforces_deagle_bpammo = register_cvar("bf2dm_specialforces_deagle_bpammo","70");
tacticalops_xm1014_bpammo = register_cvar("bf2dm_tacticalops_xm1014_bpammo","84");
tacticalops_mac10_bpammo = register_cvar("bf2dm_tacticalops_mac10_bpammo","120");
tacticalops_p228_bpammo = register_cvar("bf2dm_tacticalops_p228_bpammo","65");
assault_m4a1_bpammo = register_cvar("bf2dm_assault_m4a1_bpammo","240");
assault_usp_bpammo = register_cvar("bf2dm_assault_usp_bpammo","60");
medic_p90_bpammo = register_cvar("bf2dm_medic_p90_bpammo","250");
medic_deagle_bpammo = register_cvar("bf2dm_medic_deagle_bpammo","101");
demosquad_ump45_bpammo = register_cvar("bf2dm_demosquad_ump45_bpammo","150");
demosquad_usp_bpammo = register_cvar("bf2dm_demosquad_usp_bpammo","600");
recon_mp5_bpammo = register_cvar("bf2dm_recon_mp5_bpammo","240");
recon_fiveseven_bpammo = register_cvar("bf2dm_rcon_fiveseven_bpammo","90");
engineer_p90_bpammo = register_cvar("bf2dm_engineer_p90_bpammo","250");
engineer_deagle_bpammo = register_cvar("bf2dm_engineer_deagle_bpammo","63");
antitank_deagle_bpammo = register_cvar("bf2dm_antitank_deagle_bpammo","70");
//antitank_rpg_bpammo = register_cvar("bf2dm_antitank_rpg_bpammo","10");
}
/** Plugin Precache FORWARD **/
public plugin_precache()
{
// for(new i = 0; i < sizeof gHostageSoundsAndModels; ++i)
// precache_generic(gHostageSoundsAndModels[i]);
precache_model(gMedKitModel); // "models/w_medkit.mdl"
precache_model(gSandbagsModel); // "models/pallet_with_bags.mdl"
// create an "info_map_parameters" entity
new Ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_map_parameters"));
// stop buying on current map
//if(pev_valid(Ent))
//{
// fm_SetKeyValue(Ent, "buying", "3");
// dllfunc(DLLFunc_Spawn, Ent);
//}
}
public plugin_cfg()
{
PrincipalMenu = menu_create("\rBF2 Class Menu:", "PRINCIPAL_MENU_HANDLER");
menu_additem(PrincipalMenu, "\wChoose a New Class", "1", 0);
menu_additem(PrincipalMenu, "\wChoose Previous Class", "2", 0);
menu_additem(PrincipalMenu, "\wChoose Previous Class and Hide Menu", "3", 0);
menu1 = menu_create("\rChoose a New Class:", "CHOOSE_A_NEW_CLASS_HANDLER");
menu_additem(menu1, "\wRifleman", "1", 0);
menu_additem(menu1, "\wSniper", "2", 0);
menu_additem(menu1, "\wInfantry", "3", 0);
menu_additem(menu1, "\wCombat", "4", 0);
menu_additem(menu1, "\wHeavy Support", "5", 0);
menu_additem(menu1, "\wSpecial Forces", "6", 0);
// menu_additem(menu1, "\wTactical Ops", "7", 0);
menu_additem(menu1, "\wAssault", "8", 0);
// menu_additem(menu1, "\wMedic", "9", 0);
// menu_additem(menu1, "\wDemolition Squad", "10", 0);
menu_additem(menu1, "\wGhost", "11", 0);
// menu_additem(menu1, "\wEngineer","12",0);
// menu_additem(menu1, "\wAnti-Tank","13",0);
sandbagsMenu = menu_create("\rSandbags:", "SANDBAGS_MENU_HANDLER");
menu_additem(sandbagsMenu, "\wPlace Sandbags", "1", 0);
menu_additem(sandbagsMenu, "\wRemove Sandbags", "2", 0);
}
// When i called this, the menu is back
public bring_back_menu(id)
{
if(!is_user_connected(id)) return PLUGIN_CONTINUE;
gHasChoosedHideOrNO[id] = 0;
client_print_green(id,"[BF2] You re-enabled BF2 Classes Menu !");
return PLUGIN_CONTINUE;
}
// the Brain of plugin, Principal Menu
public CREATE_THE_MENU(id)
{
menu_display(id, PrincipalMenu, 0);
}
// when is Handled the Principal Menu
public PRINCIPAL_MENU_HANDLER(id,menu,item)
{
if(item == MENU_EXIT)
{
//menu_destroy(menu);
return PLUGIN_HANDLED;
}
static data[10], iName[64], iAccess, callback;
menu_item_getinfo(menu, item, iAccess, data,9, iName, 63, callback);
new key = str_to_num(data);
switch(key)
{
// Choose a New Class
case 1:
{
menu_display(id,menu1,0);
}
// Choose a Previous Class
case 2:
{
if(gHasThisClass[id] == CLASS_RIFLEMAN) make_player_specific_class(id,1,menu);
else if(gHasThisClass[id] == CLASS_SNIPER) make_player_specific_class(id,2,menu);
else if(gHasThisClass[id] == CLASS_INFANTRY) make_player_specific_class(id,3,menu);
else if(gHasThisClass[id] == CLASS_COMBAT) make_player_specific_class(id,4,menu);
else if(gHasThisClass[id] == CLASS_HEAVYSUPPORT) make_player_specific_class(id,5,menu);
else if(gHasThisClass[id] == CLASS_SPECIALFORCES) make_player_specific_class(id,6,menu);
else if(gHasThisClass[id] == CLASS_TACTICALOPS) make_player_specific_class(id,7,menu);
else if(gHasThisClass[id] == CLASS_ASSAULT) make_player_specific_class(id,8,menu);
else if(gHasThisClass[id] == CLASS_MEDIC) make_player_specific_class(id,9,menu);
else if(gHasThisClass[id] == CLASS_DEMOLITIONSQUAD) make_player_specific_class(id,10,menu);
else if(gHasThisClass[id] == CLASS_RECON) make_player_specific_class(id,11,menu);
else if(gHasThisClass[id] == CLASS_ENGINEER) make_player_specific_class(id,12,menu);
else if(gHasThisClass[id] == CLASS_ANTITANK) make_player_specific_class(id,13,menu);
menu_cancel(id);
}
// Choose a Previous Class and Hide Menu
case 3:
{
if(gHasThisClass[id] == CLASS_RIFLEMAN) make_player_specific_class(id,1,menu);
else if(gHasThisClass[id] == CLASS_SNIPER) make_player_specific_class(id,2,menu);
else if(gHasThisClass[id] == CLASS_INFANTRY) make_player_specific_class(id,3,menu);
else if(gHasThisClass[id] == CLASS_COMBAT) make_player_specific_class(id,4,menu);
else if(gHasThisClass[id] == CLASS_HEAVYSUPPORT) make_player_specific_class(id,5,menu);
else if(gHasThisClass[id] == CLASS_SPECIALFORCES) make_player_specific_class(id,6,menu);
else if(gHasThisClass[id] == CLASS_TACTICALOPS) make_player_specific_class(id,7,menu);
else if(gHasThisClass[id] == CLASS_ASSAULT) make_player_specific_class(id,8,menu);
else if(gHasThisClass[id] == CLASS_MEDIC) make_player_specific_class(id,9,menu);
else if(gHasThisClass[id] == CLASS_DEMOLITIONSQUAD) make_player_specific_class(id,10,menu);
else if(gHasThisClass[id] == CLASS_RECON) make_player_specific_class(id,11,menu);
else if(gHasThisClass[id] == CLASS_ENGINEER) make_player_specific_class(id,12,menu);
else if(gHasThisClass[id] == CLASS_ANTITANK) make_player_specific_class(id,13,menu);
gCopyOfHideMenu = menu;
// print to chat msg
client_print_green(id,"[BF2] Type ^"class^" in chat to re-enable BF2 Classes Menu");
gHasChoosedHideOrNO[id] = 2;
menu_cancel(id);
}
}
return PLUGIN_HANDLED;
}
public CHOOSE_A_NEW_CLASS_HANDLER(id,menu,item)
{
if(item == MENU_EXIT)
{
//menu_destroy(menu);
return PLUGIN_HANDLED;
}
static data[64], iName[64], iAccess, callback;
menu_item_getinfo(menu, item, iAccess, data,63, iName, 63, callback);
new key = str_to_num(data);
switch(key)
{
case 1: make_player_specific_class(id,1,menu); // rifleman
case 2: make_player_specific_class(id,2,menu); // sniper
case 3: make_player_specific_class(id,3,menu); // Infantry
case 4: make_player_specific_class(id,4,menu); // Combat
case 5: make_player_specific_class(id,5,menu); // Heavy Support
case 6: make_player_specific_class(id,6,menu); // Special Forces
case 7: make_player_specific_class(id,7,menu); // Tactical Ops
case 8: make_player_specific_class(id,8,menu); // Assault
case 9: make_player_specific_class(id,9,menu); // medic
case 10: make_player_specific_class(id,10,menu); // Demolition Squad
case 11: make_player_specific_class(id,11,menu); // Recon
case 12: make_player_specific_class(id,12,menu); // Engineer
case 13: make_player_specific_class(id,13,menu); // Anti-Tank
}
return PLUGIN_HANDLED;
}
public CLCMD_SAY_SANDBAGS(id)
{
if(!is_user_alive(id))
return PLUGIN_CONTINUE;
if(gHasThisClass[id] != CLASS_ENGINEER)
return PLUGIN_CONTINUE;
menu_display(id,sandbagsMenu,0);
return PLUGIN_CONTINUE;
}
public SANDBAGS_MENU_HANDLER(id,menu,item)
{
if(item == MENU_EXIT)
return 1;
static data[64], iName[64], iAccess, callback;
menu_item_getinfo(menu, item, iAccess, data,63, iName, 63, callback);
new key = str_to_num(data);
switch(key)
{
// place sandbags
case 1:
{
if(gCreatedSandbagsNum[id] >= get_pcvar_num(max_eng_sandbags))
{
client_print_green(id,"[BF2] You can't place more that %d sandbags",get_pcvar_num(max_eng_sandbags));
return 1;
}
bf2dm_place_sandbags(id);
menu_display(id,menu,0);
gCreatedSandbagsNum[id] += 1;
}
// remove sandbags
case 2:
{
bf2dm_remove_sandbags(id);
menu_display(id,menu,0);
}
}
return 1;
}
/*********************************************************************************************/
/* Fakemeta Forward Client Prethink */
/*********************************************************************************************/
public FORWARD_PLAYER_PRETHINK(id)
{
if(!is_user_alive(id)) return FMRES_IGNORED;
if(gHasThisClass[id] != CLASS_MEDIC) return FMRES_IGNORED;
if((pev(id, pev_button) & IN_USE) && !(pev(id, pev_oldbuttons) & IN_USE))
{
if(gCreatedMedKitsNum[id] >= get_pcvar_num(bf2dm_max_medkits))
{
client_print_green(id,"[BF2] You can't place more than %d medkits",get_pcvar_num(bf2dm_max_medkits));
return FMRES_HANDLED;
}
bf2dm_create_medkit(id);
gCreatedMedKitsNum[id] += 1;
}
return FMRES_IGNORED;
}
/*********************************************************************************************/
/* Forward Client Connect */
/*********************************************************************************************/
public client_connect(id)
{
gIsRifleManCT[id] = 0;
gIsRifleManTE[id] = 0;
gIsSniperCT[id] = 0;
gIsSniperTE[id] = 0;
gIsInfantryCT[id] = 0;
gIsInfantryTE[id] = 0;
gIsCombatCT[id] = 0;
gIsCombatTE[id] = 0;
gIsHeavySupportCT[id] = 0;
gIsHeavySupportTE[id] = 0;
gIsSpecialForcesCT[id] = 0;
gIsSpecialForcesTE[id] = 0;
gIsTacticalOpsCT[id] = 0;
gIsTacticalOpsTE[id] = 0;
gIsAssaultCT[id] = 0;
gIsAssaultTE[id] = 0;
gIsMedicCT[id] = 0;
gIsMedicTE[id] = 0;
gIsDemolitionSquadCT[id] = 0;
gIsDemolitionSquadTE[id] = 0;
gIsReconCT[id] = 0;
gIsReconTE[id] = 0;
gIsEngineerCT[id] = 0;
gIsEngineerTE[id] = 0;
gIsAntiTankCT[id] = 0;
gIsAntiTankTE[id] = 0;
gHasThisClass[id] = CLASS_NOTHING;
gHasChoosedHideOrNO[id] = 0;
gRecivedHeNADE[id] = 0;
gUsedRespawnCommand[id] = 0;
gRespawnByTASKinServer[id] = 0;
}
/*********************************************************************************************/
/* Forward Client Disconnect */
/*********************************************************************************************/
public client_disconnect(id)
{
gIsRifleManCT[id] = 0;
gIsRifleManTE[id] = 0;
gIsSniperCT[id] = 0;
gIsSniperTE[id] = 0;
gIsInfantryCT[id] = 0;
gIsInfantryTE[id] = 0;
gIsCombatCT[id] = 0;
gIsCombatTE[id] = 0;
gIsHeavySupportCT[id] = 0;
gIsHeavySupportTE[id] = 0;
gIsSpecialForcesCT[id] = 0;
gIsSpecialForcesTE[id] = 0;
gIsTacticalOpsCT[id] = 0;
gIsTacticalOpsTE[id] = 0;
gIsAssaultCT[id] = 0;
gIsAssaultTE[id] = 0;
gIsMedicCT[id] = 0;
gIsMedicTE[id] = 0;
gIsDemolitionSquadCT[id] = 0;
gIsDemolitionSquadTE[id] = 0;
gIsReconCT[id] = 0;
gIsReconTE[id] = 0;
gIsEngineerCT[id] = 0;
gIsEngineerTE[id] = 0;
gIsAntiTankCT[id] = 0;
gIsAntiTankTE[id] = 0;
gHasThisClass[id] = CLASS_NOTHING;
gHasChoosedHideOrNO[id] = 0;
gRecivedHeNADE[id] = 0;
gUsedRespawnCommand[id] = 0;
gRespawnByTASKinServer[id] = 0;
// remove tasks
remove_task(TASK_RESPAWN+id);
remove_task(TASK_CHECK_RESPAWN+id);
remove_task(TASK_CHECK_RESPAWN2+id);
remove_task(TASK_REMOVE_PROTECTION+id);
}
public message_status_icon(msg_id, msg_dest, id)
{
static icon[8];
get_msg_arg_string(2, "buyzone", 7);
if(equal(icon,"buyzone"))
return PLUGIN_HANDLED;
return PLUGIN_CONTINUE;
}
/*********************************************************************************************/
/* Client Death */
/*********************************************************************************************/
public event_deathmsg()
{
// get Victim
new victim = read_data(2);
if(get_pcvar_num(bf2dm_respawn))
{
// Respawn Victim
set_task(0.1,"begin_respawn", victim);
}
// Remove victim's dropped weapon
set_task(0.1,"remove_dropped_weapon");
}
/*********************************************************************************************/
/* Client Death */
/*********************************************************************************************/
public event_curweapon(id)
{
if(!is_user_alive(id)) return;
if(gHasThisClass[id] != CLASS_DEMOLITIONSQUAD)
return;
if(!user_has_weapon(id,CSW_HEGRENADE))
{
if(gRecivedHeNADE[id] >= get_pcvar_num(bf2dm_max_henades))
return;
fm_give_item(id,"weapon_hegrenade");
gRecivedHeNADE[id] += 1;
}
}
/*********************************************************************************************/
/* Reset HUD Event */
/*********************************************************************************************/
public event_reset_hud(id)
{
// is user connected ?
if(!is_user_connected(id)) return;
// is respawn off ?
if(!get_pcvar_num(bf2dm_respawn))
CREATE_THE_MENU(id);
}
// when a user what to respawn type "respawn" in chat
public CLIENT_COMMAND_RESPAWN(id)
{
if(!is_user_connected(id)) return;
if(is_user_alive(id)) user_silentkill(id);
set_task(0.1,"begin_respawn",id);
gUsedRespawnCommand[id] = 1;
}
public begin_respawn(id)
{
if(!is_user_connected(id))
return;
// now on spectator
new CsTeams:team = cs_get_user_team(id);
if(team == CS_TEAM_UNASSIGNED || team == CS_TEAM_SPECTATOR) return;
// alive, and not in the broken sort of way
if(is_user_alive(id) && !pev(id,pev_iuser1)) return;
set_task(0.1,"respawn",TASK_RESPAWN+id);
}
public respawn(taskid)
{
new id = taskid-TASK_RESPAWN;
if(!is_user_connected(id)) return;
// now on spectator
new CsTeams:team = cs_get_user_team(id);
if(team == CS_TEAM_UNASSIGNED || team == CS_TEAM_SPECTATOR) return;
// alive, and not in the broken sort of way
if(is_user_alive(id) && !pev(id,pev_iuser1)) return;
fm_cs_user_spawn(id);
// make sure they made it
remove_task(TASK_CHECK_RESPAWN+id);
remove_task(TASK_CHECK_RESPAWN2+id);
set_task(0.5,"check_respawn",TASK_CHECK_RESPAWN+id);
set_task(1.5,"check_respawn",TASK_CHECK_RESPAWN2+id);
do_random_spawn(id,1);
engfunc(EngFunc_EmitSound,id,CHAN_ITEM,"items/gunpickup2.wav",VOL_NORM,ATTN_NORM,0,PITCH_NORM);
// reset the medkits count
gCreatedMedKitsNum[id] = 0;
// reset sandbags count
gCreatedSandbagsNum[id] = 0;
// reset Demolition Squad Nades
gRecivedHeNADE[id] = 0;
if(gRespawnByTASKinServer[id] == 1)
{
cs_set_user_deaths(id,cs_get_user_deaths(id) + 1);
gRespawnByTASKinServer[id] = 0;
}
if(gUsedRespawnCommand[id] == 1)
{
cs_set_user_deaths(id,get_user_deaths(id) + 1);
gUsedRespawnCommand[id] = 0;
}
static color[16], sRed[5], sGreen[5], sBlue[5];
get_pcvar_string(bf2dm_render_color, color, 15);
parse(color,sRed,4,sGreen,4,sBlue,4);
// check if choosed to hide menu
if(gHasChoosedHideOrNO[id] == 2)
{
if(gHasThisClass[id] == CLASS_RIFLEMAN) make_player_specific_class(id,1,gCopyOfHideMenu);
else if(gHasThisClass[id] == CLASS_SNIPER) make_player_specific_class(id,2,gCopyOfHideMenu);
else if(gHasThisClass[id] == CLASS_INFANTRY) make_player_specific_class(id,3,gCopyOfHideMenu);
else if(gHasThisClass[id] == CLASS_COMBAT) make_player_specific_class(id,4,gCopyOfHideMenu);
else if(gHasThisClass[id] == CLASS_HEAVYSUPPORT) make_player_specific_class(id,5,gCopyOfHideMenu);
else if(gHasThisClass[id] == CLASS_SPECIALFORCES) make_player_specific_class(id,6,gCopyOfHideMenu);
else if(gHasThisClass[id] == CLASS_TACTICALOPS) make_player_specific_class(id,7,gCopyOfHideMenu);
else if(gHasThisClass[id] == CLASS_ASSAULT) make_player_specific_class(id,8,gCopyOfHideMenu);
else if(gHasThisClass[id] == CLASS_MEDIC) make_player_specific_class(id,9,gCopyOfHideMenu);
else if(gHasThisClass[id] == CLASS_DEMOLITIONSQUAD) make_player_specific_class(id,10,gCopyOfHideMenu);
else if(gHasThisClass[id] == CLASS_RECON) make_player_specific_class(id,11,gCopyOfHideMenu);
else if(gHasThisClass[id] == CLASS_ENGINEER) make_player_specific_class(id,12,gCopyOfHideMenu);
else if(gHasThisClass[id] == CLASS_ANTITANK) make_player_specific_class(id,13,gCopyOfHideMenu);
// make it invincible
set_user_godmode(id,1);
fm_set_user_rendering(id,kRenderFxGlowShell,str_to_num(sRed),str_to_num(sGreen),str_to_num(sBlue),kRenderNormal,1);
set_task(float(get_pcvar_num(bf2dm_rmv_protect)),"remove_spawn_protection",TASK_REMOVE_PROTECTION+id);
// A stupid NOOB : hey SAMURAI, you forgot the menu..
// SAMURAI : no idiot, there is no menu
}
else
{
// Most important, brings up the menu ;)
CREATE_THE_MENU(id);
// make it invincible
set_user_godmode(id,1);
fm_set_user_rendering(id,kRenderFxGlowShell,str_to_num(sRed),str_to_num(sGreen),str_to_num(sBlue),kRenderNormal,1);
set_task(float(get_pcvar_num(bf2dm_rmv_protect)),"remove_spawn_protection",TASK_REMOVE_PROTECTION+id);
}
}
public check_respawn(taskid)
{
new id;
if(taskid > TASK_CHECK_RESPAWN2) id = taskid-TASK_CHECK_RESPAWN2;
else id = taskid-TASK_CHECK_RESPAWN;
if(!is_user_connected(id))
return;
// now on spectator
new CsTeams:team = cs_get_user_team(id);
if(team == CS_TEAM_UNASSIGNED || team == CS_TEAM_SPECTATOR) return;
// didn't respawn properly
if(pev(id,pev_iuser1) || !is_user_alive(id))
{
remove_task(TASK_CHECK_RESPAWN+id);
remove_task(TASK_CHECK_RESPAWN2+id);
respawn(TASK_RESPAWN+id); // respawn them again
}
else
{
// double guarantee
give_essentials(id);
set_task(0.1,"give_essentials",id);
}
}
public give_essentials(id)
{
if(!is_user_alive(id) || pev(id,pev_iuser1)) return;
fm_set_user_suit(id,true,false);
if(!user_has_weapon(id,CSW_KNIFE))
fm_give_item(id,"weapon_knife");
}
public remove_spawn_protection(taskid)
{
new id = taskid - TASK_REMOVE_PROTECTION;
if(is_user_connected(id))
{
fm_set_user_godmode(id,0);
fm_set_user_rendering(id);
}
}
// remove victims dropped weapon
public remove_dropped_weapon()
{
new weapons = -1;
while((weapons = fm_find_ent_by_class(weapons,"weaponbox")))
{
engfunc(EngFunc_RemoveEntity,weapons);
}
}
// here to stop user from buying
//public block_user_buy()
//{
// return PLUGIN_HANDLED;
//}
// block fullupdate
public clcmd_fullupdate()
{
// is respawn on ?
if(get_pcvar_num(bf2dm_respawn))
return PLUGIN_HANDLED;
return PLUGIN_CONTINUE;
}
// Client Putinserver Forward
public client_putinserver(id)
{
set_task(6.0,"task_putinserver",id + 3211123);
}
public task_putinserver(id)
{
id -= 3211123;
if(!is_user_connected(id)) return;
client_print_teamcolor(id,"Type 'class' to bring up the Classes menu",PLUGIN_VERSION);
if(get_pcvar_num(bf2dm_respawn))
{
if(is_user_alive(id)) user_silentkill(id);
gRespawnByTASKinServer[id] = 1;
set_task(0.1,"begin_respawn", id);
}
}
public event_new_round()
{
if(get_pcvar_num(bf2dm_respawn))
{
// call function to place any player at a random origin
set_task(0.1,"randomly_place_everyone");
}
new players[32], inum, i, index;
get_players(players,inum);
for(i = 0; i < inum; i++)
{
index = players[i];
if(!is_user_connected(index)) continue;
gCreatedMedKitsNum[index] = 0;
gCreatedSandbagsNum[index] = 0;
}
}
/*********************************************************************************************/
/* Fakemeta forward KeyValue */
/*********************************************************************************************/
public FORWARD_KEY_VALUE(entId, kvd_id)
{
if(!pev_valid(entId)) return FMRES_IGNORED;
static className[64];
get_kvd(kvd_id, KV_ClassName, className, 63);
if(containi(className, "func_bomb_target") != -1
|| containi(className, "info_bomb_target") != -1
|| containi(className, "hostage_entity") != -1
|| containi(className, "monster_scientist") != -1
|| containi(className, "func_hostage_rescue") != -1
|| containi(className, "info_hostage_rescue") != -1
|| containi(className, "info_vip_start") != -1
|| containi(className, "func_vip_safetyzone") != -1
|| containi(className, "func_escapezone") != -1)
engfunc(EngFunc_RemoveEntity, entId);
if(!hostageMade)
{
hostageMade = true;
new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "hostage_entity"));
engfunc(EngFunc_SetOrigin, ent, Float:{0.0,0.0,-55000.0});
engfunc(EngFunc_SetSize, ent, Float:{-1.0,-1.0,-1.0}, Float:{1.0,1.0,1.0});
dllfunc(DLLFunc_Spawn, ent);
}
return FMRES_HANDLED;
}
/*********************************************************************************************/
/* Fakemeta Forward TOUCH */
/*********************************************************************************************/
public FORWARD_TOUCH(ent,id)
{
if(!is_user_alive(id) || !pev_valid(ent))
return FMRES_IGNORED;
static classname[32];
pev(ent,pev_classname,classname,31);
if(!equal(classname,gMeditKitClassName))
return FMRES_IGNORED;
static Float:healthGive, Float:userHealth, Float:healthSet;
healthGive = float(get_pcvar_num(hkit_health_give));
pev(id,pev_health,userHealth);
healthSet = healthGive + userHealth;
set_pev(id,pev_health,healthSet);
// remove medkit
engfunc(EngFunc_RemoveEntity,ent);
return FMRES_IGNORED;
}
/*********************************************************************************************/
/* Fakemeta Forward Set Model */
/*********************************************************************************************/
public FORWARD_SET_MODEL(entid, model[])
{
if(!pev_valid(entid) || !equal(model,"models/w_weaponbox.mdl",9))
return FMRES_IGNORED;
static id, i;
id = pev(entid,pev_owner);
if (!id || !is_user_connected(id) || is_user_alive(id))
return FMRES_IGNORED;
if(equal(model,"models/w_shield.mdl"))
set_pev(entid,pev_flags,pev(entid,pev_flags) | FL_KILLME);
if (entid != g_entid[id]) return FMRES_IGNORED;
g_entid[id] = 0;
if(equal(model,"models/w_backpack.mdl"))
set_pev(entid,pev_flags,pev(entid,pev_flags) | FL_KILLME);
for (i = 1; i <= g_maxents; ++i)
{
if(pev_valid(i) && entid == pev(i,pev_owner))
{
set_pev(entid,pev_flags,pev(entid,pev_flags) | FL_KILLME);
set_pev(i,pev_flags,pev(entid,pev_flags) | FL_KILLME);
}
}
return FMRES_IGNORED;
}
//******************************** Misc & Support Functions *******************************//
//******************************************************************************************//
// from fakemeta_util
stock fm_strip_user_weapons(index)
{
new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "player_weaponstrip"));
if(!pev_valid(ent)) return 0;
dllfunc(DLLFunc_Spawn, ent);
dllfunc(DLLFunc_Use, ent, index);
engfunc(EngFunc_RemoveEntity, ent);
return 1;
}
// from fakemeta_util
stock fm_give_item(index, const item[])
{
if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10))
return 0;
new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item));
if(!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);
if(pev(ent, pev_solid) != save) return ent;
engfunc(EngFunc_RemoveEntity, ent);
return -1;
}
/* Create a metkit at where is "id" aiming */
public bf2dm_create_medkit(id)
{
new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString,"info_target"));
static Float:fMedkitOrigin[3];
get_user_hitpoint(id,fMedkitOrigin);
if(engfunc(EngFunc_PointContents, fMedkitOrigin) == CONTENTS_SKY)
{
client_print_green(id,"[BF2] You can't place a medkit on the sky !");
return 1;
}
engfunc(EngFunc_SetOrigin, ent, fMedkitOrigin);
if(!ent) return 1;
engfunc(EngFunc_SetModel,ent,gMedKitModel); // "models/w_medkit.mdl"
set_pev(ent,pev_classname,ent,gMeditKitClassName);
dllfunc(DLLFunc_Spawn, ent);
set_pev(ent,pev_solid,SOLID_BBOX);
set_pev(ent,pev_movetype,MOVETYPE_FLY);
set_pev(ent,pev_takedamage,DAMAGE_NO);
engfunc(EngFunc_DropToFloor,ent);
engfunc(EngFunc_SetSize,ent,Float:{-23.160000, -13.660000, -0.050000}, Float:{11.470000,12.780000,6.720000});
return 1;
}
/* Create sandbags at where is "id" aiming */
public bf2dm_place_sandbags(id)
{
new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString,"info_target"));
static Float:fOrigin[3];
get_user_hitpoint(id,fOrigin);
if(engfunc(EngFunc_PointContents, fOrigin) == CONTENTS_SKY)
{
client_print_green(id,"[BF2] You can't place sandbags on the sky !");
return 1;
}
engfunc(EngFunc_SetOrigin, ent, fOrigin);
if(!ent) return 1;
engfunc(EngFunc_SetModel,ent,gSandbagsModel);
set_pev(ent,pev_classname,gSandbagsClassname);
dllfunc(DLLFunc_Spawn,ent);
set_pev(ent,pev_solid,SOLID_BBOX);
set_pev(ent,pev_movetype,MOVETYPE_FLY);
new Float:sandbags_health = get_pcvar_float(bf2dm_sandbgas_health);
switch(sandbags_health)
{
case 0.0 : set_pev(ent,pev_takedamage,DAMAGE_NO);
default :
{
set_pev(ent,pev_health,sandbags_health);
set_pev(ent,pev_takedamage,DAMAGE_YES);
}
}
engfunc(EngFunc_DropToFloor,ent);
engfunc(EngFunc_SetSize,ent,Float:{27.260000, -22.280001, -22.290001}, Float:{27.340000, 26.629999, 29.020000});
return 1;
}
/* If "id" is aiming at sandbags, will be removed */
public bf2dm_remove_sandbags(id)
{
new ent, body, class[32];
get_user_aiming(id, ent, body);
if(pev_valid(ent))
{
pev(ent, pev_classname, class, 31);
if(equal(class, gSandbagsClassname))
engfunc(EngFunc_RemoveEntity,ent);
else client_print_green(id, "[BF2] You are not aiming at sandbags");
}
else client_print_green(id, "[BF2] You are not aiming at a valid entity");
}
// from gungame by xxAlavanchexx
stock str_count(str[],searchchar)
{
new i = 0;
new maxlen = strlen(str);
new count = 0;
for(i=0;i<=maxlen;i++)
{
if(str[i] == searchchar)
count++;
}
return count;
}
// by xxAvalanchexx
public do_random_spawn(id,spawn_random)
{
// not even alive, don't brother
if(!is_user_alive(id) || pev(id,pev_iuser1))
return;
// no spawns???
if(spawnCount <= 0) return;
// no CSDM spawns, mode 2
if(spawn_random == 2 && !csdmSpawnCount)
return;
static Float:vecHolder[3];
new sp_index = random_num(0,spawnCount-1);
// get origin for comparisons
vecHolder[0] = spawns[sp_index][0];
vecHolder[1] = spawns[sp_index][1];
vecHolder[2] = spawns[sp_index][2];
// this one is taken
if(!is_hull_vacant(vecHolder,HULL_HUMAN) && spawnCount > 1)
{
new i;
for(i=sp_index+1;i!=sp_index;i++)
{
// start over when we reach the end
if(i >= spawnCount) i = 0;
vecHolder[0] = spawns[i][0];
vecHolder[1] = spawns[i][1];
vecHolder[2] = spawns[i][2];
// free space! office space!
if(is_hull_vacant(vecHolder,HULL_HUMAN))
{
sp_index = i;
break;
}
}
}
// origin
vecHolder[0] = spawns[sp_index][0];
vecHolder[1] = spawns[sp_index][1];
vecHolder[2] = spawns[sp_index][2];
engfunc(EngFunc_SetOrigin,id,vecHolder);
// angles
vecHolder[0] = spawns[sp_index][3];
vecHolder[1] = spawns[sp_index][4];
vecHolder[2] = spawns[sp_index][5];
set_pev(id,pev_angles,vecHolder);
// vangles
vecHolder[0] = spawns[sp_index][6];
vecHolder[1] = spawns[sp_index][7];
vecHolder[2] = spawns[sp_index][8];
set_pev(id,pev_v_angle,vecHolder);
set_pev(id,pev_fixangle,1);
}
// by xxAvalanchexx
public randomly_place_everyone()
{
new players[32], num, i, CsTeams:team;
get_players(players,num);
new validNum;
for(i=0;i<num;i++)
{
team = cs_get_user_team(players[i]);
if(team == CS_TEAM_T || team == CS_TEAM_CT) validNum++;
}
if(validNum > csdmSpawnCount)
return;
for(i=0;i<num;i++)
{
team = cs_get_user_team(players[i]);
if(team == CS_TEAM_T || team == CS_TEAM_CT)
{
do_random_spawn(players[i],2);
CREATE_THE_MENU(players[i]);
}
}
}
// by VEN
stock bool:is_hull_vacant(const Float:origin[3],hull)
{
new tr = 0;
engfunc(EngFunc_TraceHull,origin,origin,0,hull,0,tr);
if(!get_tr2(tr,TR_StartSolid) && !get_tr2(tr,TR_AllSolid) && get_tr2(tr,TR_InOpen))
return true;
return false;
}
// from fakemeta_util by VEN
stock fm_cs_user_spawn(index)
{
set_pev(index, pev_deadflag, DEAD_RESPAWNABLE);
dllfunc(DLLFunc_Spawn, index);
set_pev(index, pev_iuser1, 0);
return 1;
}
// from fakemeta_util by VEN
#define WEAPON_SUIT 31
stock fm_set_user_suit(index, bool:suit = true, bool:sound = true)
{
new weapons = pev(index, pev_weapons);
if (!suit)
set_pev(index, pev_weapons, weapons & ~(1<<WEAPON_SUIT));
else if (!(weapons & (1<<WEAPON_SUIT)))
{
set_pev(index, pev_weapons, weapons | (1<<WEAPON_SUIT));
if (sound)
emit_sound(index, CHAN_VOICE, "items/tr_kevlar.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
}
}
// from fakemeta_util
stock fm_set_user_rendering(index, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16)
{
return fm_set_rendering(index, fx, r, g, b, render, amount);
}
// from fakemeta_util
stock fm_set_rendering(entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16)
{
new Float:RenderColor[3];
RenderColor[0] = float(r);
RenderColor[1] = float(g);
RenderColor[2] = float(b);
set_pev(entity, pev_renderfx, fx);
set_pev(entity, pev_rendercolor, RenderColor);
set_pev(entity, pev_rendermode, render);
set_pev(entity, pev_renderamt, float(amount));
return 1;
}
// from fakmeta_util
stock fm_set_user_godmode(index, godmode = 0)
{
set_pev(index, pev_takedamage, godmode == 1 ? DAMAGE_NO : DAMAGE_AIM)
return 1
}
/* Print a char message with green color*/
/* by Alka */
stock client_print_green(index, const message[], {Float, Sql, Result,_}:...)
{
new Buffer[512], Buffer2[512];
formatex(Buffer2, sizeof Buffer2 - 1, "^x04%s", message);
vformat(Buffer, sizeof Buffer - 1, Buffer2, 3);
if(!is_user_connected(index))
return;
message_begin(MSG_ONE, msgSayText, _, index);
write_byte(index);
write_string(Buffer);
message_end();
}
/* The same at client_print_green stock but with team colors*/
stock client_print_teamcolor(index, const message[], {Float, Sql, Result,_}:...)
{
new Buffer[512], Buffer2[512];
formatex(Buffer2, sizeof Buffer2 - 1, "^x03%s", message);
vformat(Buffer, sizeof Buffer - 1, Buffer2, 3);
if(!is_user_connected(index))
return;
message_begin(MSG_ONE, msgSayText, _, index);
write_byte(index);
write_string(Buffer);
message_end();
}
stock fm_SetKeyValue(ent, const szKey[], const szValue[])
{
new szClassname[33];
pev(ent, pev_classname, szClassname, sizeof szClassname - 1);
set_kvd(0, KV_ClassName, szClassname);
set_kvd(0, KV_KeyName, szKey);
set_kvd(0, KV_Value, szValue);
set_kvd(0, KV_fHandled, 0);
dllfunc(DLLFunc_KeyValue, ent, 0);
}
stock get_user_hitpoint(id, Float:hOrigin[3])
{
if ( ! is_user_alive( id ))
return 0;
new Float:fOrigin[3], Float:fvAngle[3], Float:fvOffset[3], Float:fvOrigin[3], Float:feOrigin[3];
new Float:fTemp[3];
pev(id, pev_origin, fOrigin);
pev(id, pev_v_angle, fvAngle);
pev(id, pev_view_ofs, fvOffset);
xs_vec_add(fOrigin, fvOffset, fvOrigin);
engfunc(EngFunc_AngleVectors, fvAngle, feOrigin, fTemp, fTemp);
xs_vec_mul_scalar(feOrigin, 9999.9, feOrigin);
xs_vec_add(fvOrigin, feOrigin, feOrigin);
engfunc(EngFunc_TraceLine, fvOrigin, feOrigin, 0, id);
global_get(glb_trace_endpos, hOrigin);
return 1;
}
/* Here is the laboratory where is maked every player who class want */
public make_player_specific_class(id,class, menu)
{
switch(class)
{
// rifleman
case 1:
{
switch(get_user_team(id))
{
case 1:
{
if(gIsRifleManTE[id] >= get_pcvar_num(pmax_rifleman))
{
client_print_green(id,"[BF2] There can only be %d %s on your team!",get_pcvar_num(pmax_rifleman),gUserClasses[0]);
menu_display(id,menu,0);
return 1;
}
fm_strip_user_weapons(id);
if(user_has_weapon(id,CSW_KNIFE))
fm_give_item(id,"weapon_knife");
fm_give_item(id,"weapon_scout");
fm_give_item(id,"weapon_tmp");
fm_give_item(id,"weapon_deagle");
fm_give_item(id,"weapon_hegrenade");
cs_set_user_bpammo(id,CSW_SCOUT,get_pcvar_num(rifleman_scout_bpammo));
cs_set_user_bpammo(id,CSW_TMP,get_pcvar_num(rifleman_tmp_bpammo));
cs_set_user_bpammo(id,CSW_DEAGLE,get_pcvar_num(rifleman_deagle_bpammo));
gHasThisClass[id] = CLASS_RIFLEMAN;
gIsRifleManTE[id] += 1;
}
case 2:
{
if(gIsRifleManTE[id] >= get_pcvar_num(pmax_rifleman))
{
client_print_green(id,"[BF2] There can only be %d %s on your team!",get_pcvar_num(pmax_rifleman),gUserClasses[0]);
menu_display(id,menu,0);
return 1;
}
fm_strip_user_weapons(id);
if(!user_has_weapon(id,CSW_KNIFE))
fm_give_item(id,"weapon_knife");
fm_give_item(id,"weapon_scout");
fm_give_item(id,"weapon_tmp");
fm_give_item(id,"weapon_deagle");
fm_give_item(id,"weapon_hegrenade");
cs_set_user_bpammo(id,CSW_SCOUT,get_pcvar_num(rifleman_scout_bpammo));
cs_set_user_bpammo(id,CSW_TMP,get_pcvar_num(rifleman_tmp_bpammo));
cs_set_user_bpammo(id,CSW_DEAGLE,get_pcvar_num(rifleman_deagle_bpammo));
gHasThisClass[id] = CLASS_RIFLEMAN;
gIsRifleManCT[id] += 1;
}
}
}
// Sniper
case 2:
{
switch(get_user_team(id))
{
case 1:
{
if(gIsSniperTE[id] >= get_pcvar_num(pmax_sniper))
{
client_print_green(id,"[BF2] There can only be %d %s on your team!",get_pcvar_num(pmax_sniper),gUserClasses[1]);
menu_display(id,menu,0);
return 1;
}
fm_strip_user_weapons(id);
if(!user_has_weapon(id,CSW_KNIFE))
fm_give_item(id,"weapon_knife");
fm_give_item(id,"weapon_awp");
fm_give_item(id,"weapon_fiveseven");
fm_give_item(id,"weapon_hegrenade");
cs_set_user_bpammo(id,CSW_AWP,get_pcvar_num(sniper_awp_bpammo));
cs_set_user_bpammo(id,CSW_FIVESEVEN,get_pcvar_num(sniper_fiveseven_bpammo));
gHasThisClass[id] = CLASS_SNIPER;
gIsSniperTE[id] += 1;
}
case 2:
{
if(gIsSniperTE[id] >= get_pcvar_num(pmax_sniper))
{
client_print_green(id,"[BF2] There can only be %d %s on your team!",get_pcvar_num(pmax_sniper),gUserClasses[1]);
menu_display(id,menu,0);
return 1;
}
fm_strip_user_weapons(id);
if(!user_has_weapon(id,CSW_KNIFE))
fm_give_item(id,"weapon_knife");
fm_give_item(id,"weapon_awp");
fm_give_item(id,"weapon_fiveseven");
fm_give_item(id,"weapon_hegrenade");
cs_set_user_bpammo(id,CSW_AWP,get_pcvar_num(sniper_awp_bpammo));
cs_set_user_bpammo(id,CSW_FIVESEVEN,get_pcvar_num(sniper_fiveseven_bpammo));
gHasThisClass[id] = CLASS_SNIPER;
gIsSniperCT[id] += 1;
}
}
}
// Infantry
case 3:
{
switch(get_user_team(id))
{
case 1:
{
if(gIsInfantryTE[id] >= get_pcvar_num(pmax_infantry))
{
client_print_green(id,"[BF2] There can only be %d %s on your team!",get_pcvar_num(pmax_infantry),gUserClasses[2]);
menu_display(id,menu,0);
return 1;
}
fm_strip_user_weapons(id);
if(!user_has_weapon(id,CSW_KNIFE))
fm_give_item(id,"weapon_knife");
fm_give_item(id,"weapon_famas");
fm_give_item(id,"weapon_usp");
fm_give_item(id,"weapon_hegrenade");
cs_set_user_bpammo(id,CSW_FAMAS,get_pcvar_num(infantry_famas_bpammo));
cs_set_user_bpammo(id,CSW_USP,get_pcvar_num(infantry_usp_bpammo));
gHasThisClass[id] = CLASS_INFANTRY;
gIsInfantryTE[id] += 1;
}
case 2:
{
if(gIsInfantryTE[id] >= get_pcvar_num(pmax_infantry))
{
client_print_green(id,"[BF2] There can only be %d %s on your team!",get_pcvar_num(pmax_infantry),gUserClasses[2]);
menu_display(id,menu,0);
return 1;
}
fm_strip_user_weapons(id);
if(!user_has_weapon(id,CSW_KNIFE))
fm_give_item(id,"weapon_knife");
fm_give_item(id,"weapon_famas");
fm_give_item(id,"weapon_usp");
fm_give_item(id,"weapon_hegrenade");
cs_set_user_bpammo(id,CSW_FAMAS,get_pcvar_num(infantry_famas_bpammo));
cs_set_user_bpammo(id,CSW_USP,get_pcvar_num(infantry_usp_bpammo));
gHasThisClass[id] = CLASS_INFANTRY;
gIsInfantryCT[id] += 1;
}
}
}
// Combat
case 4:
{
switch(get_user_team(id))
{
case 1:
{
if(gIsCombatTE[id] >= get_pcvar_num(pmax_combat))
{
client_print_green(id,"[BF2] There can only be %d %s on your team!",get_pcvar_num(pmax_combat),gUserClasses[3]);
menu_display(id,menu,0);
return 1;
}
fm_strip_user_weapons(id);
if(!user_has_weapon(id,CSW_KNIFE))
fm_give_item(id,"weapon_knife");
fm_give_item(id,"weapon_ak47");
fm_give_item(id,"weapon_p228");
fm_give_item(id,"weapon_hegrenade");
cs_set_user_bpammo(id,CSW_AK47,get_pcvar_num(combat_ak47_bpammo));
cs_set_user_bpammo(id,CSW_P228,get_pcvar_num(combat_p228_bpammo));
gHasThisClass[id] = CLASS_COMBAT;
gIsCombatTE[id] += 1;
}
case 2:
{
if(gIsCombatTE[id] >= get_pcvar_num(pmax_combat))
{
client_print_green(id,"[BF2] There can only be %d %s on your team!",get_pcvar_num(pmax_combat),gUserClasses[3]);
menu_display(id,menu,0);
return 1;
}
fm_strip_user_weapons(id);
if(!user_has_weapon(id,CSW_KNIFE))
fm_give_item(id,"weapon_knife");
fm_give_item(id,"weapon_ak47");
fm_give_item(id,"weapon_p228");
fm_give_item(id,"weapon_hegrenade");
cs_set_user_bpammo(id,CSW_AK47,get_pcvar_num(combat_ak47_bpammo));
cs_set_user_bpammo(id,CSW_P228,get_pcvar_num(combat_p228_bpammo));
gHasThisClass[id] = CLASS_COMBAT;
gIsCombatCT[id] += 1;
}
}
}
// Heavy Support
case 5:
{
switch(get_user_team(id))
{
case 1:
{
if(gIsHeavySupportTE[id] >= get_pcvar_num(pmax_heavysupport))
{
client_print_green(id,"[BF2] There can only be %d %s on your team!",get_pcvar_num(pmax_heavysupport),gUserClasses[4]);
menu_display(id,menu,0);
return 1;
}
fm_strip_user_weapons(id);
if(!user_has_weapon(id,CSW_KNIFE))
fm_give_item(id,"weapon_knife");
fm_give_item(id,"weapon_m249");
fm_give_item(id,"weapon_elite");
fm_give_item(id,"weapon_hegrenade");
cs_set_user_bpammo(id,CSW_M249,get_pcvar_num(heavysupport_m249_bpammo));
cs_set_user_bpammo(id,CSW_ELITE,get_pcvar_num(heavysupport_elites_bpammo));
gHasThisClass[id] = CLASS_HEAVYSUPPORT;
gIsHeavySupportTE[id] += 1;
}
case 2:
{
if(gIsHeavySupportTE[id] >= get_pcvar_num(pmax_heavysupport))
{
client_print_green(id,"[BF2] There can only be %d %s on your team!",get_pcvar_num(pmax_heavysupport),gUserClasses[4]);
menu_display(id,menu,0);
return 1;
}
fm_strip_user_weapons(id);
if(!user_has_weapon(id,CSW_KNIFE))
fm_give_item(id,"weapon_knife");
fm_give_item(id,"weapon_m249");
fm_give_item(id,"weapon_elite");
fm_give_item(id,"weapon_hegrenade");
cs_set_user_bpammo(id,CSW_M249,get_pcvar_num(heavysupport_m249_bpammo));
cs_set_user_bpammo(id,CSW_ELITE,get_pcvar_num(heavysupport_elites_bpammo));
gHasThisClass[id] = CLASS_HEAVYSUPPORT;
gIsHeavySupportCT[id] += 1;
}
}
}
// special forces
case 6:
{
switch(get_user_team(id))
{
case 1:
{
if(gIsSpecialForcesTE[id] >= get_pcvar_num(pmax_specialforces))
{
client_print_green(id,"[BF2] There can only be %d %s on your team!",get_pcvar_num(pmax_specialforces),gUserClasses[5]);
menu_display(id,menu,0);
return 1;
}
fm_strip_user_weapons(id);
if(!user_has_weapon(id,CSW_KNIFE))
fm_give_item(id,"weapon_knife");
fm_give_item(id,"weapon_m3");
fm_give_item(id,"weapon_tmp");
fm_give_item(id,"weapon_deagle");
fm_give_item(id,"weapon_hegrenade");
fm_give_item(id,"weapon_flashbang");
cs_set_user_bpammo(id,CSW_M3,get_pcvar_num(specialforces_m3_bpammo));
cs_set_user_bpammo(id,CSW_TMP,get_pcvar_num(specialforces_tmp_bpammo));
cs_set_user_bpammo(id,CSW_DEAGLE,get_pcvar_num(specialforces_deagle_bpammo));
gHasThisClass[id] = CLASS_SPECIALFORCES;
gIsSpecialForcesTE[id] += 1;
}
case 2:
{
if(gIsSpecialForcesTE[id] >= get_pcvar_num(pmax_specialforces))
{
client_print_green(id,"[BF2] There can only be %d %s on your team!",get_pcvar_num(pmax_specialforces),gUserClasses[5]);
menu_display(id,menu,0);
return 1;
}
fm_strip_user_weapons(id);
if(!user_has_weapon(id,CSW_KNIFE))
fm_give_item(id,"weapon_knife");
fm_give_item(id,"weapon_m3");
fm_give_item(id,"weapon_tmp");
fm_give_item(id,"weapon_deagle");
fm_give_item(id,"weapon_hegrenade");
fm_give_item(id,"weapon_flashbang");
cs_set_user_bpammo(id,CSW_M3,get_pcvar_num(specialforces_m3_bpammo));
cs_set_user_bpammo(id,CSW_TMP,get_pcvar_num(specialforces_tmp_bpammo));
cs_set_user_bpammo(id,CSW_DEAGLE,get_pcvar_num(specialforces_deagle_bpammo));
gHasThisClass[id] = CLASS_SPECIALFORCES;
gIsSpecialForcesCT[id] += 1;
}
}
}
// Tactical OPS
case 7:
{
switch(get_user_team(id))
{
case 1:
{
if(gIsTacticalOpsTE[id] >= get_pcvar_num(pmax_tacticalops))
{
client_print_green(id,"[BF2] There can only be %d %s on your team!",get_pcvar_num(pmax_tacticalops),gUserClasses[6]);
menu_display(id,menu,0);
return 1;
}
fm_strip_user_weapons(id);
if(!user_has_weapon(id,CSW_KNIFE))
fm_give_item(id,"weapon_knife");
fm_give_item(id,"weapon_xm1014");
fm_give_item(id,"weapon_mac10");
fm_give_item(id,"weapon_p228");
fm_give_item(id,"weapon_hegrenade");
cs_set_user_bpammo(id,CSW_XM1014,get_pcvar_num(tacticalops_xm1014_bpammo));
cs_set_user_bpammo(id,CSW_MAC10,get_pcvar_num(tacticalops_mac10_bpammo));
cs_set_user_bpammo(id,CSW_P228,get_pcvar_num(tacticalops_p228_bpammo));
gHasThisClass[id] = CLASS_TACTICALOPS;
gIsTacticalOpsTE[id] += 1;
}
case 2:
{
if(gIsTacticalOpsTE[id] >= get_pcvar_num(pmax_tacticalops))
{
client_print_green(id,"[BF2] There can only be %d %s on your team!",get_pcvar_num(pmax_tacticalops),gUserClasses[6]);
menu_display(id,menu,0);
return 1;
}
fm_strip_user_weapons(id);
if(!user_has_weapon(id,CSW_KNIFE))
fm_give_item(id,"weapon_knife");
fm_give_item(id,"weapon_xm1014");
fm_give_item(id,"weapon_mac10");
fm_give_item(id,"weapon_p228");
fm_give_item(id,"weapon_hegrenade");
cs_set_user_bpammo(id,CSW_XM1014,get_pcvar_num(tacticalops_xm1014_bpammo));
cs_set_user_bpammo(id,CSW_MAC10,get_pcvar_num(tacticalops_mac10_bpammo));
cs_set_user_bpammo(id,CSW_P228,get_pcvar_num(tacticalops_p228_bpammo));
gHasThisClass[id] = CLASS_TACTICALOPS;
gIsTacticalOpsCT[id] += 1;
}
}
}
// Assault
case 8:
{
switch(get_user_team(id))
{
case 1:
{
if(gIsAssaultTE[id] >= get_pcvar_num(pmax_assault))
{
client_print_green(id,"[BF2] There can only be %d %s on your team!",get_pcvar_num(pmax_assault),gUserClasses[7]);
menu_display(id,menu,0);
return 1;
}
fm_strip_user_weapons(id);
if(!user_has_weapon(id,CSW_KNIFE))
fm_give_item(id,"weapon_knife");
fm_give_item(id,"weapon_m4a1");
fm_give_item(id,"weapon_usp");
fm_give_item(id,"weapon_hegrenade");
cs_set_user_bpammo(id,CSW_M4A1,get_pcvar_num(assault_m4a1_bpammo));
cs_set_user_bpammo(id,CSW_USP,get_pcvar_num(assault_usp_bpammo));
gHasThisClass[id] = CLASS_ASSAULT;
gIsAssaultTE[id] += 1;
}
case 2:
{
if(gIsAssaultTE[id] >= get_pcvar_num(pmax_assault))
{
client_print_green(id,"[BF2] There can only be %d %s on your team!",get_pcvar_num(pmax_assault),gUserClasses[7]);
menu_display(id,menu,0);
return 1;
}
fm_strip_user_weapons(id);
if(!user_has_weapon(id,CSW_KNIFE))
fm_give_item(id,"weapon_knife");
fm_give_item(id,"weapon_m4a1");
fm_give_item(id,"weapon_usp");
fm_give_item(id,"weapon_hegrenade");
cs_set_user_bpammo(id,CSW_M4A1,get_pcvar_num(assault_m4a1_bpammo));
cs_set_user_bpammo(id,CSW_USP,get_pcvar_num(assault_usp_bpammo));
gHasThisClass[id] = CLASS_ASSAULT;
gIsAssaultCT[id] += 1;
}
}
}
// MEDIC
case 9:
{
switch(get_user_team(id))
{
case 1:
{
if(gIsMedicTE[id] >= get_pcvar_num(pmax_medic))
{
client_print_green(id,"[BF2] There can only be %d %s on your team!",get_pcvar_num(pmax_medic),gUserClasses[8]);
menu_display(id,menu,0);
return 1;
}
fm_strip_user_weapons(id);
if(!user_has_weapon(id,CSW_KNIFE))
fm_give_item(id,"weapon_knife");
fm_give_item(id,"weapon_p90");
fm_give_item(id,"weapon_deagle");
fm_give_item(id,"weapon_hegrenade");
cs_set_user_bpammo(id,CSW_P90,get_pcvar_num(medic_p90_bpammo));
cs_set_user_bpammo(id,CSW_DEAGLE,get_pcvar_num(medic_deagle_bpammo));
client_print_green(id,"[BF2DM] Press ^"use^" to place a medkit at where you are aiming!");
gHasThisClass[id] = CLASS_MEDIC;
gIsMedicTE[id] += 1;
}
case 2:
{
if(gIsMedicTE[id] >= get_pcvar_num(pmax_medic))
{
client_print_green(id,"[BF2] There can only be %d %s on your team!",get_pcvar_num(pmax_medic),gUserClasses[8]);
menu_display(id,menu,0);
return 1;
}
fm_strip_user_weapons(id);
if(!user_has_weapon(id,CSW_KNIFE))
fm_give_item(id,"weapon_knife");
fm_give_item(id,"weapon_p90");
fm_give_item(id,"weapon_deagle");
fm_give_item(id,"weapon_hegrenade");
cs_set_user_bpammo(id,CSW_P90,get_pcvar_num(medic_p90_bpammo));
cs_set_user_bpammo(id,CSW_DEAGLE,get_pcvar_num(medic_deagle_bpammo));
client_print_green(id,"[BF2] Press ^"use^" to place a medkit at where you are aiming!");
gHasThisClass[id] = CLASS_MEDIC;
gIsMedicCT[id] += 1;
}
}
}
// Demolition Squad
case 10:
{
switch(get_user_team(id))
{
case 1:
{
if(gIsDemolitionSquadTE[id] >= get_pcvar_num(pmax_demolitionsquad))
{
client_print_green(id,"[BF2] There can only be %d %s on your team!",get_pcvar_num(pmax_demolitionsquad),gUserClasses[9]);
menu_display(id,menu,0);
return 1;
}
fm_strip_user_weapons(id);
if(!user_has_weapon(id,CSW_KNIFE))
fm_give_item(id,"weapon_knife");
fm_give_item(id,"weapon_ump45");
fm_give_item(id,"weapon_usp");
fm_give_item(id,"weapon_hegrenade");
cs_set_user_bpammo(id,CSW_UMP45,get_pcvar_num(demosquad_ump45_bpammo));
cs_set_user_bpammo(id,CSW_USP,get_pcvar_num(demosquad_usp_bpammo));
gHasThisClass[id] = CLASS_DEMOLITIONSQUAD;
gIsDemolitionSquadTE[id] += 1;
}
case 2:
{
if(gIsDemolitionSquadTE[id] >= get_pcvar_num(pmax_demolitionsquad))
{
client_print_green(id,"[BF2] There can only be %d %s on your team!",get_pcvar_num(pmax_demolitionsquad),gUserClasses[9]);
menu_display(id,menu,0);
return 1;
}
fm_strip_user_weapons(id);
if(!user_has_weapon(id,CSW_KNIFE))
fm_give_item(id,"weapon_knife");
fm_give_item(id,"weapon_ump45");
fm_give_item(id,"weapon_usp");
fm_give_item(id,"weapon_hegrenade");
cs_set_user_bpammo(id,CSW_UMP45,get_pcvar_num(demosquad_ump45_bpammo));
cs_set_user_bpammo(id,CSW_USP,get_pcvar_num(demosquad_usp_bpammo));
gHasThisClass[id] = CLASS_DEMOLITIONSQUAD;
gIsDemolitionSquadCT[id] += 1;
}
}
}
// RECON
case 11:
{
switch(get_user_team(id))
{
case 1:
{
if(gIsReconTE[id] >= get_pcvar_num(pmax_recon))
{
client_print_green(id,"[BF2] There can only be %d %s on your team!",get_pcvar_num(pmax_recon),gUserClasses[10]);
menu_display(id,menu,0);
return 1;
}
fm_strip_user_weapons(id);
if(!user_has_weapon(id,CSW_KNIFE))
fm_give_item(id,"weapon_knife");
fm_give_item(id,"weapon_mp5navy");
fm_give_item(id,"weapon_fiveseven");
fm_give_item(id,"weapon_hegrenade");
cs_set_user_bpammo(id,CSW_MP5NAVY,get_pcvar_num(recon_mp5_bpammo));
cs_set_user_bpammo(id,CSW_FIVESEVEN,get_pcvar_num(recon_fiveseven_bpammo));
gHasThisClass[id] = CLASS_RECON;
gIsReconTE[id] += 1;
}
case 2:
{
if(gIsReconCT[id] >= get_pcvar_num(pmax_recon))
{
client_print_green(id,"[BF2] There can only be %d %s on your team!",get_pcvar_num(pmax_recon),gUserClasses[10]);
menu_display(id,menu,0);
return 1;
}
fm_strip_user_weapons(id);
if(!user_has_weapon(id,CSW_KNIFE))
fm_give_item(id,"weapon_knife");
fm_give_item(id,"weapon_mp5navy");
fm_give_item(id,"weapon_fiveseven");
fm_give_item(id,"weapon_hegrenade");
cs_set_user_bpammo(id,CSW_MP5NAVY,get_pcvar_num(recon_mp5_bpammo));
cs_set_user_bpammo(id,CSW_FIVESEVEN,get_pcvar_num(recon_fiveseven_bpammo));
gHasThisClass[id] = CLASS_RECON;
gIsReconCT[id] += 1;
}
}
}
// Engineer
case 12:
{
switch(get_user_team(id))
{
case 1:
{
if(gIsEngineerTE[id] >= get_pcvar_num(pmax_engineer))
{
client_print_green(id,"[BF2] There can only be %d %s on your team!",get_pcvar_num(pmax_engineer),gUserClasses[11]);
menu_display(id,menu,0);
return 1;
}
fm_strip_user_weapons(id);
if(!user_has_weapon(id,CSW_KNIFE))
fm_give_item(id,"weapon_knife");
fm_give_item(id,"weapon_p90");
fm_give_item(id,"weapon_deagle");
fm_give_item(id,"weapon_hegrenade");
cs_set_user_bpammo(id,CSW_P90,get_pcvar_num(engineer_p90_bpammo));
cs_set_user_bpammo(id,CSW_DEAGLE,get_pcvar_num(engineer_deagle_bpammo));
gHasThisClass[id] = CLASS_ENGINEER;
client_print_green(id,"[BF2] Type ^"/sandbags^" in chat to place sandbags where are you aiming");
gIsEngineerTE[id] += 1;
}
case 2:
{
if(gIsEngineerCT[id] >= get_pcvar_num(pmax_engineer))
{
client_print_green(id,"[BF2] There can only be %d %s on your team!",get_pcvar_num(pmax_engineer),gUserClasses[11]);
menu_display(id,menu,0);
return 1;
}
fm_strip_user_weapons(id);
if(!user_has_weapon(id,CSW_KNIFE))
fm_give_item(id,"weapon_knife");
fm_give_item(id,"weapon_p90");
fm_give_item(id,"weapon_deagle");
fm_give_item(id,"weapon_hegrenade");
cs_set_user_bpammo(id,CSW_P90,get_pcvar_num(engineer_p90_bpammo));
cs_set_user_bpammo(id,CSW_DEAGLE,get_pcvar_num(engineer_deagle_bpammo));
gHasThisClass[id] = CLASS_ENGINEER;
client_print_green(id,"[BF2] Type ^"/sandbags^" in chat to place sandbags where are you aiming");
gIsEngineerCT[id] += 1;
}
}
}
// Anti-Tank
case 13:
{
switch(get_user_team(id))
{
case 1:
{
if(gIsAntiTankTE[id] >= get_pcvar_num(pmax_antitank))
{
client_print_green(id,"[BF2] There can only be %d %s on your team!",get_pcvar_num(pmax_antitank),gUserClasses[12]);
menu_display(id,menu,0);
return 1;
}
fm_strip_user_weapons(id);
if(!user_has_weapon(id,CSW_KNIFE))
fm_give_item(id,"weapon_knife");
fm_give_item(id,"weapon_deagle");
// give required weapon for RPG
cs_set_user_bpammo(id,CSW_DEAGLE, get_pcvar_num(antitank_deagle_bpammo)); // hack :)
gHasThisClass[id] = CLASS_ANTITANK;
gIsAntiTankTE[id] += 1;
}
case 2:
{
if(gIsAntiTankCT[id] >= get_pcvar_num(pmax_antitank))
{
client_print_green(id,"[BF2] There can only be %d %s on your team!",get_pcvar_num(pmax_antitank),gUserClasses[12]);
menu_display(id,menu,0);
return 1;
}
fm_strip_user_weapons(id);
if(!user_has_weapon(id,CSW_KNIFE))
fm_give_item(id,"weapon_knife");
fm_give_item(id,"weapon_deagle");
// give required weapon for RPG
cs_set_user_bpammo(id,CSW_DEAGLE, get_pcvar_num(antitank_deagle_bpammo)); // hack again
gHasThisClass[id] = CLASS_ANTITANK;
gIsAntiTankCT[id] += 1;
}
}
}
}
return 1;
}
__________________
 @ PC Shop Gaming
LetShannonDunk.com - 2010 All-Star Dunk Contest hopeful!
|
|