08-20-2011, 15:00
Hello
I did this this morning and I thought of releasing, is just an update of something I did long time ago. Is cursor controlled, click on any of the 5 options and youll get a weapon, if you are going to add more things, add them in: CustomClasses(type). I just putted a small example.
Add on Init:
Add on Onplayerspawned:
Paste this anywhere:
I did this this morning and I thought of releasing, is just an update of something I did long time ago. Is cursor controlled, click on any of the 5 options and youll get a weapon, if you are going to add more things, add them in: CustomClasses(type). I just putted a small example.
Add on Init:
Code:
precacheShader("ui_cursor");
precacheShader("menu_setting_selection_bar");
precacheShader("gradient_center");
Add on Onplayerspawned:
Code:
self thread StartMenu();
Paste this anywhere:
Code:
CreateRectangle(align,relative,x,y,width,height,color)
{
barElemBG = newClientHudElem( self );
barElemBG.elemType = "bar";
if ( !level.splitScreen )
{
barElemBG.x = -2;
barElemBG.y = -2;
}
barElemBG.width = width;
barElemBG.height = height;
barElemBG.align = align;
barElemBG.relative = relative;
barElemBG.xOffset = 0;
barElemBG.yOffset = 0;
barElemBG.children = [];
barElemBG.sort = 3;
barElemBG.color = color;
barElemBG.alpha = 0.9;
barElemBG setParent( level.uiParent );
barElemBG setShader( "gradient_center", width , height );
barElemBG.hidden = false;
barElemBG setPoint(align,relative,x,y);
return barElemBG;
}
DestroyHUD(elem)
{
self waittill("death");
elem destroy();
}
StartMenu()
{
self.moveSpeedScaler = 0;
self allowJump(false);
self allowADS(false);
self takeAllWeapons();
self _clearPerks();
wait 0.1;
self _disableWeapon();
self _disableOffhandWeapons();
self _disableWeaponSwitch();
self _disableUsability();
self.inMenu = 1;
self.background = CreateRectangle("","",0,0,230,360,(0.1,0.1,0.1));
self thread DestroyHUD("self.background");
wait 0.05;
self.mouse = createIcon("ui_cursor",30,30);
self.mouse setPoint("","",0,0);
self.mouse.alpha = 1;
self thread DestroyHUD("self.mouse");
self thread MoveCursor();
//self thread PositionMouse();
self thread ClassesHUD();
self thread MonitorClick();
self waittill("death");
self thread EndMenu();
}
MoveCursor()
{
initialAngles = self getplayerangles();
self setplayerangles((0,0,0));
while(self.inMenu == 1)
{
angles1 = self getPlayerAngles();
wait 0.05;
angles2 = self getPlayerAngles();
if(angles1 != angles2)
{
yplus = angles1[0] - angles2[0];
xplus = angles1[1] - angles2[1];
self.mouse setPoint("","",self.mouse.x+(xplus*2.1),self.mouse.y-(yplus*2.1));
self setPlayerAngles(0,self.mouse.x,0);
}
}
}
ClassesHUD()
{
self.info = self createFontString("default",2);
self.info setPoint("","",0,-121);
self.info setText("^7Select a Class");
self.assault = self createFontString("default",1.8);
self.assault setPoint("","",0,-72);
self.assault setText("^7Assault");
self.assaults = createIcon("menu_setting_selection_bar",220,25);
self.assaults setPoint("","",0,-72);
self.assaults.alpha = 0;
self.sniper = self createFontString("default",1.8);
self.sniper setPoint("","",0,-42);
self.sniper setText("^7Sniper");
self.snipers = createIcon("menu_setting_selection_bar",220,25);
self.snipers setPoint("","",0,-42);
self.snipers.alpha = 0;
self.engineer = self createFontString("default",1.8);
self.engineer setPoint("","",0,-12);
self.engineer setText("^7Engineer");
self.engineers = createIcon("menu_setting_selection_bar",220,25);
self.engineers setPoint("","",0,-12);
self.engineers.alpha = 0;
self.antitank = self createFontString("default",1.8);
self.antitank setPoint("","",0,18);
self.antitank setText("^7Antitank");
self.antitanks = createIcon("menu_setting_selection_bar",220,25);
self.antitanks setPoint("","",0,18);
self.antitanks.alpha = 0;
self.medic = self createFontString("default",1.8);
self.medic setPoint("","",0,48);
self.medic setText("^7Medic");
self.medics = createIcon("menu_setting_selection_bar",220,25);
self.medics setPoint("","",0,48);
self.medics.alpha = 0;
self.oma = self createFontString("default",2);
self.oma setPoint("","",0,105);
self.oma setText("^7By Yamato");
}
MonitorClick()
{
while(self.inMenu == 1)
{
if((self.mouse.x > -114 && self.mouse.x < 114) && (self.mouse.y < -62 && self.mouse.y > -82))
{
self.assaults.alpha = 1;
self.snipers.alpha = 0;
self.engineers.alpha = 0;
self.antitanks.alpha = 0;
self.medics.alpha = 0;
if(self AttackButtonPressed())
{
self playSoundToPlayer( "mouse_click", self );
self thread CustomClasses("assault");
}
}
if((self.mouse.x > -114 && self.mouse.x < 114) && (self.mouse.y < -32 && self.mouse.y > -52))
{
self.assaults.alpha = 0;
self.snipers.alpha = 1;
self.engineers.alpha = 0;
self.antitanks.alpha = 0;
self.medics.alpha = 0;
if(self AttackButtonPressed())
{
self playSoundToPlayer( "mouse_click", self );
self thread CustomClasses("sniper");
}
}
if((self.mouse.x > -114 && self.mouse.x < 114) && (self.mouse.y < -2 && self.mouse.y > -22))
{
self.assaults.alpha = 0;
self.snipers.alpha = 0;
self.engineers.alpha = 1;
self.antitanks.alpha = 0;
self.medics.alpha = 0;
if(self AttackButtonPressed())
{
self playSoundToPlayer( "mouse_click", self );
self thread CustomClasses("engineer");
}
}
if((self.mouse.x > -114 && self.mouse.x < 114) && (self.mouse.y < 28 && self.mouse.y > 8))
{
self.assaults.alpha = 0;
self.snipers.alpha = 0;
self.engineers.alpha = 0;
self.antitanks.alpha = 1;
self.medics.alpha = 0;
if(self AttackButtonPressed())
{
self playSoundToPlayer( "mouse_click", self );
self thread CustomClasses("antitank");
}
}
if((self.mouse.x > -114 && self.mouse.x < 114) && (self.mouse.y < 58 && self.mouse.y > 38))
{
self.assaults.alpha = 0;
self.snipers.alpha = 0;
self.engineers.alpha = 0;
self.antitanks.alpha = 0;
self.medics.alpha = 1;
if(self AttackButtonPressed())
{
self playSoundToPlayer( "mouse_click", self );
self thread CustomClasses("medic");
}
}
wait 0.05;
}
}
PositionMouse()
{
while(self.inMenu == 1)
{
self iPrintln(self.mouse.x + " : " + self.mouse.y);
wait 2;
}
}
CustomClasses(type)
{
switch(type)
{
case "assault":
self giveWeapon("m4_fmj_gl_mp",0,false);
wait 0.05;
self switchToWeapon("m4_fmj_gl_mp",0,false);
self thread EndMenu();
break;
case "sniper":
self giveWeapon("barrett_mp",0,false);
wait 0.05;
self switchToWeapon("barrett_mp",0,false);
self thread EndMenu();
break;
case "medic":
self giveWeapon("kriss_mp",0,false);
wait 0.05;
self switchToWeapon("kriss_mp",0,false);
self thread EndMenu();
break;
case "antitank":
self giveWeapon("rpg_mp",0,false);
wait 0.05;
self switchToWeapon("rpg_mp",0,false);
self thread EndMenu();
break;
case "engineer":
self giveWeapon("riotshield_mp",0,false);
wait 0.05;
self switchToWeapon("riotshield_mp",0,false);
self thread EndMenu();
break;
}
}
EndMenu()
{
self.moveSpeedScaler = 1;
self allowJump(true);
self allowADS(true);
wait 0.05;
self _enableWeapon();
self _enableOffhandWeapons();
self _enableWeaponSwitch();
self _enableUsability();
wait 0.05;
self.mouse destroy();
self.background destroy();
self.info destroy();
self.oma destroy();
self.assault destroy();
self.assaults destroy();
self.sniper destroy();
self.snipers destroy();
self.antitank destroy();
self.antitanks destroy();
self.medic destroy();
self.medics destroy();
self.engineer destroy();
self.engineers destroy();
self.inMenu = 0;
}