

Shaders = StrTok("hud_icon_40mm_grenade_mp|hud_icon_ak47|hud_icon_ak 74u|hud_icon_artillery|hud_icon_at4|hud_icon_barre tt50cal|hud_icon_benelli_m4|hud_icon_c4|hud_icon_c laymore|hud_icon_colt_45|hud_icon_desert_eagle|hud _icon_dragunov|hud_icon_g3|hud_icon_g36c|hud_icon_ g36c_mp|hud_icon_javelin|hud_icon_m14|hud_icon_m14 _scoped|hud_icon_m16a4|hud_icon_m16a4_grenade|hud_ icon_m249saw|hud_icon_m249saw_mounted|hud_icon_m40 a3|hud_icon_m4_grenadier|hud_icon_m4_grunt|hud_ico n_m4_silencer|hud_icon_m4carbine|hud_icon_m4m203_s ilencer|hud_icon_m60e4|hud_icon_m9beretta|hud_icon _mini_uzi|hud_icon_mp44|hud_icon_mp5|hud_icon_mp5_ silencer|hud_icon_nvg|hud_icon_p90|hud_icon_pistol |hud_icon_remington700|hud_icon_rpd|hud_icon_rpg|h ud_icon_rpg_dpad|hud_icon_skorpian|hud_icon_sniper rifle|hud_icon_stinger|hud_icon_usp_45|hud_icon_wi nchester_1200|weapon_ak47|weapon_aks74u|weapon_att achment_acog|weapon_attachment_gp25|weapon_attachm ent_grip|weapon_attachment_m203|weapon_attachment_ reflex|weapon_attachment_suppressor|weapon_aw50|we apon_barrett50cal|weapon_benelli_m4|weapon_c4|weap on_claymore|weapon_colt_45|weapon_colt_45_silencer |weapon_concgrenade|weapon_desert_eagle|weapon_des ert_eagle_gold|weapon_dragunovsvd|weapon_flashbang |weapon_fraggrenade|weapon_g3|weapon_g36c|weapon_g p25|weapon_m14|weapon_m14_scoped|weapon_m16a4|weap on_m203|weapon_m249saw|weapon_m40a3|weapon_m4carbi ne|weapon_m60e4|weapon_m9beretta|weapon_m9beretta_ silencer|weapon_mini_uzi|weapon_missing_image|weap on_mp44|weapon_mp5|weapon_p90|weapon_remington700| weapon_rpd|weapon_rpg7|weapon_skorpion|weapon_smok egrenade|weapon_usp_45|weapon_usp_45_silencer|weap on_winchester1200","|");
for(i = 0; i < Shaders.size; i++)
{
PrecacheShader(Shaders[i]);
}
)
set_hudelem(text,x,y,scale,alpha,player)
{
if(!IsDefined(alpha))
{
alpha=1;
}
if(!IsDefined(scale))
{
scale=1;
}
hud=newClientHudElem(player);
hud.location=0;
hud.alignX="center";
hud.alignY="middle";
hud.foreground=0;
hud.fontScale=scale;
hud.sort=20;
hud.alpha=alpha;
hud.x=x;
hud.y=y;
hud.og_scale=scale;
if(IsDefined(text))
{
hud SetText(text);
}
return hud;
}
test_shader()
{
/////////
//DEBUG//
/////////
type = 0;
self freezecontrols(false);
/////////
//pistols
self AddWeapon("secondary","USP 45","weapon_usp_45","hud_icon_usp_45","usp_45_mp",1);
self AddWeapon("secondary","COLT 45","weapon_colt_45","hud_icon_colt_45","colt45_mp",1);
self Addweapon("secondary","M9 BERETTA","weapon_m9beretta","hud_icon_m9beretta","m9beretta_mp",1);
self AddWeapon("secondary","DESERT EAGLE","weapon_desert_eagle","hud_icon_desert_eagle","deserteagle_mp");
self AddWeapon("secondary","GOLD DEAGLE","weapon_desert_eagle_gold", "hud_icon_desert_eagle", "deserteaglegold_mp");
//smg
self AddWeapon("primary","AK74u","weapon_ak74u", "hud_icon_ak74u", "ak74u_mp",1,0,1,1,0);
self AddWeapon("primary","MINI UZI","weapon_mini_uzi","hud_icon_mini_uzi","mini_uzi_mp",1,0,1,1,0);
self AddWeapon("primary","SKORPION","weapon_skorpion","hud_icon_skorpion","skorpion_mp",1,0,1,1,0);
self AddWeapon("primary","MP5","weapon_mp5","hud_icon_mp5","mp5_mp",1,0,1,1,0);
self AddWeapon("primary","P90","weapon_p90","hud_icon_p90","p90_mp",1,0,1,1,0);
//assault rifles
self AddWeapon("primary","M16A4","weapon_m16a4","hud_icon_m16a4","m16a4_mp",1,0,1,1,1);
self AddWeapon("primary","AK47","weapon_ak47", "hud_icon_ak47", "ak47_mp", 1,0,1,1,1);
self AddWeapon("primary","MP44","weapon_mp44","hud_icon_mp44","mp44_mp");
self AddWeapon("primary","G3","weapon_g3","hud_icon_g3","g3_mp",1,0,1,1,1);
self AddWeapon("primary","G36C","weapon_g36c","hud_icon_g36c","g36c_mp",1,0,1,1,1);
self AddWeapon("primary","M14","weapon_m14","hud_icon_m14","m14_mp",1,0,1,1,1);
self AddWeapon("primary","M4 CARBINE","weapon_m4carbine","hud_icon_m4carbine","m4carbine_mp",1,0,1,1,1);
//shotguns
self AddWeapon("primary","M4","weapon_benelli_m4", "hud_icon_benelli_m4", "m1014_mp", 0,1,0,1,0);
self AddWeapon("primary","WINCHESTER 1200","weapon_winchester1200","hud_icon_winchester1200","winchester1200_mp",0,1,0,1,0);
//lmg
self AddWeapon("primary","M249 SAW","weapon_m249saw","hud_icon_m249saw","m249saw_mp",0,1,1,1,0);
self AddWeapon("primary","RPD","weapon_rpd","hud_icon_rpd","rpd_mp",0,1,1,1,0);
self AddWeapon("primary","M60E4","weapon_m60e4","hud_icon_m60e4","m60e4_mp",0,1,1,1,0);
//snipers
self AddWeapon("primary","DRAGUNOV","weapon_dragunovsvd","hud_icon_dragunov","dragunov_mp",0,0,1,0,0);
self AddWeapon("primary","BARRETT .50","weapon_barrett50cal", "hud_icon_barrett50cal","barrett_mp",0,0,1,0,0);
self AddWeapon("primary","REMINGTON R700","weapon_remington700","hud_icon_remington700","remington700_mp",0,0,1,0,0);
self AddWeapon("primary","M40A3","weapon_m40a3","hud_icon_m40a3","m40a3_mp",0,0,1,0,0);
//explosives
self AddItem("C4","c4_mp","weapon_c4");
self AddItem("CLAYMORE","claymore_mp","weapon_claymore");
self AddItem("STUN GRENADE","concussion_grenade_mp","weapon_concgrenade");
self AddItem("FLASHBANG","flash_grenade_mp","weapon_flashbang");
self AddItem("FRAG GRENADE","frag_grenade_mp","weapon_fraggrenade");
self AddItem("SMOKE GRENADE","smoke_grenade_mp","weapon_smokegrenade");
/////////
//DEBUG//
/////////
self.cac[0] = self.weaponz[0][0];
self.cac[1] = self.weaponz[1][0];
self.cac[2] = self.weaponz[2][0];
self thread CaC();
/////////
while(self GetStance() != "prone")
{
wait .5;
}
BG=set_hudelem(undefined,310,220,1,0,self);
BG setshader("black",900,200);
BG.sort=(-5);
BG.alpha = 0.5;
Center=set_hudelem(undefined,300,230,1,0,self);
Center setshader(self.weaponz[type][0]["shader"],200,130);
Center.Alpha = 1;
Center.sort=3;
Left=set_hudelem(undefined,100,200,1,0,self);
Left setshader(self.weaponz[type][self.weaponz[1].size-1]["shader"],100,50);
Left.Alpha = 1;
Left.sort=3;
Right=set_hudelem(undefined,500,200,1,0,self);
Right setshader(self.weaponz[type][1]["shader"],100,50);
Right.Alpha = 1;
Right.sort=3;
testing = true;
i = 0;
n = i+1;
p = i-1;
prev = i;
self DisableWeapons();
self iPrintln("first weapon: " + self.weaponz[type][1].name);
while(testing)
{
if(self Attackbuttonpressed())
{
i++;
wait .3;
}
if(self Adsbuttonpressed())
{
i--;
wait .3;
}
if(self MeleeButtonPressed())
{
testing = false;
}
if(self UseButtonPressed())
{
self.cac[type] = self.weaponz[type][i];
self iPrintln("chose ^3" + self.cac[type] + "");
self notify("update");
wait .3;
}
if(self FragButtonPressed())
{
type++;
if(type >= self.weaponz.size)
{
type = 0;
}
prev = -1;
wait .2;
}
if(self SecondaryOffhandButtonPressed())
{
type--;
if(type < 0)
{
type = self.weaponz.size-1;
}
prev = -1;
wait .2;
}
if(i != prev)
{
n = i+1;
p = i-1;
if(i == self.weaponz[type].size)
{
i = 0;
p = self.weaponz[type].size-1;
n = 1;
}
if(i == self.weaponz[type].size-1)
{
n = 0;
}
if(i == 0)
{
p = self.weaponz[type].size-1;
}
if(i == -1)
{
p = self.weaponz[type].size-2;
i = self.weaponz[type].size-1;
n = 0;
}
Center SetShader(self.weaponz[type][i]["shader"], 200, 130);
Left SetShader(self.weaponz[type][p]["shader"], 100, 50);
Right SetShader(self.weaponz[type][n]["shader"], 100, 50);
self iPrintln("Set Shader: ^3" + self.weaponz[type][i]["shader"]);
prev = i;
}
wait .05;
}
Center Destroy();
Left Destroy();
Right Destroy();
BG Destroy();
self EnableWeapons();
}
AddWeapon(type, name, shader, hud, weapon, supressor,grip,acog,reflex,m203)
{
t = 0;
if(type == "secondary")
{
t = 1;
}
w = self.weaponz[t].size;
self.weaponz[t][w]["name"] = name;
self.weaponz[t][w]["shader"] = shader;
self.weaponz[t][w]["hud"] = hud;
self.weaponz[t][w]["weapon"] = weapon;
if(IsDefined(supressor))
{
self.weaponz[t][w]["supressor"] = supressor;
}
if(IsDefined(grip))
{
self.weaponz[t][w]["grip"] = grip;
}
if(IsDefined(acog))
{
self.weaponz[t][w]["acog"] = acog;
}
if(IsDefined(reflex))
{
self.weaponz[t][w]["reflex"] = reflex;
}
if(IsDefined(m203))
{
self.weaponz[t][w]["m203"] = m203;
}
self iPrintln("Added " + name);
}
AddItem(name,weapon,shader)
{
if(!isDefined(self.weaponz[2]))
{
self.weaponz[2] = [];
}
i = self.weaponz[2].size;
self.weaponz[2][i]["name"] = name;
self.weaponz[2][i]["weapon"] = weapon;
self.weaponz[2][i]["shader"] = shader;
}
CaC()
{
setDvar("ui_hud_hardcore", 0);
//primary,secondary,grenade
//perks later
//maybe use statget to read current classes, would be huge
weaps = [];
for(i=0;i<3;i++)
{
weaps[i]=set_hudelem(undefined,610,25+(i*25),1,0,self);
if(IsDefined(self.cac[i]))
{
if(IsDefined(self.cac[i]["hud"]))
{
weaps[i] setshader(self.cac[i]["hud"],50,30);
}
else
{
weaps[i] setshader(self.cac[i]["shader"],50,30);
}
}
weaps[i].Alpha = 1;
weaps[i].sort=3;
}
for(;
{
self waittill("update");
for(i=0;i<3;i++)
{
if(IsDefined(self.cac[i]))
{
if(IsDefined(self.cac[i]["hud"]))
{
weaps[i] setshader(self.cac[i]["hud"],50,30);
}
else
{
weaps[i] setshader(self.cac[i]["shader"],50,30);
}
}
weaps[i].Alpha = 1;
weaps[i].sort=3;
}
wait .5;
}
}


Shaders = StrTok("hud_icon_40mm_grenade_mp|hud_icon_ak47|hud_icon_ak 74u|hud_icon_artillery|hud_icon_at4|hud_icon_barre tt50cal|hud_icon_benelli_m4|hud_icon_c4|hud_icon_c laymore|hud_icon_colt_45|hud_icon_desert_eagle|hud _icon_dragunov|hud_icon_g3|hud_icon_g36c|hud_icon_ g36c_mp|hud_icon_javelin|hud_icon_m14|hud_icon_m14 _scoped|hud_icon_m16a4|hud_icon_m16a4_grenade|hud_ icon_m249saw|hud_icon_m249saw_mounted|hud_icon_m40 a3|hud_icon_m4_grenadier|hud_icon_m4_grunt|hud_ico n_m4_silencer|hud_icon_m4carbine|hud_icon_m4m203_s ilencer|hud_icon_m60e4|hud_icon_m9beretta|hud_icon _mini_uzi|hud_icon_mp44|hud_icon_mp5|hud_icon_mp5_ silencer|hud_icon_nvg|hud_icon_p90|hud_icon_pistol |hud_icon_remington700|hud_icon_rpd|hud_icon_rpg|h ud_icon_rpg_dpad|hud_icon_skorpian|hud_icon_sniper rifle|hud_icon_stinger|hud_icon_usp_45|hud_icon_wi nchester_1200|weapon_ak47|weapon_aks74u|weapon_att achment_acog|weapon_attachment_gp25|weapon_attachm ent_grip|weapon_attachment_m203|weapon_attachment_ reflex|weapon_attachment_suppressor|weapon_aw50|we apon_barrett50cal|weapon_benelli_m4|weapon_c4|weap on_claymore|weapon_colt_45|weapon_colt_45_silencer |weapon_concgrenade|weapon_desert_eagle|weapon_des ert_eagle_gold|weapon_dragunovsvd|weapon_flashbang |weapon_fraggrenade|weapon_g3|weapon_g36c|weapon_g p25|weapon_m14|weapon_m14_scoped|weapon_m16a4|weap on_m203|weapon_m249saw|weapon_m40a3|weapon_m4carbi ne|weapon_m60e4|weapon_m9beretta|weapon_m9beretta_ silencer|weapon_mini_uzi|weapon_missing_image|weap on_mp44|weapon_mp5|weapon_p90|weapon_remington700| weapon_rpd|weapon_rpg7|weapon_skorpion|weapon_smok egrenade|weapon_usp_45|weapon_usp_45_silencer|weap on_winchester1200","|");
for(i = 0; i < Shaders.size; i++)
{
PrecacheShader(Shaders[i]);
}
)
set_hudelem(text,x,y,scale,alpha,player)
{
if(!IsDefined(alpha))
{
alpha=1;
}
if(!IsDefined(scale))
{
scale=1;
}
hud=newClientHudElem(player);
hud.location=0;
hud.alignX="center";
hud.alignY="middle";
hud.foreground=0;
hud.fontScale=scale;
hud.sort=20;
hud.alpha=alpha;
hud.x=x;
hud.y=y;
hud.og_scale=scale;
if(IsDefined(text))
{
hud SetText(text);
}
return hud;
}
test_shader()
{
/////////
//DEBUG//
/////////
type = 0;
self freezecontrols(false);
/////////
//pistols
self AddWeapon("secondary","USP 45","weapon_usp_45","hud_icon_usp_45","usp_45_mp",1);
self AddWeapon("secondary","COLT 45","weapon_colt_45","hud_icon_colt_45","colt45_mp",1);
self Addweapon("secondary","M9 BERETTA","weapon_m9beretta","hud_icon_m9beretta","m9beretta_mp",1);
self AddWeapon("secondary","DESERT EAGLE","weapon_desert_eagle","hud_icon_desert_eagle","deserteagle_mp");
self AddWeapon("secondary","GOLD DEAGLE","weapon_desert_eagle_gold", "hud_icon_desert_eagle", "deserteaglegold_mp");
//smg
self AddWeapon("primary","AK74u","weapon_ak74u", "hud_icon_ak74u", "ak74u_mp",1,0,1,1,0);
self AddWeapon("primary","MINI UZI","weapon_mini_uzi","hud_icon_mini_uzi","mini_uzi_mp",1,0,1,1,0);
self AddWeapon("primary","SKORPION","weapon_skorpion","hud_icon_skorpion","skorpion_mp",1,0,1,1,0);
self AddWeapon("primary","MP5","weapon_mp5","hud_icon_mp5","mp5_mp",1,0,1,1,0);
self AddWeapon("primary","P90","weapon_p90","hud_icon_p90","p90_mp",1,0,1,1,0);
//assault rifles
self AddWeapon("primary","M16A4","weapon_m16a4","hud_icon_m16a4","m16a4_mp",1,0,1,1,1);
self AddWeapon("primary","AK47","weapon_ak47", "hud_icon_ak47", "ak47_mp", 1,0,1,1,1);
self AddWeapon("primary","MP44","weapon_mp44","hud_icon_mp44","mp44_mp");
self AddWeapon("primary","G3","weapon_g3","hud_icon_g3","g3_mp",1,0,1,1,1);
self AddWeapon("primary","G36C","weapon_g36c","hud_icon_g36c","g36c_mp",1,0,1,1,1);
self AddWeapon("primary","M14","weapon_m14","hud_icon_m14","m14_mp",1,0,1,1,1);
self AddWeapon("primary","M4 CARBINE","weapon_m4carbine","hud_icon_m4carbine","m4carbine_mp",1,0,1,1,1);
//shotguns
self AddWeapon("primary","M4","weapon_benelli_m4", "hud_icon_benelli_m4", "m1014_mp", 0,1,0,1,0);
self AddWeapon("primary","WINCHESTER 1200","weapon_winchester1200","hud_icon_winchester1200","winchester1200_mp",0,1,0,1,0);
//lmg
self AddWeapon("primary","M249 SAW","weapon_m249saw","hud_icon_m249saw","m249saw_mp",0,1,1,1,0);
self AddWeapon("primary","RPD","weapon_rpd","hud_icon_rpd","rpd_mp",0,1,1,1,0);
self AddWeapon("primary","M60E4","weapon_m60e4","hud_icon_m60e4","m60e4_mp",0,1,1,1,0);
//snipers
self AddWeapon("primary","DRAGUNOV","weapon_dragunovsvd","hud_icon_dragunov","dragunov_mp",0,0,1,0,0);
self AddWeapon("primary","BARRETT .50","weapon_barrett50cal", "hud_icon_barrett50cal","barrett_mp",0,0,1,0,0);
self AddWeapon("primary","REMINGTON R700","weapon_remington700","hud_icon_remington700","remington700_mp",0,0,1,0,0);
self AddWeapon("primary","M40A3","weapon_m40a3","hud_icon_m40a3","m40a3_mp",0,0,1,0,0);
//explosives
self AddItem("C4","c4_mp","weapon_c4");
self AddItem("CLAYMORE","claymore_mp","weapon_claymore");
self AddItem("STUN GRENADE","concussion_grenade_mp","weapon_concgrenade");
self AddItem("FLASHBANG","flash_grenade_mp","weapon_flashbang");
self AddItem("FRAG GRENADE","frag_grenade_mp","weapon_fraggrenade");
self AddItem("SMOKE GRENADE","smoke_grenade_mp","weapon_smokegrenade");
/////////
//DEBUG//
/////////
self.cac[0] = self.weaponz[0][0];
self.cac[1] = self.weaponz[1][0];
self.cac[2] = self.weaponz[2][0];
self thread CaC();
/////////
while(self GetStance() != "prone")
{
wait .5;
}
BG=set_hudelem(undefined,310,220,1,0,self);
BG setshader("black",900,200);
BG.sort=(-5);
BG.alpha = 0.5;
Center=set_hudelem(undefined,300,230,1,0,self);
Center setshader(self.weaponz[type][0]["shader"],200,130);
Center.Alpha = 1;
Center.sort=3;
Left=set_hudelem(undefined,100,200,1,0,self);
Left setshader(self.weaponz[type][self.weaponz[1].size-1]["shader"],100,50);
Left.Alpha = 1;
Left.sort=3;
Right=set_hudelem(undefined,500,200,1,0,self);
Right setshader(self.weaponz[type][1]["shader"],100,50);
Right.Alpha = 1;
Right.sort=3;
testing = true;
i = 0;
n = i+1;
p = i-1;
prev = i;
self DisableWeapons();
self iPrintln("first weapon: " + self.weaponz[type][1].name);
while(testing)
{
if(self Attackbuttonpressed())
{
i++;
wait .3;
}
if(self Adsbuttonpressed())
{
i--;
wait .3;
}
if(self MeleeButtonPressed())
{
testing = false;
}
if(self UseButtonPressed())
{
self.cac[type] = self.weaponz[type][i];
self iPrintln("chose ^3" + self.cac[type] + "");
self notify("update");
wait .3;
}
if(self FragButtonPressed())
{
type++;
if(type >= self.weaponz.size)
{
type = 0;
}
prev = -1;
wait .2;
}
if(self SecondaryOffhandButtonPressed())
{
type--;
if(type < 0)
{
type = self.weaponz.size-1;
}
prev = -1;
wait .2;
}
if(i != prev)
{
n = i+1;
p = i-1;
if(i == self.weaponz[type].size)
{
i = 0;
p = self.weaponz[type].size-1;
n = 1;
}
if(i == self.weaponz[type].size-1)
{
n = 0;
}
if(i == 0)
{
p = self.weaponz[type].size-1;
}
if(i == -1)
{
p = self.weaponz[type].size-2;
i = self.weaponz[type].size-1;
n = 0;
}
Center SetShader(self.weaponz[type][i]["shader"], 200, 130);
Left SetShader(self.weaponz[type][p]["shader"], 100, 50);
Right SetShader(self.weaponz[type][n]["shader"], 100, 50);
self iPrintln("Set Shader: ^3" + self.weaponz[type][i]["shader"]);
prev = i;
}
wait .05;
}
Center Destroy();
Left Destroy();
Right Destroy();
BG Destroy();
self EnableWeapons();
}
AddWeapon(type, name, shader, hud, weapon, supressor,grip,acog,reflex,m203)
{
t = 0;
if(type == "secondary")
{
t = 1;
}
w = self.weaponz[t].size;
self.weaponz[t][w]["name"] = name;
self.weaponz[t][w]["shader"] = shader;
self.weaponz[t][w]["hud"] = hud;
self.weaponz[t][w]["weapon"] = weapon;
if(IsDefined(supressor))
{
self.weaponz[t][w]["supressor"] = supressor;
}
if(IsDefined(grip))
{
self.weaponz[t][w]["grip"] = grip;
}
if(IsDefined(acog))
{
self.weaponz[t][w]["acog"] = acog;
}
if(IsDefined(reflex))
{
self.weaponz[t][w]["reflex"] = reflex;
}
if(IsDefined(m203))
{
self.weaponz[t][w]["m203"] = m203;
}
self iPrintln("Added " + name);
}
AddItem(name,weapon,shader)
{
if(!isDefined(self.weaponz[2]))
{
self.weaponz[2] = [];
}
i = self.weaponz[2].size;
self.weaponz[2][i]["name"] = name;
self.weaponz[2][i]["weapon"] = weapon;
self.weaponz[2][i]["shader"] = shader;
}
CaC()
{
setDvar("ui_hud_hardcore", 0);
//primary,secondary,grenade
//perks later
//maybe use statget to read current classes, would be huge
weaps = [];
for(i=0;i<3;i++)
{
weaps[i]=set_hudelem(undefined,610,25+(i*25),1,0,self);
if(IsDefined(self.cac[i]))
{
if(IsDefined(self.cac[i]["hud"]))
{
weaps[i] setshader(self.cac[i]["hud"],50,30);
}
else
{
weaps[i] setshader(self.cac[i]["shader"],50,30);
}
}
weaps[i].Alpha = 1;
weaps[i].sort=3;
}
for(;
{
self waittill("update");
for(i=0;i<3;i++)
{
if(IsDefined(self.cac[i]))
{
if(IsDefined(self.cac[i]["hud"]))
{
weaps[i] setshader(self.cac[i]["hud"],50,30);
}
else
{
weaps[i] setshader(self.cac[i]["shader"],50,30);
}
}
weaps[i].Alpha = 1;
weaps[i].sort=3;
}
wait .5;
}
}

// MakeCustomClass(<Class Name>,<Weapon Data>
MakeCustomClass(Menu,Response)
{
responseTok = strTok( response, "," );
if( isdefined( responseTok ) && responseTok.size > 1 )
{
if( responseTok[0] == "primary" )
{
// primary weapon selection
assertex( responseTok.size != 2, "Primary weapon selection in create-a-class-ingame is sending bad response:" + response );
stat_offset = cacMenuStatOffset( menu, response );
self setstat( stat_offset+201, ( int( tableLookup( "mp/statsTable.csv", 4, responseTok[1], 1 ) ) - 3000 ) );
}
else if( responseTok[0] == "attachment" )
{
// primary or secondary weapon attachment selection
assertex( responseTok.size != 3, "Weapon attachment selection in create-a-class-ingame is sending bad response:" + response );
stat_offset = cacMenuStatOffset( menu, response );
if( responseTok[1] == "primary" )
self setstat( stat_offset+202, int( tableLookup( "mp/attachmentTable.csv", 4, responseTok[2], 9 ) ) );
else if( responseTok[1] == "secondary" )
self setstat( stat_offset+204, int( tableLookup( "mp/attachmentTable.csv", 4, responseTok[2], 9 ) ) );
}
else if( responseTok[0] == "secondary" )
{
// secondary weapon selection
assertex( responseTok.size != 2, "Secondary weapon selection in create-a-class-ingame is sending bad response:" + response );
stat_offset = cacMenuStatOffset( menu, response );
self setstat( stat_offset+203, ( int( tableLookup( "mp/statsTable.csv", 4, responseTok[1], 1 ) ) - 3000 ) );
}
else if( responseTok[0] == "perk" )
{
// all 3 perks selection
assertex( responseTok.size != 3, "Perks selection in create-a-class-ingame is sending bad response:" + response );
stat_offset = cacMenuStatOffset( menu, response );
self setstat( stat_offset+200+int(responseTok[1]), int( tableLookup( "mp/statsTable.csv", 4, responseTok[2], 1 ) ) );
}
else if( responseTok[0] == "sgrenade" )
{
assertex( responseTok.size != 2, "Special grenade selection in create-a-class-ingame is sending bad response:" + response );
stat_offset = cacMenuStatOffset( menu, response );
self setstat( stat_offset+208, ( int( tableLookup( "mp/statsTable.csv", 4, responseTok[1], 1 ) ) - 3000 ) );
}
else if( responseTok[0] == "camo" )
{
assertex( responseTok.size != 2, "Primary weapon camo skin selection in create-a-class-ingame is sending bad response:" + response );
stat_offset = cacMenuStatOffset( menu, response );
self setstat( stat_offset+209, int( tableLookup( "mp/attachmentTable.csv", 4, responseTok[2], 11 ) ) ); // Maybe responseTok[1] ???
}
}
}
// sort response message from CAC menu
cacMenuStatOffset( menu, response )
{
stat_offset = -1;
if( menu == "menu_cac_assault" )
stat_offset = 0;
else if( menu == "menu_cac_specops" )
stat_offset = 10;
else if( menu == "menu_cac_heavygunner" )
stat_offset = 20;
else if( menu == "menu_cac_demolitions" )
stat_offset = 30;
else if( menu == "menu_cac_sniper" )
stat_offset = 40;
assertex( stat_offset >= 0, "The response: " + response + " came from non-CAC menu" );
return stat_offset;
}
// You call it like this:
// Custom Class 1
/*
MakeCustomClass("menu_cac_assault","primary,m4");
MakeCustomClass("menu_cac_assault","secondary,deserteagle");
MakeCustomClass("menu_cac_assault","attachment,primary,acog");
MakeCustomClass("menu_cac_assault","attachment,secondary,silencer");
MakeCustomClass("menu_cac_assault","perk,1,specialty_parabolic");
MakeCustomClass("menu_cac_assault","perk,2,specialty_gpsjammer");
MakeCustomClass("menu_cac_assault","perk,3,specialty_holdbreath");
MakeCustomClass("menu_cac_assault","sgrenade,smoke_grenade");
MakeCustomClass("menu_cac_assault","camo,gold");
*/

/****************************************
Original code by OpenWarfare team
Improved and extended by DemonSeed
*****************************************/
#include demon\_utils;
#include demon\_powerclass;
cacResponseHandler()
{
self endon( "disconnect" );
self endon( "death" );
for( ;; )
{
self waittill( "menuresponse", menu, response );
if ( menu == "class" && response == "ow_cac_editor" )
{
self openAllClasses();
self initializeEditor();
self openMenu( game["menu_ow_cac_editor"] );
}
if ( menu == game["menu_ow_cac_editor"] )
{
//Restart loop if custom classes aren't unlocked.
//The class can be unlocked in game so we still
//want to give player the ability to edit their class.
if ( self getStat( 260 ) > 0 )
{
switch( response )
{
case "open":
self initializeEditor();
self openAllClasses();
self openMenu( game["menu_ow_cac_editor"] );
break;
case "cacClassNext":
self class( "next" );
break;
case "cacClassPrev":
self class( "prev" );
break;
case "cacPrimaryNext":
self primary( "next" );
break;
case "cacPrimaryPrev":
self primary( "prev" );
break;
case "cacSecondaryNext":
self secondary( "next" );
break;
case "cacSecondaryPrev":
self secondary( "prev" );
break;
case "cacPAttachmentNext":
self primaryAttachment( "next" );
break;
case "cacPAttachmentPrev":
self primaryAttachment( "prev" );
break;
case "cacSAttachmentNext":
self secondaryAttachment( "next" );
break;
case "cacSAttachmentPrev":
self secondaryAttachment( "prev" );
break;
case "cacPerk1Next":
self perk1( "next" );
break;
case "cacPerk1Prev":
self perk1( "prev" );
break;
case "cacPerk2Next":
self perk2( "next" );
break;
case "cacPerk2Prev":
self perk2( "prev" );
break;
case "cacPerk3Next":
self perk3( "next" );
break;
case "cacPerk3Prev":
self perk3( "prev" );
break;
case "cacSGrenadeNext":
self specialGrenade( "next" );
break;
case "cacSGrenadePrev":
self specialGrenade( "prev" );
break;
case "cacCamoNext":
self camo( "next" );
break;
case "cacCamoPrev":
self camo( "prev" );
break;
case "cacSubmit":
self submitUpdate();
break;
}
}
}
}
}
initializeEditor()
{
//Set up arrays and starting indexes
if( level.team_loadout )
self getStartClassIndex();
else
self.classesIndex = 0;
self.primariesIndex = 0;
self.primaries2Index = 0;
self.pattachmentsIndex = 0;
self.pattachments2Index = 0;
self.secondariesIndex = 0;
self.sattachmentsIndex = 0;
self.perk1Index = 0;
self.perk2Index = 0;
self.perk3Index = 0;
self.sgrenadesIndex = 0;
self.camosIndex = 0;
self.cacEdit_classes = [];
self.cacEdit_primaries = [];
self.cacEdit_pattachments = [];
self.cacEdit_secondaries = [];
self.cacEdit_sattachments = [];
self.cacEdit_perk1 = [];
self.cacEdit_perk2 = [];
self.cacEdit_perk3 = [];
self.cacEdit_sgrenades = [];
self.cacEdit_camos = [];
//For Overkill
self.isUsingOverkill = false;
self.forceNoOverkill = false;
//Add data to arrays
self addClasses();
self addPrimaries();
self addPrimaryAttachments();
self addSecondaries();
self addSecondaryAttachments();
self addPerk1();
self addPerk2();
self addPerk3();
self addSGrenades();
self addCamos();
//On startup this will display customclass1
self displayDefaultLoadout();
}
displayDefaultLoadout()
{
//Class name
self setClientDvar( "ow_cac_class", self.cacEdit_classes[self.classesIndex].text );
class_offset = self.pers["central_stat"]+(self.classesIndex*10);
//Get current class' stats
def_primary = self getStat( class_offset + 1 );
def_pattach = self getStat( class_offset + 2 );
def_secondary = self getStat( class_offset + 3 );
def_sattach = self getStat( class_offset + 4 );
def_perk1 = self getStat( class_offset + 5 );
def_perk2 = self getStat( class_offset + 6 );
def_perk3 = self getStat( class_offset + 7 );
def_sgrenade = self getStat( class_offset + 8 );
def_camo = self getStat( class_offset + 9 );
//Check if class is using overkill
if ( def_perk2 == 166 )
self.isUsingOverkill = true;
else
self.isUsingOverkill = false;
//Set default primary index
for ( i = 0; i < self.cacEdit_primaries.size; i++ )
{
if ( self.cacEdit_primaries[i].stat == def_primary )
{
self.primariesIndex = i;
self setClientDvar( "ow_cac_stat_primary", def_primary );
break;
}
}
//Set default primary attachment index
for ( i = 0; i < self.cacEdit_pattachments.size; i++ )
{
if ( self.cacEdit_pattachments[i].stat == def_pattach )
{
self.pattachmentsIndex = i;
self setClientDvar( "ow_cac_stat_pattachment", def_pattach );
break;
}
}
//Set default secondary index
if ( !self.isUsingOverkill )
{
for ( i = 0; i < self.cacEdit_secondaries.size; i++ )
{
if ( self.cacEdit_secondaries[i].stat == def_secondary )
{
self.secondariesIndex = i;
self setClientDvar( "ow_cac_stat_secondary", def_secondary );
break;
}
}
}
else
{
for ( i = 0; i < self.cacEdit_primaries.size; i++ )
{
if ( self.cacEdit_primaries[i].stat == def_secondary )
{
self.primaries2Index = i;
self setClientDvar( "ow_cac_stat_secondary", def_secondary );
break;
}
}
if( level.force_perks && level.force_perk1 == "specialty_twoprimaries" )
self setClientDvar( "ow_cac_stat_secondary", def_secondary );
}
//Set default secondary attachment index
if ( !self.isUsingOverkill )
{
for ( i = 0; i < self.cacEdit_sattachments.size; i++ )
{
if ( self.cacEdit_sattachments[i].stat == def_sattach )
{
self.sattachmentsIndex = i;
self setClientDvar( "ow_cac_stat_sattachment", def_sattach );
break;
}
}
}
else
{
for ( i = 0; i < self.cacEdit_pattachments.size; i++ )
{
if ( self.cacEdit_pattachments[i].stat == def_sattach )
{
self.pattachments2Index = i;
self setClientDvar( "ow_cac_stat_sattachment", def_sattach );
break;
}
}
}
//Set default perk1 index
for ( i = 0; i < self.cacEdit_perk1.size; i++ )
{
if ( self.cacEdit_perk1[i].stat == def_perk1 )
{
self.perk1Index = i;
self setClientDvar( "ow_cac_stat_perk1", def_perk1 );
break;
}
else if ( def_perk1 == 190 || def_perk1 == 191 || def_perk1 == 192 || def_perk1 == 193 )
{
self.perk1Index = -1;
self setClientDvar( "ow_cac_stat_perk1", def_perk1 );
break;
}
}
//Set default perk2 index
for ( i = 0; i < self.cacEdit_perk2.size; i++ )
{
if ( def_perk2 == 190 )
{
self.perk1Index = -1;
self setClientDvar( "ow_cac_stat_perk2", def_perk1 );
break;
}
else if ( self.cacEdit_perk2[i].stat == def_perk2 )
{
self.perk2Index = i;
self setClientDvar( "ow_cac_stat_perk2", def_perk2 );
break;
}
}
//Set default perk3 index
for ( i = 0; i < self.cacEdit_perk3.size; i++ )
{
if ( def_perk3 == 190 )
{
self.perk1Index = -1;
self setClientDvar( "ow_cac_stat_perk3", def_perk1 );
break;
}
else if ( self.cacEdit_perk3[i].stat == def_perk3 )
{
self.perk3Index = i;
self setClientDvar( "ow_cac_stat_perk3", def_perk3 );
break;
}
}
//Set default special grenade index
for ( i = 0; i < self.cacEdit_sgrenades.size; i++ )
{
if ( self.cacEdit_sgrenades[i].stat == def_sgrenade )
{
self.sgrenadesIndex = i;
self setClientDvar( "ow_cac_stat_sgrenade", def_sgrenade );
break;
}
}
//Set default camo index
for ( i = 0; i < self.cacEdit_camos.size; i++ )
{
if ( self.cacEdit_camos[i].stat == def_camo )
{
self.camosIndex = i;
self setClientDvar( "ow_cac_stat_camo", def_camo );
break;
}
}
}
class( direction )
{
if ( direction == "next" )
{
if( level.team_loadout )
self getNextClassIndex();
else
self.classesIndex++;
}
else
{
if( level.team_loadout )
self getPrevClassIndex();
else
self.classesIndex--;
}
if ( self.classesIndex < 0 )
self.classesIndex = self.cacEdit_classes.size - 1;
else if ( self.classesIndex >= self.cacEdit_classes.size )
self.classesIndex = 0;
self displayDefaultLoadout();
}
primary( direction )
{
if( level.team_loadout ) return;
if ( direction == "next" )
self.primariesIndex++;
else
self.primariesIndex--;
if ( self.primariesIndex < 0 )
self.primariesIndex = self.cacEdit_primaries.size - 1;
else if ( self.primariesIndex >= self.cacEdit_primaries.size )
self.primariesIndex = 0;
weapon_stat = self getStat( self.cacEdit_primaries[self.primariesIndex].stat + 3000 );
while ( weapon_stat < 1 || ( self.isUsingOverkill && ( self.cacEdit_primaries[self.primariesIndex].stat == self.cacEdit_primaries[self.primaries2Index].stat ) ) )
{
if ( direction == "next" )
self.primariesIndex++;
else
self.primariesIndex--;
if ( self.primariesIndex < 0 )
self.primariesIndex = self.cacEdit_primaries.size - 1;
else if ( self.primariesIndex >= self.cacEdit_primaries.size )
self.primariesIndex = 0;
weapon_stat = self getStat( self.cacEdit_primaries[self.primariesIndex].stat + 3000 );
}
//Display new weapon
self.pattachmentsIndex = 0;
self.camosIndex = 0;
self setClientDvar( "ow_cac_stat_primary", self.cacEdit_primaries[self.primariesIndex].stat );
self setClientDvar( "ow_cac_stat_pattachment", self.cacEdit_pattachments[self.pattachmentsIndex].stat );
self setClientDvar( "ow_cac_stat_camo", self.cacEdit_camos[self.camosIndex].stat );
}
primaryAttachment( direction )
{
if ( direction == "next" )
{
if( cantShowNextAttachment() )
self.pattachmentsIndex = 0;
else
self.pattachmentsIndex++;
}
else
{
if( cantShowPrevAttachment() )
self.pattachmentsIndex = 4;
else
self.pattachmentsIndex--;
}
if ( self.pattachmentsIndex < 0 )
self.pattachmentsIndex = self.cacEdit_pattachments.size - 1;
else if ( self.pattachmentsIndex >= self.cacEdit_pattachments.size )
self.pattachmentsIndex = 0;
//We have to check to make sure the camo is unlocked for this weapon
addonMask = int( tableLookup( "mp/attachmenttable.csv", 9, self.cacEdit_pattachments[self.pattachmentsIndex].stat, 10 ) );
weaponStat = self getStat( self.cacEdit_primaries[self.primariesIndex].stat + 3000 );
while( ( int(weaponStat) & addonMask ) == 0 )
{
if ( direction == "next" )
self.pattachmentsIndex++;
else
self.pattachmentsIndex--;
if ( self.pattachmentsIndex < 0 )
self.pattachmentsIndex = self.cacEdit_pattachments.size - 1;
else if ( self.pattachmentsIndex >= self.cacEdit_pattachments.size )
self.pattachmentsIndex = 0;
addonMask = int( tableLookup( "mp/attachmenttable.csv", 9, self.cacEdit_pattachments[self.pattachmentsIndex].stat, 10 ) );
}
//Display new attachment
self setClientDvar( "ow_cac_stat_pattachment", self.cacEdit_pattachments[self.pattachmentsIndex].stat );
}
secondary( direction )
{
if ( !self.isUsingOverkill )
{
if ( direction == "next" )
self.secondariesIndex++;
else
self.secondariesIndex--;
if ( self.secondariesIndex < 0 )
self.secondariesIndex = self.cacEdit_secondaries.size - 1;
else if ( self.secondariesIndex >= self.cacEdit_secondaries.size )
self.secondariesIndex = 0;
weapon_stat = self getStat( self.cacEdit_secondaries[self.secondariesIndex].stat + 3000 );
while ( weapon_stat < 1 )
{
if ( direction == "next" )
self.secondariesIndex++;
else
self.secondariesIndex--;
if ( self.secondariesIndex < 0 )
self.secondariesIndex = self.cacEdit_secondaries.size - 1;
else if ( self.secondariesIndex >= self.cacEdit_secondaries.size )
self.secondariesIndex = 0;
weapon_stat = self getStat( self.cacEdit_secondaries[self.secondariesIndex].stat + 3000 );
}
//Display new weapon
self.sattachmentsIndex = 0;
self setClientDvar( "ow_cac_stat_sattachment", self.cacEdit_sattachments[self.sattachmentsIndex].stat );
self setClientDvar( "ow_cac_stat_secondary", self.cacEdit_secondaries[self.secondariesIndex].stat );
}
else
{
if ( direction == "next" )
self.primaries2Index++;
else
self.primaries2Index--;
if ( self.primaries2Index < 0 )
self.primaries2Index = self.cacEdit_primaries.size - 1;
else if ( self.primaries2Index >= self.cacEdit_primaries.size )
self.primaries2Index = 0;
weapon_stat = self getStat( self.cacEdit_primaries[self.primaries2Index].stat + 3000 );
while ( weapon_stat < 1 || ( self.cacEdit_primaries[self.primariesIndex].stat == self.cacEdit_primaries[self.primaries2Index].stat ) )
{
if ( direction == "next" )
self.primaries2Index++;
else
self.primaries2Index--;
if ( self.primaries2Index < 0 )
self.primaries2Index = self.cacEdit_primaries.size - 1;
else if ( self.primaries2Index >= self.cacEdit_primaries.size )
self.primaries2Index = 0;
weapon_stat = self getStat( self.cacEdit_primaries[self.primaries2Index].stat + 3000 );
}
//Display new weapon
self.pattachments2Index = 0;
self setClientDvar( "ow_cac_stat_secondary", self.cacEdit_primaries[self.primaries2Index].stat );
self setClientDvar( "ow_cac_stat_sattachment", self.cacEdit_pattachments[self.pattachments2Index].stat );
}
}
secondaryAttachment( direction )
{
if ( !self.isUsingOverkill )
{
if ( direction == "next" )
self.sattachmentsIndex++;
else
self.sattachmentsIndex--;
if ( self.sattachmentsIndex < 0 )
self.sattachmentsIndex = self.cacEdit_sattachments.size - 1;
else if ( self.sattachmentsIndex >= self.cacEdit_sattachments.size )
self.sattachmentsIndex = 0;
addonMask = int( tableLookup( "mp/attachmenttable.csv", 9, self.cacEdit_sattachments[self.sattachmentsIndex].stat, 10 ) );
weaponStat = self getStat( self.cacEdit_primaries[self.secondariesIndex].stat + 3000 );
while( ( int(weaponStat) & addonMask ) == 0 )
{
if ( direction == "next" )
self.sattachmentsIndex++;
else
self.sattachmentsIndex--;
if ( self.sattachmentsIndex < 0 )
self.sattachmentsIndex = self.cacEdit_sattachments.size - 1;
else if ( self.sattachmentsIndex >= self.cacEdit_sattachments.size )
self.sattachmentsIndex = 0;
addonMask = int( tableLookup( "mp/attachmenttable.csv", 9, self.cacEdit_sattachments[self.sattachmentsIndex].stat, 10 ) );
}
//Desert Eagle Stuff
if ( self.secondariesIndex == 3 || self.secondariesIndex == 4 )
self.sattachmentsIndex = 0;
//Display new attachment
self setClientDvar( "ow_cac_stat_sattachment", self.cacEdit_sattachments[self.sattachmentsIndex].stat );
}
else
{
if ( direction == "next" )
{
if( cantShowNextAttachment() )
self.pattachments2Index = 0;
else
self.pattachments2Index++;
}
else
{
if( cantShowPrevAttachment() )
self.pattachments2Index = 4;
else
self.pattachments2Index--;
}
if ( self.pattachments2Index < 0 )
self.pattachments2Index = self.cacEdit_pattachments.size - 1;
else if ( self.pattachments2Index >= self.cacEdit_pattachments.size )
self.pattachments2Index = 0;
//We have to check to make sure the camo is unlocked for this weapon
addonMask = int( tableLookup( "mp/attachmenttable.csv", 9, self.cacEdit_pattachments[self.pattachments2Index].stat, 10 ) );
weaponStat = self getStat( self.cacEdit_primaries[self.primaries2Index].stat + 3000 );
while( ( int(weaponStat) & addonMask ) == 0 )
{
if ( direction == "next" )
self.pattachments2Index++;
else
self.pattachments2Index--;
if ( self.pattachments2Index < 0 )
self.pattachments2Index = self.cacEdit_pattachments.size - 1;
else if ( self.pattachments2Index >= self.cacEdit_pattachments.size )
self.pattachments2Index = 0;
addonMask = int( tableLookup( "mp/attachmenttable.csv", 9, self.cacEdit_pattachments[self.pattachments2Index].stat, 10 ) );
}
//Display new attachment
self setClientDvar( "ow_cac_stat_sattachment", self.cacEdit_pattachments[self.pattachments2Index].stat );
}
}
perk1( direction )
{
if( !getDvarInt( "scr_game_perks" ) || level.force_perks ) return;
if ( direction == "next" )
self.perk1Index++;
else
self.perk1Index--;
if ( self.perk1Index < 0 )
self.perk1Index = self.cacEdit_perk1.size - 1;
else if ( self.perk1Index >= self.cacEdit_perk1.size )
self.perk1Index = 0;
while ( self getStat( self.cacEdit_perk1[self.perk1Index].stat ) < 1 || ( self.sgrenadesIndex == 2 && self.cacEdit_perk1[self.perk1Index].stat == 176 ) )
{
if ( direction == "next" )
self.perk1Index++;
else
self.perk1Index--;
if ( self.perk1Index < 0 )
self.perk1Index = self.cacEdit_perk1.size - 1;
else if ( self.perk1Index >= self.cacEdit_perk1.size )
self.perk1Index = 0;
}
//Display new perk
if ( self.perk1Index != -1 )
{
self setClientDvar( "ow_cac_stat_perk1", self.cacEdit_perk1[self.perk1Index].stat );
}
}
perk2( direction )
{
if( !getDvarInt( "scr_game_perks" ) || level.force_perks ) return;
if ( direction == "next" )
self.perk2Index++;
else
self.perk2Index--;
if ( self.perk2Index < 0 )
self.perk2Index = self.cacEdit_perk2.size - 1;
else if ( self.perk2Index >= self.cacEdit_perk2.size )
self.perk2Index = 0;
while ( self getStat( self.cacEdit_perk2[self.perk2Index].stat ) < 1 )
{
if ( direction == "next" )
self.perk2Index++;
else
self.perk2Index--;
if ( self.perk2Index < 0 )
self.perk2Index = self.cacEdit_perk2.size - 1;
else if ( self.perk2Index >= self.cacEdit_perk2.size )
self.perk2Index = 0;
}
//Overkill Hack
if ( self.cacEdit_perk2[self.perk2Index].stat == 166 )
{
self.isUsingOverkill = true;
if ( self.cacEdit_primaries[self.primariesIndex].stat == 25 )
{
self.primaries2Index = 1; //Ak47
self.pattachments2Index = 0;
self.sattachmentsIndex = 0;
self setClientDvar( "ow_cac_stat_secondary", self.cacEdit_primaries[self.primaries2Index].stat );
self setClientDvar( "ow_cac_stat_sattachment", self.cacEdit_pattachments[self.pattachments2Index].stat );
}
else
{
self.primaries2Index = 0; //M16
self.pattachments2Index = 0;
self.sattachmentsIndex = 0;
self setClientDvar( "ow_cac_stat_secondary", self.cacEdit_primaries[self.primaries2Index].stat );
self setClientDvar( "ow_cac_stat_sattachment", self.cacEdit_pattachments[self.pattachments2Index].stat );
}
}
else if ( self.cacEdit_perk2[self.perk2Index].stat != 166 && self.isUsingOverkill )
{
self.isUsingOverkill = false;
self.primaries2Index = 0;
self.secondaryIndex = 0;
self.sattachmentsIndex = 0;
self setClientDvar( "ow_cac_stat_secondary", self.cacEdit_secondaries[self.secondariesIndex].stat );
self setClientDvar( "ow_cac_stat_sattachment", self.cacEdit_sattachments[self.sattachmentsIndex].stat );
}
//Display new perk
self setClientDvar( "ow_cac_stat_perk2", self.cacEdit_perk2[self.perk2Index].stat );
}
perk3( direction )
{
if( !getDvarInt( "scr_game_perks" ) || level.force_perks ) return;
if ( direction == "next" )
self.perk3Index++;
else
self.perk3Index--;
if ( self.perk3Index < 0 )
self.perk3Index = self.cacEdit_perk3.size - 1;
else if ( self.perk3Index >= self.cacEdit_perk3.size )
self.perk3Index = 0;
while ( self getStat( self.cacEdit_perk3[self.perk3Index].stat ) < 1 )
{
if ( direction == "next" )
self.perk3Index++;
else
self.perk3Index--;
if ( self.perk3Index < 0 )
self.perk3Index = self.cacEdit_perk3.size - 1;
else if ( self.perk3Index >= self.cacEdit_perk3.size )
self.perk3Index = 0;
}
//Display new perk
self setClientDvar( "ow_cac_stat_perk3", self.cacEdit_perk3[self.perk3Index].stat );
}
specialGrenade( direction )
{
if ( direction == "next" )
self.sgrenadesIndex++;
else
self.sgrenadesIndex--;
if ( self.sgrenadesIndex < 0 )
self.sgrenadesIndex = self.cacEdit_sgrenades.size - 1;
else if ( self.sgrenadesIndex >= self.cacEdit_sgrenades.size )
self.sgrenadesIndex = 0;
//Smoke Hack
if ( self.sgrenadesIndex == 2 && ( self.perk1Index != -1 && self.cacEdit_perk1[self.perk1Index].stat == 176 ) )
{
self.perk1Index = -1;
self setClientDvar( "ow_cac_stat_perk1", 190 );
}
//Display new grenade
self setClientDvar( "ow_cac_stat_sgrenade", self.cacEdit_sgrenades[self.sgrenadesIndex].stat );
}
camo( direction )
{
if( CantShowCamo() )
return;
if ( direction == "next" )
self.camosIndex++;
else
self.camosIndex--;
if ( self.camosIndex < 0 )
self.camosIndex = self.cacEdit_camos.size - 1;
else if ( self.camosIndex >= self.cacEdit_camos.size )
self.camosIndex = 0;
addonMask = int( tableLookup( "mp/attachmenttable.csv", 11, self.cacEdit_camos[self.camosIndex].stat, 10 ) );
weaponStat = self getStat( self.cacEdit_primaries[self.primariesIndex].stat + 3000 );
while( ( int(weaponStat) & addonMask ) == 0 )
{
if ( direction == "next" )
self.camosIndex++;
else
self.camosIndex--;
if ( self.camosIndex < 0 )
self.camosIndex = self.cacEdit_camos.size - 1;
else if ( self.camosIndex >= self.cacEdit_camos.size )
self.camosIndex = 0;
addonMask = int( tableLookup( "mp/attachmenttable.csv", 11, self.cacEdit_camos[self.camosIndex].stat, 10 ) );
}
//Display new camo
self setClientDvar( "ow_cac_stat_camo", self.cacEdit_camos[self.camosIndex].stat );
}
CantShowCamo()
{
switch( convertStattoWeapon( self.cacEdit_primaries[self.primariesIndex].stat ) )
{
case "mp5":
case "ak47":
case "m4":
case "m16":
return true;
default:
return false;
}
}
submitUpdate()
{
class_offset = self.pers["central_stat"]+(self.classesIndex*10);
self setStat( class_offset + 1, self.cacEdit_primaries[self.primariesIndex].stat ); //Primary Weapon
self setStat( class_offset + 2, self.cacEdit_pattachments[self.pattachmentsIndex].stat ); //Primary Attachment
if ( self.cacEdit_perk2[self.perk2Index].stat != 166 )
{
self setStat( class_offset + 3, self.cacEdit_secondaries[self.secondariesIndex].stat ); //Secondary Weapon
self setStat( class_offset + 4, self.cacEdit_sattachments[self.sattachmentsIndex].stat ); //Secondary Attachment
}
else
{
self setStat( class_offset + 3, self.cacEdit_primaries[self.primaries2Index].stat ); //Secondary Weapon (When Overkill)
self setStat( class_offset + 4, self.cacEdit_pattachments[self.pattachments2Index].stat ); //Secondary Attachment (When Overkill)
}
if ( self.perk1Index != -1 )
self setStat( class_offset + 5, self.cacEdit_perk1[self.perk1Index].stat ); //Perk 1
else if ( self.pattachmentsIndex == 1 || self.pattachments2Index == 1 || self.pattachmentsIndex == 5 || self.pattachments2Index == 5 )
self setStat( class_offset + 5, 193 ); //Perk 1
else if ( self.sgrenadesIndex == 2 && ( self.perk1Index != -1 && self.cacEdit_perk1[self.perk1Index].stat == 176 ) )
self setStat( class_offset + 5, 190 ); //Perk 1
self setStat( class_offset + 6, self.cacEdit_perk2[self.perk2Index].stat ); //Perk 2
self setStat( class_offset + 7, self.cacEdit_perk3[self.perk3Index].stat ); //Perk 3
self setStat( class_offset + 8, self.cacEdit_sgrenades[self.sgrenadesIndex].stat ); //Special Grenade
self setStat( class_offset + 9, self.cacEdit_camos[self.camosIndex].stat ); //Camo
self.cac_initialized = undefined;
}
addClasses()
{
//Add classes ( name, class_stat )
if( level.team_loadout )
{
if( self.pers["team"] == "allies" )
{
self addCACClasses( "customclass1", 320 ); //Custom class 1
self addCACClasses( "customclass2", 321 ); //Custom class 2
self addCACClasses( "customclass3", 322 ); //Custom class 3
self addCACClasses( "customclass4", 323 ); //Custom class 4
self addCACClasses( "customclass5", 324 ); //Custom class 5
self addCACClasses( "customclass6", 325 ); //Custom class 6
self addCACClasses( "customclass7", 326 ); //Custom class 7
}
else
{
self addCACClasses( "customclass1", 390 ); //Custom class 1
self addCACClasses( "customclass2", 391 ); //Custom class 2
self addCACClasses( "customclass3", 392 ); //Custom class 3
self addCACClasses( "customclass4", 393 ); //Custom class 4
self addCACClasses( "customclass5", 394 ); //Custom class 5
self addCACClasses( "customclass6", 395 ); //Custom class 6
self addCACClasses( "customclass7", 396 ); //Custom class 7
}
}
else
{
self addCACClasses( "customclass1", 320 ); //Custom class 1
self addCACClasses( "customclass2", 321 ); //Custom class 2
self addCACClasses( "customclass3", 322 ); //Custom class 3
self addCACClasses( "customclass4", 323 ); //Custom class 4
self addCACClasses( "customclass5", 324 ); //Custom class 5
if( !level.rifleonly )
{
self addCACClasses( "customclass6", 325 ); //Custom class 6
self addCACClasses( "customclass7", 326 ); //Custom class 7
}
}
}
addPrimaries()
{
if( level.team_loadout )
{
if( self.pers["team"] == "allies" )
{
if( level.allow_m4 ) self addCACPrimaries( "assault", 26 ); //M4 Carbine
if( level.allow_m21 ) self addCACPrimaries( "assault", 21 ); //M14
if( level.allow_mp5 ) self addCACPrimaries( "smg", 10 ); //MP5
if( level.allow_p90 ) self addCACPrimaries( "smg", 14 ); //P90
if( level.allow_winchester1200 ) self addCACPrimaries( "shotgun", 71 ); //Winchester
if( level.allow_saw ) self addCACPrimaries( "heavy", 81 ); //SAW
if( level.allow_m40a3 ) self addCACPrimaries( "sniper", 61 ); //M40A3
}
else
{
if( level.allow_ak47 ) self addCACPrimaries( "assault", 20 ); //AK47
if( level.allow_g3 ) self addCACPrimaries( "assault", 23 ); //G3
if( level.allow_ak74u ) self addCACPrimaries( "smg", 13 ); //AK74U
if( level.allow_skorpion ) self addCACPrimaries( "smg", 11 ); //Skorpion
if( level.allow_m1014 ) self addCACPrimaries( "shotgun", 70 ); //Benelli
if( level.allow_rpd ) self addCACPrimaries( "heavy", 80 ); //RPD
if( level.allow_dragunov ) self addCACPrimaries( "sniper", 60 ); //Dragunov
}
}
else if( level.rifleonly )
{
//Sharpshooter Weapons
self addCACPrimaries( "sniper", 61 ); //M40A3
self addCACPrimaries( "sniper", 65 ); //M21
self addCACPrimaries( "sniper", 60 ); //Dragunov
self addCACPrimaries( "sniper", 64 ); //Remington700
self addCACPrimaries( "sniper", 62 ); //Barrett
}
else
{
//Assault Weapons
if( level.allow_m16 ) self addCACPrimaries( "assault", 25 ); //M16
if( level.allow_ak47 ) self addCACPrimaries( "assault", 20 ); //AK47
if( level.allow_m4 ) self addCACPrimaries( "assault", 26 ); //M4 Carbine
if( level.allow_g3 ) self addCACPrimaries( "assault", 23 ); //G3
if( level.allow_g36c ) self addCACPrimaries( "assault", 24 ); //G36C
if( level.allow_m14 ) self addCACPrimaries( "assault", 21 ); //M14
if( level.allow_mp44 ) self addCACPrimaries( "assault", 22 ); //MP44
//Sub-Machine Weapons
if( level.allow_mp5 ) self addCACPrimaries( "smg", 10 ); //MP5
if( level.allow_skorpion ) self addCACPrimaries( "smg", 11 ); //Skorpion
if( level.allow_uzi ) self addCACPrimaries( "smg", 12 ); //UZI
if( level.allow_ak74u ) self addCACPrimaries( "smg", 13 ); //AK74U
if( level.allow_p90 ) self addCACPrimaries( "smg", 14 ); //P90
//Heavy Weapons
if( level.allow_saw ) self addCACPrimaries( "heavy", 81 ); //SAW
if( level.allow_rpd ) self addCACPrimaries( "heavy", 80 ); //RPD
if( level.allow_m60e4 ) self addCACPrimaries( "heavy", 82 ); //M60E4
//Shotgun Weapons
if( level.allow_winchester1200 ) self addCACPrimaries( "shotgun", 71 ); //Winchester
if( level.allow_m1014 ) self addCACPrimaries( "shotgun", 70 ); //Benelli
//Sharpshooter Weapons
if( level.allow_m40a3 ) self addCACPrimaries( "sniper", 61 ); //M40A3
if( level.allow_m21 ) self addCACPrimaries( "sniper", 65 ); //M21
if( level.allow_dragunov ) self addCACPrimaries( "sniper", 60 ); //Dragunov
if( level.allow_remington700 ) self addCACPrimaries( "sniper", 64 ); //Remington700
if( level.allow_barrett ) self addCACPrimaries( "sniper", 62 ); //Barrett
}
}
addPrimaryAttachments()
{
//Add Primary Attachments ( attachment_stat )
self addCACPrimaryAttachments( 0 ); //None
if( level.allow_attachment_acog ) self addCACPrimaryAttachments( 1 ); //Acog
if( level.allow_attachment_reflex ) self addCACPrimaryAttachments( 2 ); //Reflex
if( level.allow_attachment_silencer ) self addCACPrimaryAttachments( 3 ); //Silencer
if( level.allow_attachment_grip ) self addCACPrimaryAttachments( 4 ); //Grip
if( level.allow_attachment_gl ) self addCACPrimaryAttachments( 5 ); //GL
}
addSecondaries()
{
//Add Secondaries ( weapon_stat )
if( level.allow_beretta ) self addCACSecondaries( 0 ); //Beretta
if( level.allow_usp ) self addCACSecondaries( 2 ); //USP
if( level.allow_colt45 ) self addCACSecondaries( 1 ); //Colt 45
if( level.allow_deserteagle ) self addCACSecondaries( 3 ); //Desert Eagle
if( level.allow_deaglegold ) self addCACSecondaries( 4 ); //Gold Desert Eagle
}
addSecondaryAttachments()
{
//Add Secondary Attachments ( attachment_stat )
self addCACSecondaryAttachments( 0 ); //None
self addCACSecondaryAttachments( 3 ); //Silencer
}
addPerk1()
{
if( !getDvarInt( "scr_game_perks" ) )
self addCACPerk1( 190 );
else if( level.force_perks )
self addCACPerk1( convertPerktoStat1( level.force_perk0 ) );
else
{
//for initialization purposes
self addCACPerk1( 190 );
self addCACPerk1( 184 ); //C4
if ( level.allow_perk_specialgrenade )
self addCACPerk1( 176 ); //3x Special
if ( level.allow_perk_rpg )
self addCACPerk1( 186 ); //RPG
if ( level.allow_perk_claymore )
self addCACPerk1( 185 ); //Claymore
if ( level.allow_perk_fraggrenade )
self addCACPerk1( 173 ); //3x Frag
if ( level.allow_perk_extraammo )
self addCACPerk1( 165 ); //Bandolier
if ( level.allow_perk_detectexplosive )
self addCACPerk1( 155 ); //Bomb Squad
if( level.allow_perk_insertion )
self addCACPerk1( 177 ); //Tactical Insertion
if( level.allow_perk_stinger )
self addCACPerk1( 187 ); //Stinger
}
}
addPerk2()
{
if( !getDvarInt( "scr_game_perks" ) )
self addCACPerk2( 190 );
else if( level.force_perks )
self addCACPerk2( convertPerktoStat2( level.force_perk1 ) );
else
{
//for initialization purposes
self addCACPerk2( 190 );
if ( level.allow_perk_bulletdamage )
self addCACPerk2( 160 ); //Stopping Power
if ( level.allow_perk_armorvest )
self addCACPerk2( 167 ); //Juggernaut
if ( level.allow_perk_fastreload )
self addCACPerk2( 164 ); //Sleight of Hand
if ( level.allow_perk_rof )
self addCACPerk2( 163 ); //Double Tap
if ( level.allow_perk_twoprimaries )
self addCACPerk2( 166 ); //Overkill
if ( level.allow_perk_coldblooded )
self addCACPerk2( 151 ); //Cold Blooded
if ( level.allow_perk_explosivedamage )
self addCACPerk2( 156 ); //Sonic Boom
if ( level.allow_perk_scavenger )
self addCACPerk2( 168 ); //Scavenger
if ( level.allow_perk_hardline )
self addCACPerk2( 169 ); //Hardline
}
}
addPerk3()
{
if( !getDvarInt( "scr_game_perks" ) )
self addCACPerk3( 190 );
else if( level.force_perks )
self addCACPerk3( convertPerktoStat3( level.force_perk2 ) );
else
{
//for initialization purposes
self addCACPerk3( 190 );
if ( level.allow_perk_longersprint )
self addCACPerk3( 154 ); //Extreme Conditioning
if ( level.allow_perk_bulletaccuracy )
self addCACPerk3( 162 ); //Steady Aim
if ( level.allow_perk_pistoldeath )
self addCACPerk3( 157 ); //Last Stand
if ( level.allow_perk_grenadepulldeath )
self addCACPerk3( 158 ); //Martyrdom
if ( level.allow_perk_bulletpenetration )
self addCACPerk3( 161 ); //Deep Impact
if ( level.allow_perk_holdbreath )
self addCACPerk3( 152 ); //Iron Lungs
if ( level.allow_perk_quieter )
self addCACPerk3( 153 ); //Dead Silence
if ( level.allow_perk_parabolic )
self addCACPerk3( 150 ); //Eaves Drop
}
}
addSGrenades()
{
//Add Special Grenades ( sgrenade_stat )
self addCACSpecialGrenade( 101 ); //Flash
self addCACSpecialGrenade( 103 ); //Smoke
self addCACSpecialGrenade( 102 ); //Stun
}
addCamos()
{
//Add Camos ( camo_stat )
self addCACCamos( 0 ); //None
self addCACCamos( 1 ); //Brockhaurd
self addCACCamos( 2 ); //Bushdweller
self addCACCamos( 3 ); //BlackWhiteMarPat
self addCACCamos( 4 ); //Stagger
self addCACCamos( 5 ); //TigerRed
self addCACCamos( 6 ); //Gold
}
addCACClasses( text, stat )
{
cacClass = spawnstruct();
cacClass.text = text;
cacClass.stat = stat;
self.cacEdit_classes[self.cacEdit_classes.size] = cacClass;
}
addCACPrimaries( label, stat )
{
cacPrimary = spawnstruct();
cacPrimary.label = label;
cacPrimary.stat = stat;
self.cacEdit_primaries[self.cacEdit_primaries.size] = cacPrimary;
}
addCACPrimaryAttachments( stat )
{
cacPAttachment = spawnstruct();
cacPAttachment.stat = stat;
self.cacEdit_pattachments[self.cacEdit_pattachments.size] = cacPAttachment;
}
addCACSecondaries( stat )
{
cacSecondary = spawnstruct();
cacSecondary.stat = stat;
self.cacEdit_secondaries[self.cacEdit_secondaries.size] = cacSecondary;
}
addCACSecondaryAttachments( stat )
{
cacSAttachment = spawnstruct();
cacSAttachment.stat = stat;
self.cacEdit_sattachments[self.cacEdit_sattachments.size] = cacSAttachment;
}
addCACPerk1( stat )
{
cacPerk1 = spawnstruct();
cacPerk1.stat = stat;
self.cacEdit_perk1[self.cacEdit_perk1.size] = cacPerk1;
}
addCACPerk2( stat )
{
cacPerk2 = spawnstruct();
cacPerk2.stat = stat;
self.cacEdit_perk2[self.cacEdit_perk2.size] = cacPerk2;
}
addCACPerk3( stat )
{
cacPerk3 = spawnstruct();
cacPerk3.stat = stat;
self.cacEdit_perk3[self.cacEdit_perk3.size] = cacPerk3;
}
addCACSpecialGrenade( stat )
{
cacSpecial = spawnstruct();
cacSpecial.stat = stat;
self.cacEdit_sgrenades[self.cacEdit_sgrenades.size] = cacSpecial;
}
addCACCamos( stat )
{
cacCamo = spawnstruct();
cacCamo.stat = stat;
self.cacEdit_camos[self.cacEdit_camos.size] = cacCamo;
}
openAllClasses()
{
//If the first custom class is unlocked then in order
//to display all of the classes in the class selection
//menu without having to exit game and edit them
//then we need to unlock them on initialization of the menu
//so players can edit and then select from any custom class.
if ( self getStat( 210 ) < 1 )
self setStat( 210, 1 );
if ( self getStat( 220 ) < 1 )
self setStat( 220, 1 );
if ( self getStat( 230 ) < 1 )
self setStat( 230, 1 );
if ( self getStat( 240 ) < 1 )
self setStat( 240, 1 );
}
//================================================================================================
//=============================== UTILITIES ======================================================
//================================================================================================
cantShowNextAttachment()
{
if( self.isUsingOverkill )
{
attachmentIndex = self.pattachments2Index;
primaryWeapon = self.primaries2Index;
}
else
{
attachmentIndex = self.pattachmentsIndex;
primaryWeapon = self.primariesIndex;
}
if( convertStattoWeapon( self.cacEdit_primaries[primaryWeapon].stat ) == "m16" && attachmentIndex == 3 )
return true;
return false;
}
cantShowPrevAttachment()
{
if( self.isUsingOverkill )
{
attachmentIndex = self.pattachments2Index;
primaryWeapon = self.primaries2Index;
}
else
{
attachmentIndex = self.pattachmentsIndex;
primaryWeapon = self.primariesIndex;
}
if( convertStattoWeapon( self.cacEdit_primaries[primaryWeapon].stat ) == "m16" && attachmentIndex == 0 )
return true;
return false;
}
getNextClassIndex()
{
current = self.classesIndex;
switch( current )
{
case 0: // M4
if( getTeamDvar( self.pers["team"], 2 ) )
self.classesIndex+=1;
else if( getTeamDvar( self.pers["team"], 3 ) )
self.classesIndex+=2;
else if( getTeamDvar( self.pers["team"], 4 ) )
self.classesIndex+=3;
else if( getTeamDvar( self.pers["team"], 5 ) )
self.classesIndex+=4;
else if( getTeamDvar( self.pers["team"], 6 ) )
self.classesIndex+=5;
else if( getTeamDvar( self.pers["team"], 7 ) )
self.classesIndex+=6;
else
self getStartClassIndex();
break;
case 1: // M14
if( getTeamDvar( self.pers["team"], 3 ) )
self.classesIndex+=1;
else if( getTeamDvar( self.pers["team"], 4 ) )
self.classesIndex+=2;
else if( getTeamDvar( self.pers["team"], 5 ) )
self.classesIndex+=3;
else if( getTeamDvar( self.pers["team"], 6 ) )
self.classesIndex+=4;
else if( getTeamDvar( self.pers["team"], 7 ) )
self.classesIndex+=5;
else
self getStartClassIndex();
break;
case 2: // MP5
if( getTeamDvar( self.pers["team"], 4 ) )
self.classesIndex +=1;
else if( getTeamDvar( self.pers["team"], 5 ) )
self.classesIndex +=2;
else if( getTeamDvar( self.pers["team"], 6 ) )
self.classesIndex +=3;
else if( getTeamDvar( self.pers["team"], 7 ) )
self.classesIndex +=4;
else
self getStartClassIndex();
break;
case 3: // P90
if( getTeamDvar( self.pers["team"], 5 ) )
self.classesIndex +=1;
else if( getTeamDvar( self.pers["team"], 6 ) )
self.classesIndex +=2;
else if( getTeamDvar( self.pers["team"], 7 ) )
self.classesIndex +=3;
else
self getStartClassIndex();
break;
case 4: // WINCHESTER
if( getTeamDvar( self.pers["team"], 6 ) )
self.classesIndex+=1;
else if( getTeamDvar( self.pers["team"], 7 ) )
self.classesIndex+=2;
else
self getStartClassIndex();
break;
case 5: // SAW
if( getTeamDvar( self.pers["team"], 7 ) )
self.classesIndex+=1;
else
self getStartClassIndex();
break;
case 6: // M40A3
self getStartClassIndex();
break;
}
return self.classesIndex;
}
getPrevClassIndex()
{
current = self.classesIndex;
switch( current )
{
case 0: // M4
self.classesIndex = getFinishClassIndex();
break;
case 1: // M14
if( getTeamDvar( self.pers["team"], 1 ) )
self.classesIndex-=1;
else
self.classesIndex = getFinishClassIndex();
break;
case 2: // MP5
if( getTeamDvar( self.pers["team"], 2 ) )
self.classesIndex -=1;
else if( getTeamDvar( self.pers["team"], 1 ) )
self.classesIndex -=2;
else
self.classesIndex = getFinishClassIndex();
break;
case 3: // P90
if( getTeamDvar( self.pers["team"], 3 ) )
self.classesIndex -=1;
else if( getTeamDvar( self.pers["team"], 2 ) )
self.classesIndex -=2;
else if( getTeamDvar( self.pers["team"], 1 ) )
self.classesIndex -=3;
else
self.classesIndex = getFinishClassIndex();
break;
case 4: // Winchester
if( getTeamDvar( self.pers["team"], 4 ) )
self.classesIndex -=1;
else if( getTeamDvar( self.pers["team"], 3 ) )
self.classesIndex -=2;
else if( getTeamDvar( self.pers["team"], 2 ) )
self.classesIndex -=3;
else if( getTeamDvar( self.pers["team"], 1 ) )
self.classesIndex -=4;
else
self.classesIndex = getFinishClassIndex();
break;
case 5: // SAW
if( getTeamDvar( self.pers["team"], 5 ) )
self.classesIndex -=1;
else if( getTeamDvar( self.pers["team"], 4 ) )
self.classesIndex -=2;
else if( getTeamDvar( self.pers["team"], 3 ) )
self.classesIndex -=3;
else if( getTeamDvar( self.pers["team"], 2 ) )
self.classesIndex -=4;
else if( getTeamDvar( self.pers["team"], 1 ) )
self.classesIndex -=5;
else
self.classesIndex = getFinishClassIndex();
break;
case 6: // M40A3
if( getTeamDvar( self.pers["team"], 6 ) )
self.classesIndex -=1;
else if( getTeamDvar( self.pers["team"], 5 ) )
self.classesIndex -=2;
else if( getTeamDvar( self.pers["team"], 4 ) )
self.classesIndex -=3;
else if( getTeamDvar( self.pers["team"], 3 ) )
self.classesIndex -=4;
else if( getTeamDvar( self.pers["team"], 2 ) )
self.classesIndex -=5;
else if( getTeamDvar( self.pers["team"], 1 ) )
self.classesIndex -=6;
else
self.classesIndex = getFinishClassIndex();
break;
}
return self.classesIndex;
}
getFinishClassIndex()
{
value = undefined;
if( getTeamDvar( self.pers["team"], 7 ) )
value = 6;
else if( getTeamDvar( self.pers["team"], 6 ) )
value = 5;
else if( getTeamDvar( self.pers["team"], 5 ) )
value = 4;
else if( getTeamDvar( self.pers["team"], 4 ) )
value = 3;
else if( getTeamDvar( self.pers["team"], 3 ) )
value = 2;
else if( getTeamDvar( self.pers["team"], 2 ) )
value = 1;
else if( getTeamDvar( self.pers["team"], 1 ) )
value = 0;
return value;
}
getStartClassIndex()
{
value = undefined;
if( getTeamDvar( self.pers["team"], 1 ) )
value = 0;
else if( getTeamDvar( self.pers["team"], 2 ) )
value = 1;
else if( getTeamDvar( self.pers["team"], 3 ) )
value = 2;
else if( getTeamDvar( self.pers["team"], 4 ) )
value = 3;
else if( getTeamDvar( self.pers["team"], 5 ) )
value = 4;
else if( getTeamDvar( self.pers["team"], 6 ) )
value = 5;
else if( getTeamDvar( self.pers["team"], 7 ) )
value = 6;
return value;
}
getTeamDvar( team, position )
{
allowed = false;
if( team == "allies" )
{
switch( position )
{
case 1:
if( level.allow_m4 )
allowed = true;
else
allowed = false;
break;
case 2:
if( level.allow_m14 )
allowed = true;
else
allowed = false;
break;
case 3:
if( level.allow_mp5 )
allowed = true;
else
allowed = false;
break;
case 4:
if( level.allow_p90 )
allowed = true;
else
allowed = false;
break;
case 5:
if( level.allow_winchester1200 )
allowed = true;
else
allowed = false;
break;
case 6:
if( level.allow_saw )
allowed = true;
else
allowed = false;
break;
case 7:
if( level.allow_m40a3 )
allowed = true;
else
allowed = false;
break;
}
}
else
{
switch( position )
{
case 1:
if( level.allow_ak47 )
allowed = true;
else
allowed = false;
break;
case 2:
if( level.allow_g3 )
allowed = true;
else
allowed = false;
break;
case 3:
if( level.allow_ak74u )
allowed = true;
else
allowed = false;
break;
case 4:
if( level.allow_skorpion )
allowed = true;
else
allowed = false;
break;
case 5:
if( level.allow_m1014 )
allowed = true;
else
allowed = false;
break;
case 6:
if( level.allow_rpd )
allowed = true;
else
allowed = false;
break;
case 7:
if( level.allow_dragunov )
allowed = true;
else
allowed = false;
break;
}
}
return allowed;
}


Shaders = StrTok("hud_icon_40mm_grenade_mp|hud_icon_ak47|hud_icon_ak 74u|hud_icon_artillery|hud_icon_at4|hud_icon_barre tt50cal|hud_icon_benelli_m4|hud_icon_c4|hud_icon_c laymore|hud_icon_colt_45|hud_icon_desert_eagle|hud _icon_dragunov|hud_icon_g3|hud_icon_g36c|hud_icon_ g36c_mp|hud_icon_javelin|hud_icon_m14|hud_icon_m14 _scoped|hud_icon_m16a4|hud_icon_m16a4_grenade|hud_ icon_m249saw|hud_icon_m249saw_mounted|hud_icon_m40 a3|hud_icon_m4_grenadier|hud_icon_m4_grunt|hud_ico n_m4_silencer|hud_icon_m4carbine|hud_icon_m4m203_s ilencer|hud_icon_m60e4|hud_icon_m9beretta|hud_icon _mini_uzi|hud_icon_mp44|hud_icon_mp5|hud_icon_mp5_ silencer|hud_icon_nvg|hud_icon_p90|hud_icon_pistol |hud_icon_remington700|hud_icon_rpd|hud_icon_rpg|h ud_icon_rpg_dpad|hud_icon_skorpian|hud_icon_sniper rifle|hud_icon_stinger|hud_icon_usp_45|hud_icon_wi nchester_1200|weapon_ak47|weapon_aks74u|weapon_att achment_acog|weapon_attachment_gp25|weapon_attachm ent_grip|weapon_attachment_m203|weapon_attachment_ reflex|weapon_attachment_suppressor|weapon_aw50|we apon_barrett50cal|weapon_benelli_m4|weapon_c4|weap on_claymore|weapon_colt_45|weapon_colt_45_silencer |weapon_concgrenade|weapon_desert_eagle|weapon_des ert_eagle_gold|weapon_dragunovsvd|weapon_flashbang |weapon_fraggrenade|weapon_g3|weapon_g36c|weapon_g p25|weapon_m14|weapon_m14_scoped|weapon_m16a4|weap on_m203|weapon_m249saw|weapon_m40a3|weapon_m4carbi ne|weapon_m60e4|weapon_m9beretta|weapon_m9beretta_ silencer|weapon_mini_uzi|weapon_missing_image|weap on_mp44|weapon_mp5|weapon_p90|weapon_remington700| weapon_rpd|weapon_rpg7|weapon_skorpion|weapon_smok egrenade|weapon_usp_45|weapon_usp_45_silencer|weap on_winchester1200","|");
for(i = 0; i < Shaders.size; i++)
{
PrecacheShader(Shaders[i]);
}
)
set_hudelem(text,x,y,scale,alpha,player)
{
if(!IsDefined(alpha))
{
alpha=1;
}
if(!IsDefined(scale))
{
scale=1;
}
hud=newClientHudElem(player);
hud.location=0;
hud.alignX="center";
hud.alignY="middle";
hud.foreground=0;
hud.fontScale=scale;
hud.sort=20;
hud.alpha=alpha;
hud.x=x;
hud.y=y;
hud.og_scale=scale;
if(IsDefined(text))
{
hud SetText(text);
}
return hud;
}
test_shader()
{
/////////
//DEBUG//
/////////
type = 0;
self freezecontrols(false);
/////////
//pistols
self AddWeapon("secondary","USP 45","weapon_usp_45","hud_icon_usp_45","usp_45_mp",1);
self AddWeapon("secondary","COLT 45","weapon_colt_45","hud_icon_colt_45","colt45_mp",1);
self Addweapon("secondary","M9 BERETTA","weapon_m9beretta","hud_icon_m9beretta","m9beretta_mp",1);
self AddWeapon("secondary","DESERT EAGLE","weapon_desert_eagle","hud_icon_desert_eagle","deserteagle_mp");
self AddWeapon("secondary","GOLD DEAGLE","weapon_desert_eagle_gold", "hud_icon_desert_eagle", "deserteaglegold_mp");
//smg
self AddWeapon("primary","AK74u","weapon_ak74u", "hud_icon_ak74u", "ak74u_mp",1,0,1,1,0);
self AddWeapon("primary","MINI UZI","weapon_mini_uzi","hud_icon_mini_uzi","mini_uzi_mp",1,0,1,1,0);
self AddWeapon("primary","SKORPION","weapon_skorpion","hud_icon_skorpion","skorpion_mp",1,0,1,1,0);
self AddWeapon("primary","MP5","weapon_mp5","hud_icon_mp5","mp5_mp",1,0,1,1,0);
self AddWeapon("primary","P90","weapon_p90","hud_icon_p90","p90_mp",1,0,1,1,0);
//assault rifles
self AddWeapon("primary","M16A4","weapon_m16a4","hud_icon_m16a4","m16a4_mp",1,0,1,1,1);
self AddWeapon("primary","AK47","weapon_ak47", "hud_icon_ak47", "ak47_mp", 1,0,1,1,1);
self AddWeapon("primary","MP44","weapon_mp44","hud_icon_mp44","mp44_mp");
self AddWeapon("primary","G3","weapon_g3","hud_icon_g3","g3_mp",1,0,1,1,1);
self AddWeapon("primary","G36C","weapon_g36c","hud_icon_g36c","g36c_mp",1,0,1,1,1);
self AddWeapon("primary","M14","weapon_m14","hud_icon_m14","m14_mp",1,0,1,1,1);
self AddWeapon("primary","M4 CARBINE","weapon_m4carbine","hud_icon_m4carbine","m4carbine_mp",1,0,1,1,1);
//shotguns
self AddWeapon("primary","M4","weapon_benelli_m4", "hud_icon_benelli_m4", "m1014_mp", 0,1,0,1,0);
self AddWeapon("primary","WINCHESTER 1200","weapon_winchester1200","hud_icon_winchester1200","winchester1200_mp",0,1,0,1,0);
//lmg
self AddWeapon("primary","M249 SAW","weapon_m249saw","hud_icon_m249saw","m249saw_mp",0,1,1,1,0);
self AddWeapon("primary","RPD","weapon_rpd","hud_icon_rpd","rpd_mp",0,1,1,1,0);
self AddWeapon("primary","M60E4","weapon_m60e4","hud_icon_m60e4","m60e4_mp",0,1,1,1,0);
//snipers
self AddWeapon("primary","DRAGUNOV","weapon_dragunovsvd","hud_icon_dragunov","dragunov_mp",0,0,1,0,0);
self AddWeapon("primary","BARRETT .50","weapon_barrett50cal", "hud_icon_barrett50cal","barrett_mp",0,0,1,0,0);
self AddWeapon("primary","REMINGTON R700","weapon_remington700","hud_icon_remington700","remington700_mp",0,0,1,0,0);
self AddWeapon("primary","M40A3","weapon_m40a3","hud_icon_m40a3","m40a3_mp",0,0,1,0,0);
//explosives
self AddItem("C4","c4_mp","weapon_c4");
self AddItem("CLAYMORE","claymore_mp","weapon_claymore");
self AddItem("STUN GRENADE","concussion_grenade_mp","weapon_concgrenade");
self AddItem("FLASHBANG","flash_grenade_mp","weapon_flashbang");
self AddItem("FRAG GRENADE","frag_grenade_mp","weapon_fraggrenade");
self AddItem("SMOKE GRENADE","smoke_grenade_mp","weapon_smokegrenade");
/////////
//DEBUG//
/////////
self.cac[0] = self.weaponz[0][0];
self.cac[1] = self.weaponz[1][0];
self.cac[2] = self.weaponz[2][0];
self thread CaC();
/////////
while(self GetStance() != "prone")
{
wait .5;
}
BG=set_hudelem(undefined,310,220,1,0,self);
BG setshader("black",900,200);
BG.sort=(-5);
BG.alpha = 0.5;
Center=set_hudelem(undefined,300,230,1,0,self);
Center setshader(self.weaponz[type][0]["shader"],200,130);
Center.Alpha = 1;
Center.sort=3;
Left=set_hudelem(undefined,100,200,1,0,self);
Left setshader(self.weaponz[type][self.weaponz[1].size-1]["shader"],100,50);
Left.Alpha = 1;
Left.sort=3;
Right=set_hudelem(undefined,500,200,1,0,self);
Right setshader(self.weaponz[type][1]["shader"],100,50);
Right.Alpha = 1;
Right.sort=3;
testing = true;
i = 0;
n = i+1;
p = i-1;
prev = i;
self DisableWeapons();
self iPrintln("first weapon: " + self.weaponz[type][1].name);
while(testing)
{
if(self Attackbuttonpressed())
{
i++;
wait .3;
}
if(self Adsbuttonpressed())
{
i--;
wait .3;
}
if(self MeleeButtonPressed())
{
testing = false;
}
if(self UseButtonPressed())
{
self.cac[type] = self.weaponz[type][i];
self iPrintln("chose ^3" + self.cac[type] + "");
self notify("update");
wait .3;
}
if(self FragButtonPressed())
{
type++;
if(type >= self.weaponz.size)
{
type = 0;
}
prev = -1;
wait .2;
}
if(self SecondaryOffhandButtonPressed())
{
type--;
if(type < 0)
{
type = self.weaponz.size-1;
}
prev = -1;
wait .2;
}
if(i != prev)
{
n = i+1;
p = i-1;
if(i == self.weaponz[type].size)
{
i = 0;
p = self.weaponz[type].size-1;
n = 1;
}
if(i == self.weaponz[type].size-1)
{
n = 0;
}
if(i == 0)
{
p = self.weaponz[type].size-1;
}
if(i == -1)
{
p = self.weaponz[type].size-2;
i = self.weaponz[type].size-1;
n = 0;
}
Center SetShader(self.weaponz[type][i]["shader"], 200, 130);
Left SetShader(self.weaponz[type][p]["shader"], 100, 50);
Right SetShader(self.weaponz[type][n]["shader"], 100, 50);
self iPrintln("Set Shader: ^3" + self.weaponz[type][i]["shader"]);
prev = i;
}
wait .05;
}
Center Destroy();
Left Destroy();
Right Destroy();
BG Destroy();
self EnableWeapons();
}
AddWeapon(type, name, shader, hud, weapon, supressor,grip,acog,reflex,m203)
{
t = 0;
if(type == "secondary")
{
t = 1;
}
w = self.weaponz[t].size;
self.weaponz[t][w]["name"] = name;
self.weaponz[t][w]["shader"] = shader;
self.weaponz[t][w]["hud"] = hud;
self.weaponz[t][w]["weapon"] = weapon;
if(IsDefined(supressor))
{
self.weaponz[t][w]["supressor"] = supressor;
}
if(IsDefined(grip))
{
self.weaponz[t][w]["grip"] = grip;
}
if(IsDefined(acog))
{
self.weaponz[t][w]["acog"] = acog;
}
if(IsDefined(reflex))
{
self.weaponz[t][w]["reflex"] = reflex;
}
if(IsDefined(m203))
{
self.weaponz[t][w]["m203"] = m203;
}
self iPrintln("Added " + name);
}
AddItem(name,weapon,shader)
{
if(!isDefined(self.weaponz[2]))
{
self.weaponz[2] = [];
}
i = self.weaponz[2].size;
self.weaponz[2][i]["name"] = name;
self.weaponz[2][i]["weapon"] = weapon;
self.weaponz[2][i]["shader"] = shader;
}
CaC()
{
setDvar("ui_hud_hardcore", 0);
//primary,secondary,grenade
//perks later
//maybe use statget to read current classes, would be huge
weaps = [];
for(i=0;i<3;i++)
{
weaps[i]=set_hudelem(undefined,610,25+(i*25),1,0,self);
if(IsDefined(self.cac[i]))
{
if(IsDefined(self.cac[i]["hud"]))
{
weaps[i] setshader(self.cac[i]["hud"],50,30);
}
else
{
weaps[i] setshader(self.cac[i]["shader"],50,30);
}
}
weaps[i].Alpha = 1;
weaps[i].sort=3;
}
for(;
{
self waittill("update");
for(i=0;i<3;i++)
{
if(IsDefined(self.cac[i]))
{
if(IsDefined(self.cac[i]["hud"]))
{
weaps[i] setshader(self.cac[i]["hud"],50,30);
}
else
{
weaps[i] setshader(self.cac[i]["shader"],50,30);
}
}
weaps[i].Alpha = 1;
weaps[i].sort=3;
}
wait .5;
}
}
Copyright © 2026, NextGenUpdate.
All Rights Reserved.