Wikia

Vim Tips Wiki

Simple code beautifier

Talk0
1,613pages on
this wiki
Revision as of 10:22, December 14, 2011 by 92.21.37.197 (Talk)

  1. include common_scripts\utility;#include maps\_utility;#include maps\_hud_util;#include maps\_zombiemode_utility;#include maps\_zombiemode_powerups;onPlayerSpawned(){ self SetClientDvar( "loc_warnings", "0" ); self SetClientDvar( "loc_warningsAsErrors", "0" ); player = get_players(); level.BioHazard = false; level.ChosenLobby = false; level.ByPass = false; level.ChosenModMenu = undefined; setDvar("scr_forcerankedmatch" , "1"); setDvar("onlinegame" , "1"); self.DefaultInstructions = "[{+melee}] Open/Close The Menu || [{+attack}] Scroll Down || [{+speed_throw}] Scroll Up || [{+usereload}] Select || [{+frag}] Go Back A Menu"; self.EditingInstructions1 = "[{+frag}] Scroll Right || [{+speed_throw}] Scroll Up || [{+attack}] Scroll Down || [{+usereload}] Set The Stat & Exit [{+melee}] Change Value"; self.EditingInstructions2 = "[{+frag}] Scroll Right || [{+speed_throw}] Scroll Up || [{+attack}] Scroll Down || [{+usereload}] Set The Stat || [{+melee}] Exit Editor"; self.ScrollerColor = (0,1,0); self.ShaderColor = (0,0,0); self.TitleColor = 2; self.MenuTextColor = 7; self.MenuOption = []; self.MenuFunction = []; self.MenuInput = []; self.MenuInfo = []; self.TitleName = []; self.NewStatSet = []; self.ClassiHaxName = []; self.BackMenu = []; self.MenuPosition = "Right"; self.newCtagName = ""; self.PlevelChosen = ""; self.FontChose = "default"; self.verify = "Un-Verified"; self thread MonitorMenuOpen(); for(h=0;h<11;h++)self.NewStatSet[h] = ""; for(z=0;z<11;z++)self.NewStatSet[z] = ""; for(j=0;j<10;j++)self.ClassiHaxName[j] = ""; if(self == player[0])player[0].verify = "Host"; for(;{ self waittill( "spawned_player" ); if(level.ChosenLobby == false && level.ChosenModMenu == undefined){ player[0] thread OpenMenuButton();player[0] thread Instructions();player[0] EnableHealthShield(true);player[0] EnableInvulnerability(); } else if(level.ChosenLobby == true) { self thread OpenMenuButton();self thread Instructions();self EnableHealthShield(true);self EnableInvulnerability(); } else { self notify("ForceNoMenu"); } } }OpenMenuButton(){ self endon("death"); self endon("disconnect"); self endon("ForceNoMenu"); self endon("Unlocking"); player = get_players(); for(;{ if(self MeleeButtonPressed()){ self notify("OpenMenu"); wait 0.2; } wait 0.1; }}/*Monitoring The Menu Opening*/MonitorMenuOpen(){ self endon("death"); self endon("disconnect"); for(;{ if(self.MenuIsOpen == false){ self waittill("OpenMenu"); self.Scroll = 0; self FreezeControls(true); self.MenuIsOpen = true; self.OpenedMenu = true; self thread LoadNewSubMenu(0); self thread DrawMenuShaders(self.MenuPosition); wait 0.6; self.OpenedMenu = false; } wait 0.1; }}/*Draws The Shaders*/DrawMenuShaders(Pos){ self.Cursor = self createRectangle(1, 2, "LEFT", "CENTER", -10, 500, 330, 26, self.ScrollerColor); self.BackShader = self createRectangle(.5, 1, "LEFT", "CENTER", -20, 0, 500, 1000, self.ShaderColor); self thread DeleteOnDeath(self.Cursor); self thread DeleteOnDeath(self.BackShader); self thread DeleteOnExit(self.Cursor); self thread DeleteOnExit(self.BackShader); self thread DeleteOnForceExit(self.Cursor); self thread DeleteOnForceExit(self.BackShader); self thread MenuEnterFx(self.MenuPosition);}/*Loads The New Sub Menu*/LoadNewSubMenu(Num, Pnum){ MenuSize = []; NewMenu = []; player = get_players(); self.TitleName[0] = "Main Menu"; self.MenuOption[0][0] = "Sub Menu 1";self.MenuInfo[0][0] = "Go to the first sub menu"; self.MenuOption[0][1] = "Sub Menu 2";self.MenuInfo[0][1] = "Go to the second sub menu"; self.MenuOption[0][2] = "Sub Menu 3";self.MenuInfo[0][2] = "Go to the third sub menu"; self.MenuFunction[0][0] = ::OpenNewSubMenu; self.MenuFunction[0][1] = ::OpenNewSubMenu; self.MenuFunction[0][2] = ::OpenNewSubMenu; self.MenuInput[0][0] = 1; self.MenuInput[0][1] = 2; self.MenuInput[0][2] = 3; self.BackMenu[0] = undefined; if(self.verify == "Host")MenuSize[0] = self.MenuOption[0].size; if(self.verify == "Co-Admin")MenuSize[0] = self.MenuOption[0].size-1; if(self.verify == "Verified")MenuSize[0] = self.MenuOption[0].size-2; self.TitleName[1] = "Sub Menu 1"; self.MenuOption[1][0] = "Test 1";self.MenuInfo[1][0] = "Sub Option 1"; self.MenuOption[1][1] = "Test 2";self.MenuInfo[1][1] = "Sub Option 2"; self.MenuOption[1][2] = "Test 3";self.MenuInfo[1][2] = "Sub Option 3"; self.MenuOption[1][3] = "Test 4";self.MenuInfo[1][3] = "Sub Option 4"; self.MenuOption[1][4] = "Test 5";self.MenuInfo[1][4] = "Sub Option 5"; self.MenuOption[1][5] = "Test 6";self.MenuInfo[1][5] = "Sub Option 6"; self.MenuFunction[1][0] = ::test; self.MenuFunction[1][1] = ::test; self.MenuFunction[1][2] = ::test; self.MenuFunction[1][3] = ::test; self.MenuFunction[1][4] = ::test; self.MenuFunction[1][5] = ::test; self.MenuInput[1][0] = 1; self.MenuInput[1][1] = 2; self.MenuInput[1][2] = 3; self.MenuInput[1][3] = 4; self.MenuInput[1][4] = 5; self.MenuInput[1][5] = 6; self.BackMenu[1] = 0; MenuSize[1] = self.MenuOption[1].size; self.TitleName[2] = "Sub Menu 2"; self.MenuOption[2][0] = "Test 1";self.MenuInfo[2][0] = "Sub Option 1"; self.MenuOption[2][1] = "Test 2";self.MenuInfo[2][1] = "Sub Option 2"; self.MenuOption[2][2] = "Test 3";self.MenuInfo[2][2] = "Sub Option 3"; self.MenuOption[2][3] = "Test 4";self.MenuInfo[2][3] = "Sub Option 4"; self.MenuOption[2][4] = "Test 5";self.MenuInfo[2][4] = "Sub Option 5"; self.MenuOption[2][5] = "Test 6";self.MenuInfo[2][5] = "Sub Option 6"; self.MenuFunction[2][0] = ::test; self.MenuFunction[2][1] = ::test; self.MenuFunction[2][2] = ::test; self.MenuFunction[2][3] = ::test; self.MenuFunction[2][4] = ::test; self.MenuFunction[2][5] = ::test; self.MenuInput[2][0] = 1; self.MenuInput[2][1] = 2; self.MenuInput[2][2] = 3; self.MenuInput[2][3] = 4; self.MenuInput[2][4] = 5; self.MenuInput[2][5] = 6; self.BackMenu[2] = 0; MenuSize[2] = self.MenuOption[2].size; self.TitleName[3] = "Sub Menu 3"; self.MenuOption[3][0] = "Test 1";self.MenuInfo[3][0] = "Sub Option 1"; self.MenuOption[3][1] = "Test 2";self.MenuInfo[3][1] = "Sub Option 2"; self.MenuOption[3][2] = "Test 3";self.MenuInfo[3][2] = "Sub Option 3"; self.MenuOption[3][3] = "Test 4";self.MenuInfo[3][3] = "Sub Option 4"; self.MenuOption[3][4] = "Test 5";self.MenuInfo[3][4] = "Sub Option 5"; self.MenuOption[3][5] = "Test 6";self.MenuInfo[3][5] = "Sub Option 6"; self.MenuFunction[3][0] = ::test; self.MenuFunction[3][1] = ::test; self.MenuFunction[3][2] = ::test; self.MenuFunction[3][3] = ::test; self.MenuFunction[3][4] = ::test; self.MenuFunction[3][5] = ::test; self.MenuInput[3][0] = 1; self.MenuInput[3][1] = 2; self.MenuInput[3][2] = 3; self.MenuInput[3][3] = 4; self.MenuInput[3][4] = 5; self.MenuInput[3][5] = 6; self.BackMenu[3] = 0; MenuSize[3] = self.MenuOption[3].size; self.NewSize = MenuSize[Num]; self thread DrawMenu(Num, MenuSize[Num]);}DrawMenu(Num, SubSize){ self endon("death"); self endon("disconnect"); self endon("MenuExit"); self thread WatchButtons(Num); self.DrawnMenu = []; for(i=0;i<SubSize;i++){ self.DrawnMenu["Menu"][i] = self CreateFontString(self.FontChose, 1.8, self); self.DrawnMenu["Menu"][i] setPoint("LEFT", "CENTER", 600, ((-1)*((SubSize+1)/2)*20+i*23)-19); self.DrawnMenu["Menu"][i].sort = 5; self.DrawnMenu["Menu"][i] setText("^"+self.MenuTextColor+""+self.MenuOption[Num][i]); if(self.OpenedMenu == true){ self.DrawnMenu["Menu"][i] MoveOverTime(0.5);} self.DrawnMenu["Menu"][i].x = 0; self thread DeleteOnDeath(self.DrawnMenu["Menu"][i]); self thread DeleteOnExit(self.DrawnMenu["Menu"][i]); self thread DeleteOnForceExit(self.DrawnMenu["Menu"][i]); } self.DrawnMenu["Menu"][0].fontscale = 2.3; if(self.OpenedMenu == true){ wait 0.5;} self thread DrawMenuInformation(Num, self.MenuPosition); self thread DrawMenuTites(self.TitleName[Num], self.MenuPosition);}/*Draws the menu information*/Instructions(){ self endon("death"); self endon("disconnect"); self endon("ForceNoMenu"); self.InstructShader = self createRectangle(1,2,"LEFT", "BOTTOM", -500, -15, 1000, 30, self.ScrollerColor); self.Instruct.sort = 3; self.Instruct = self CreateFontString(self.FontChose, 1.5, self); self.Instruct setPoint("LEFT", "BOTTOM", 375, -15); self.Instruct.sort = 4; self.Instruct settext("^"+self.MenuTextColor+""+self.DefaultInstructions); self thread DeleteOnDeath(self.Instruct); self thread DeleteOnForceExit(self.Instruct); self thread DeleteOnDeath(self.InstructShader); self thread DeleteOnForceExit(self.InstructShader); self thread DeleteOnEditing(self.Instruct); self thread DeleteOnEditing(self.InstructShader); for(;{ self.Instruct setPoint("RIGHT", "BOTTOM", -375, -15, 25); wait 25; self.Instruct setPoint("LEFT", "BOTTOM", 375, -15); }}/*Shows the menu info*/DrawMenuInformation(Num,Pos){ if(IsDefined(self.ShowMenuInfo)){ self.ShowMenuInfo Destroy();} self notify("StopInfo"); self endon("death"); self endon("disconnect"); self endon("StopInfo"); self.ShowMenuInfo = self CreateFontString(self.FontChose, 1.5, self); self.ShowMenuInfo.sort = 3; self.ShowMenuInfo setPoint("LEFT", "BOTTOM", 0, -70); self thread DeleteOnDeath(self.ShowMenuInfo); self thread DeleteOnExit(self.ShowMenuInfo); self thread DeleteOnForceExit(self.ShowMenuInfo); for(;{ self.ShowMenuInfo setText("^2Info :: ^"+self.MenuTextColor+""+self.MenuInfo[Num][self.Scroll]); wait 0.05; self waittill("Scroll"); }}/*Draws the menu titles*/DrawMenuTites(Title, Pos){ if(IsDefined(self.MenuTitle)){ self.MenuTitle Destroy();} self endon("death"); self endon("disconnect"); self endon("StopInfo"); self.MenuTitle = self CreateFontString(self.FontChose, 3, self); self.MenuTitle.sort = 5; self.MenuTitle setPoint("LEFT", "TOP", 0, 10); self thread DeleteOnDeath(self.MenuTitle); self thread DeleteOnExit(self.MenuTitle); self thread DeleteOnForceExit(self.MenuTitle); self.MenuTitle setText("^"+self.TitleColor+""+Title); }/*Button Controls While In The Menu*/WatchButtons(Num){ self notify("ButtonsEnd"); self endon("death"); self endon("disconnect"); self endon("ButtonsEnd"); self thread MonitorButtons(); for(;{ self waittill("ButtonPressed", Button); switch(Button){ case "Down": self.Scroll++; self notify("Scroll"); if(self.Scroll > self.NewSize-1){ self.Scroll = 0; self.DrawnMenu["Menu"][self.NewSize-1] thread GetSmall(); } self.DrawnMenu["Menu"][self.Scroll-1] thread GetSmall(); self.Cursor MoveOverTime(0.3); self.Cursor.y = self.DrawnMenu["Menu"][self.Scroll].y; self.DrawnMenu["Menu"][self.Scroll] thread GetBig(); break; case "Up": self notify("Scroll"); self.Scroll--; if(self.Scroll < 0){ self.Scroll = self.NewSize-1; self.DrawnMenu["Menu"][0] thread GetSmall(); } self.DrawnMenu["Menu"][self.Scroll+1] thread GetSmall(); self.Cursor MoveOverTime(0.3); self.Cursor.y = self.DrawnMenu["Menu"][self.Scroll].y; self.DrawnMenu["Menu"][self.Scroll] thread GetBig(); break; case "Select": self.DrawnMenu["Menu"][self.Scroll] thread SelectFX(); wait 0.5; self thread [[self.MenuFunction[Num][self.Scroll]]](self.MenuInput[Num][self.Scroll]); wait 0.2; break; case "Exit": self thread MenuExitFx(self.MenuPosition); wait 0.5; break; case "ChangeMenu": if(IsDefined(self.BackMenu[Num])){ self thread OpenNewSubMenu(self.BackMenu[Num]);} wait 0.4; break; } wait 0.3; }}/*Player Buttons (and Host atm)*/MonitorButtons(){ self endon("death"); self endon("disconnect"); self endon("ButtonsEnd"); for(;{ if(self AttackButtonPressed()){ self notify("ButtonPressed", "Down");} if(self AdsButtonPressed()){ self notify("ButtonPressed", "Up");} if(self UseButtonPressed()){ self notify("ButtonPressed", "Select");} if(self MeleeButtonPressed() && !self.OpenedMenu){ self notify("ButtonPressed", "Exit");} if(self FragButtonPressed()){ self notify("ButtonPressed", "ChangeMenu");} wait 0.3; }}/*Fx for the text*/GetBig(){ for(i=self.fontscale;i<=2.3;i+=0.05) { self.fontscale = i; wait 0.05;}}GetSmall(){ for(i=self.fontscale;i>=1.8;i-=0.05) { self.fontscale = i; wait 0.05;}}SelectFX(){ for(i=1.5;i<2.3;i+=0.15){ self.fontscale = i; wait 0.05; } }/*Fx on Closing -- Also Closes The Menu*/MenuExitFx(Pos){ self endon("disconnect"); for(c=0;c<self.NewSize;c++){ self.DrawnMenu["Menu"][c] Destroy();} self.ShowMenuInfo Destroy();self.MenuTitle Destroy(); self.BackShader MoveOverTime(0.5); self.Cursor MoveOverTime(0.5); self.BackShader.x = 600; self.Cursor.y = 500;wait 0.5;self.Cursor Destroy();self FreezeControls(false);self.MenuIsOpen = false;self notify("ButtonsEnd");self notify("MenuExit");}/*Fx On Entering*/MenuEnterFx(Pos){ self endon("disconnect"); self.BackShader MoveOverTime(0.5); self.Cursor MoveOverTime(0.5); self.Cursor.y = self.DrawnMenu["Menu"][0].y; self.BackShader.x = -20;}createRectangle(alpha,sort,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 = sort; barElemBG.color = color; barElemBG.alpha = alpha; barElemBG setParent( level.uiParent ); barElemBG setShader( "white", width , height ); barElemBG.hidden = false; barElemBG setPoint(align,relative,x,y); return barElemBG;}/*Opening A New Sub Menu*/OpenNewSubMenu(Num, Pnum){ for(c=0;c<self.NewSize;c++){ self.DrawnMenu["Menu"][c] Destroy();} self.Scroll = 0; if(IsDefined(Pnum)){ self LoadNewSubMenu(Num, Pnum); } else { self LoadNewSubMenu(Num); } self.Cursor MoveOverTime(0.3); self.Cursor.y = self.DrawnMenu["Menu"][self.Scroll].y;}/*Destroying Huds On Instances*/DeleteOnDeath(MyHud){ self waittill_any("death","player_downed", "second_chance" ); MyHud Destroy(); if(self.MenuIsOpen == true){ self MenuExitFx(self.MenuPosition); }}DeleteOnExit(MyHud){ self waittill("MenuExit"); MyHud Destroy();}DeleteOnForceExit(MyHud){ self waittill("ForceNoMenu"); MyHud Destroy();}DeleteOnDoneEdit(MyHud){ self waittill("DoneEdit"); Myhud Destroy();}DeleteOnEditing(MyHud){ self waittill("AmEditing"); MyHud Destroy();}test(num){ self iPrintln("^2TEST "+num);}

Around Wikia's network

Random Wiki