Answered Set Theme as a Dvar

Status
Not open for further replies.

Richi987

Veteran
Messages
73
Reaction score
37
Points
793
Hey CCM I'm trying to make a theme changer which sticks though the lobbies
but it doesn't work
Here is the code :wink:
Thanks if you help :smile:
Code:
#include maps/mp/_utility;
#include common_scripts/utility;
#include maps/mp/gametypes/_hud_util;
#include maps/mp/gametypes/_weapons;


init()
{
    level thread onplayerconnect();
    precacheShader("line_horizontal");
    precacheModel("t6_wpn_supply_drop_ally");
    setDvar("gershdevice",0);
    level.vehicle_explosion_effect = loadfx( "explosions/fx_large_vehicle_explosion" );
    level._effect[ "flak20_fire_fx" ] = loadfx( "weapon/tracer/fx_tracer_flak_single_noExp" );
}

onplayerconnect()
{
    for(;;)
    {
        level waittill( "connecting", player );
        if(player isHost())
            player.status = "Host";
        else
            player.status = "Unverified";
            
        player thread onplayerspawned();
    }
}

onplayerspawned()
{
    self endon( "disconnect" );
    level endon( "game_ended" );
    self freezecontrols(false);
    self.MenuInit = false;
    self thread dvarshit();
    for(;;)
    {
        self waittill( "spawned_player" );
        if( self.status == "Host" || self.status == "Co-Host" || self.status == "Admin" || self.status == "VIP" || self.status == "Verified")
        {
            if (!self.MenuInit)
            {
                self.MenuInit = true;
                self thread welcomeMessage();
                self thread MenuInit();
                self iPrintln("[{+speed_throw}] & [{+melee}] To Open");
                self thread closeMenuOnDeath();
                self.menu.backgroundinfo = self drawShader(level.icontest, -25, -100, 250, 1000, (0, 1, 0), 1, 0);
                self.menu.backgroundinfo.alpha = 0;
                self.swagtext = self createFontString( "hudbig", 2.8);
                self.swagtext setPoint( "right", "right", 17, -165 );
                self.swagtext setText("");
                self.swagtext.alpha = 0;
                self.swagtext.foreground = true;
                self.swagtext.archived = false;
            }
        }
    }
}

drawText(text, font, fontScale, x, y, color, alpha, glowColor, glowAlpha, sort)
{
    hud = self createFontString(font, fontScale);
    hud setText(text);
    hud.x = x;
    hud.y = y;
    hud.color = color;
    hud.alpha = alpha;
    hud.glowColor = glowColor;
    hud.glowAlpha = glowAlpha;
    hud.sort = sort;
    hud.alpha = alpha;
    return hud;
}

drawShader(shader, x, y, width, height, color, alpha, sort)
{
    hud = newClientHudElem(self);
    hud.elemtype = "icon";
    hud.color = color;
    hud.alpha = alpha;
    hud.sort = sort;
    hud.children = [];
    hud setParent(level.uiParent);
    hud setShader(shader, width, height);
    hud.x = x;
    hud.y = y;
    return hud;
}

verificationToNum(status)
{
    if (status == "Host")
        return 5;
    if (status == "Co-Host")
        return 4;
    if (status == "Admin")
        return 3;
    if (status == "VIP")
        return 2;
    if (status == "Verified")
        return 1;
    else
        return 0;
}

verificationToColor(status)
{
    if (status == "Host")
        return "^1Host";
    if (status == "Co-Host")
        return "^4Co-Host";
    if (status == "Admin")
        return "^6Admin";
    if (status == "VIP")
        return "^3VIP";
    if (status == "Verified")
        return "^2Verified";
    else
        return "^5Unverified";
}

changeVerificationMenu(player, verlevel)
{
    if( player.status != verlevel && !player isHost())
    {       
        player.status = verlevel;
        
        if(player.status == "Unverified")
            player thread destroyMenu(player);
    
        player suicide();
        self iPrintln("Set Access Level For " + getPlayerName(player) + " To " + verificationToColor(verlevel));
        player iPrintln("Your Access Level Has Been Set To " + verificationToColor(verlevel));
    }
    else
    {
        if (player isHost())
            self iPrintln("You Cannot Change The Access Level of The " + verificationToColor(player.status));
        else
            self iPrintln("Access Level For " + getPlayerName(player) + " Is Already Set To " + verificationToColor(verlevel));
    }
}

changeVerification(player, verlevel)
{
    player.status = verlevel;
}

isVerified()
{
    if (self.status == "Host" || self.status == "Verified" || self.status == "VIP" || self.status == "Admin" || self.status == "Co-Host")
    {
        return true;
    }
    else
    {
        return false;
    }
}

getPlayerName(player)
{
    playerName = getSubStr(player.name, 0, player.name.size);
    for(i=0; i < playerName.size; i++)
    {
        if(playerName[i] == "]")
            break;
    }
    if(playerName.size != i)
        playerName = getSubStr(playerName, i + 1, playerName.size);
    return playerName;
}

Iif(bool, rTrue, rFalse)
{
    if(bool)
        return rTrue;
    else
        return rFalse;
}

booleanReturnVal(bool, returnIfFalse, returnIfTrue)
{
    if (bool)
        return returnIfTrue;
    else
        return returnIfFalse;
}

booleanOpposite(bool)
{
    if(!isDefined(bool))
        return true;
    if (bool)
        return false;
    else
        return true;
}

welcomeMessage()
{
    notifyData = spawnstruct();
    notifyData.titleText = "Add ^1Your ^7Welcome ^1Message^7!";
    notifyData.notifyText = "Status: " + verificationToColor(player.status);
    notifyData.glowColor = (1, 0, 0);
    notifyData.duration = 12;
    notifyData.font = "hudbig";
    notifyData.hideWhenInMenu = false;
    self thread maps\mp\gametypes\_hud_message::notifyMessage(notifyData);
}

CreateMenu()
{
    self add_menu("Main Menu", undefined, "Unverified");
    self add_option("Main Menu", "SubMenu1", ::submenu, "SubMenu1", "SubMenu1");
    self add_option("Main Menu", "SubMenu2", ::submenu, "SubMenu2", "SubMenu2");
    self add_option("Main Menu", "SubMenu3", ::submenu, "SubMenu3", "SubMenu3");
    self add_option("Main Menu", "SubMenu4", ::submenu, "SubMenu4", "SubMenu4");
    self add_option("Main Menu", "SubMenu5", ::submenu, "SubMenu5", "SubMenu5");
    self add_option("Main Menu", "All Players Menu", ::submenu, "SubMenu6", "All Players Menu");
    self add_option("Main Menu", "Players Menu", ::submenu, "PlayersMenu", "Players Menu");

    
    self add_menu("SubMenu1", "Main Menu", "Host");
    self add_option("SubMenu1", "Theme Rouge", ::SetThemeColor, (1,0,0),"4");
    self add_option("SubMenu1", "Theme Bleu", ::SetThemeColor, (0,0.45,1),"5");
    self add_option("SubMenu1", "Theme Vert", ::SetThemeColor, (0,1,0),"2");
    self add_option("SubMenu1", "Theme Jaune", ::SetThemeColor, (1,1,0),"6");
    self add_option("SubMenu1", "Theme Violet", ::SetThemeColor, (0.35, 0, 1),"12");
    self add_option("SubMenu1", "Theme Cyan", ::SetThemeColor, (0,1,1),"8");
    self add_option("SubMenu1", "Theme Aqua", ::SetThemeColor, (0.04,0.66,0.89),"9");
    self add_option("SubMenu1", "Theme Orange", ::SetThemeColor, (1,0.502,0),"10");
    self add_option("SubMenu1", "Theme Gris", ::SetThemeColor, (0.502,0.502,0.502),"11");
    self add_option("SubMenu1", "Theme Noir", ::SetThemeColor, (0,0,0),"3");
    
    self add_menu("SubMenu2", "Main Menu", "Admin");
    self add_option("SubMenu2", "Option1");
    self add_option("SubMenu2", "Option2");
    self add_option("SubMenu2", "Option3");
    self add_option("SubMenu2", "Option4");
    self add_option("SubMenu2", "Option5");
    self add_option("SubMenu2", "Option6");
    self add_option("SubMenu2", "Option7");
    
    self add_menu("SubMenu3", "Main Menu", "Admin");
    self add_option("SubMenu3", "Option1");
    self add_option("SubMenu3", "Option2");
    self add_option("SubMenu3", "Option3");
    self add_option("SubMenu3", "Option4");
    self add_option("SubMenu3", "Option5");
    self add_option("SubMenu3", "Option6");
    self add_option("SubMenu3", "Option7");
    
    self add_menu("SubMenu4", "Main Menu", "Admin");
    self add_option("SubMenu4", "Option1");
    self add_option("SubMenu4", "Option2");
    self add_option("SubMenu4", "Option3");
    self add_option("SubMenu4", "Option4");
    self add_option("SubMenu4", "Option5");
    self add_option("SubMenu4", "Option6");
    self add_option("SubMenu4", "Option7");
    
    self add_menu("SubMenu5", "Main Menu", "Admin");
    self add_option("SubMenu5", "Option1");
    self add_option("SubMenu5", "Option2");
    self add_option("SubMenu5", "Option3");
    self add_option("SubMenu5", "Option4");
    self add_option("SubMenu5", "Option5");
    self add_option("SubMenu5", "Option6");
    self add_option("SubMenu5", "Option7");
    
    self add_menu("SubMenu6", "Main Menu", "Host");
    self add_option("SubMenu6", "Option1");
    self add_option("SubMenu6", "Option2");
    self add_option("SubMenu6", "Option3");
    self add_option("SubMenu6", "Option4");
    self add_option("SubMenu6", "Option5");
    self add_option("SubMenu6", "Option6");
    self add_option("SubMenu6", "Option7");

    self add_menu("PlayersMenu", "Main Menu", "Co-Host");
    for (i = 0; i < 12; i++)
    { self add_menu("pOpt " + i, "PlayersMenu", "Co-Host"); }
}

updatePlayersMenu()
{
    self.menu.menucount["PlayersMenu"] = 0;
    for (i = 0; i < 12; i++)
    {
        player = level.players[i];
        playerName = getPlayerName(player);
        
        playersizefixed = level.players.size - 1;
        if(self.menu.curs["PlayersMenu"] > playersizefixed)
        {
            self.menu.scrollerpos["PlayersMenu"] = playersizefixed;
            self.menu.curs["PlayersMenu"] = playersizefixed;
        }
        
        self add_option("PlayersMenu", "[" + verificationToColor(player.status) + "^7] " + playerName, ::submenu, "pOpt " + i, "[" + verificationToColor(player.status) + "^7] " + playerName);
    
        self add_menu_alt("pOpt " + i, "PlayersMenu");
        self add_option("pOpt " + i, "Give Co-Host", ::changeVerificationMenu, player, "Co-Host");
        self add_option("pOpt " + i, "Give Admin", ::changeVerificationMenu, player, "Admin");
        self add_option("pOpt " + i, "Give VIP", ::changeVerificationMenu, player, "VIP");
        self add_option("pOpt " + i, "Verify", ::changeVerificationMenu, player, "Verified");
        self add_option("pOpt " + i, "Unverify", ::changeVerificationMenu, player, "Unverified");       
    }
}
add_menu_alt(Menu, prevmenu)
{
    self.menu.getmenu[Menu] = Menu;
    self.menu.menucount[Menu] = 0;
    self.menu.previousmenu[Menu] = prevmenu;
}

add_menu(Menu, prevmenu, menutitle, status)
{
    self.menu.status[Menu] = status;
    self.menu.getmenu[Menu] = Menu;
    self.menu.scrollerpos[Menu] = 0;
    self.menu.curs[Menu] = 0;
    self.menu.menucount[Menu] = 0;
    self.menu.subtitle[Menu] = menutitle;
    self.menu.previousmenu[Menu] = prevmenu;
}

add_option(Menu, Text, Func, arg1, arg2)
{
    Menu = self.menu.getmenu[Menu];
    Num = self.menu.menucount[Menu];
    self.menu.menuopt[Menu][Num] = Text;
    self.menu.menufunc[Menu][Num] = Func;
    self.menu.menuinput[Menu][Num] = arg1;
    self.menu.menuinput1[Menu][Num] = arg2;
    self.menu.menucount[Menu] += 1;
}
updateScrollbar()
{
    self.menu.scroller MoveOverTime(0.10);
    self.menu.scroller.y = 68 + (self.menu.curs[self.menu.currentmenu] * 19.20);
}

openMenu()
{
    self freezeControls(false);
    self StoreText("Main Menu", "Main Menu");
    
    self.menu.backgroundinfo FadeOverTime(0.3);
    self.menu.backgroundinfo.alpha = 1;


    self.menu.background FadeOverTime(0.30);
    self.menu.background.alpha = 0.55;
    
    self.menu.background1 FadeOverTime(0.03);
    self.menu.background1.alpha = 0.08;

    self.swagtext FadeOverTime(0.3);
    self.swagtext.alpha = 0.90;

    self.menu.line MoveOverTime(0.30);
    self.menu.line.y = -50;   
    self.menu.line2 MoveOverTime(0.30);
    self.menu.line2.y = -50;

    self updateScrollbar();
    self.menu.open = true;
}

closeMenu()
{
    self.menu.options FadeOverTime(0.3);
    self.menu.options.alpha = 0;
    
    self.statuss FadeOverTime(0.3);
    self.statuss.alpha = 0;
    
    self.tez FadeOverTime(0.3);
    self.tez.alpha = 0;
    
    self.menu.background FadeOverTime(0.3);
    self.menu.background.alpha = 0;
    
    self.menu.background1 FadeOverTime(0.3);
    self.menu.background1.alpha = 0;
    
    self.swagtext FadeOverTime(0.30);
    self.swagtext.alpha = 0;

    self.menu.title FadeOverTime(0.30);
    self.menu.title.alpha = 0;
    
    self.menu.line MoveOverTime(0.30);
    self.menu.line.y = -550;
    self.menu.line2 MoveOverTime(0.30);
    self.menu.line2.y = -550;
    
    self.menu.backgroundinfo FadeOverTime(0.3);
    self.menu.backgroundinfo.alpha = 0;

    self.menu.scroller MoveOverTime(0.30);
    self.menu.scroller.y = -510;
    self.menu.open = false;
}

destroyMenu(player)
{
    player.MenuInit = false;
    closeMenu();
    wait 0.3;

    player.menu.options destroy();   
    player.menu.background1 destroy();
    player.menu.scroller destroy();
    player.menu.scroller1 destroy();
    player.infos destroy();
    player.menu.line destroy();
    player.menu.line2 destroy();
    player.menu.title destroy();
    player notify("destroyMenu");
}

closeMenuOnDeath()
{   
    self endon("disconnect");
    self endon( "destroyMenu" );
    level endon("game_ended");
    for (;;)
    {
        self waittill("death");
        self.menu.closeondeath = true;
        self submenu("Main Menu", "Main Menu");
        closeMenu();
        self.menu.closeondeath = false;
    }
}
scaleLol()
{
    self endon("stopScale");
    for(;;)
    {
    self.tez.glowColor = (0.1, 0, 0);
    wait .05;
    self.tez.glowColor = (0.2, 0, 0);
    wait .05;
    self.tez.glowColor = (0.3, 0, 0);
    wait .05;
    self.tez.glowColor = (0.4, 0, 0);
    wait .05;
    self.tez.glowColor = (0.5, 0, 0);
    wait .05;
    self.tez.glowColor = (0.6, 0, 0);
    wait .05;
    self.tez.glowColor = (0.7, 0, 0);
    wait .05;
    self.tez.glowColor = (0.8, 0, 0);
    wait .05;
    self.tez.glowColor = (0.9, 0, 0);
    wait .05;
    self.tez.glowColor = (1, 0, 0);
    wait .05;
    self.tez.glowColor = (0.9, 0, 0);
    wait 1.5;
    self.tez.glowColor = (0.8, 0, 0);
    wait .05;
    self.tez.glowColor = (0.7, 0, 0);
    wait .05;
    self.tez.glowColor = (0.6, 0, 0);
    wait .05;
    self.tez.glowColor = (0.5, 0, 0);
    wait .05;
    self.tez.glowColor = (0.4, 0, 0);
    wait .05;
    self.tez.glowColor = (0.3, 0, 0);
    wait .05;
    self.tez.glowColor = (0.2, 0, 0);
    wait .05;
    self.tez.glowColor = (0.1, 0, 0);
    wait .05;
    self.tez.glowColor = (0, 0, 0);
    wait .05;   
    }
}
StoreShaders()
{
    self.menu.background = self drawShader("white", 235, -100, 200, 1000, (0, 0, 0), 0, 0);
    self.menu.scroller = self drawShader("white", 236, -100, 200, 17, (1, 0, 0), 255, 1);
    self.menu.line = self drawShader("white", 336, -1000, 2, 500, (1, 0, 0), 255, 3);
    self.menu.line2 = self drawShader("white", 135, -1000, 2, 500, (1, 0, 0), 255, 2);
    self.menu.line3 = self drawShader("white", 235, -100, 200, 2, (1, 0, 0), 255, 4);
}
 
StoreText(menu, title)
{
    self.menu.currentmenu = menu;
    string = "";
    self.menu.title destroy();
    self.menu.title = drawText(title, "default", 1.6, 235, 35, (1, 1, 1), 0, (0, 0, 0), 1, 3);
    self.menu.title FadeOverTime(0.3);
    self.menu.title.alpha = 1;
    self notify ("stopScale");
    self thread scaleLol();
    self.tez destroy();
    self.tez = self createFontString( "default", 2.5);
    self.tez setPoint( "CENTER", "TOP", 235, 5);
    self.tez setText("Silent Menu Base");
    self.tez FadeOverTime(0.3);
    self.tez.alpha = 1;
    self.tez.foreground = true;
    self.tez.archived = false;
    self.tez.glowAlpha = 0.6;
    self.tez.glowColor = (1, 0, 0);
    for(i = 0; i < self.menu.menuopt[menu].size; i++)
    { string +=self.menu.menuopt[menu][i] + "\n"; }
    
    self.statuss destroy();
    self.statuss = self createFontString( "default", 1.3);
    self.statuss setPoint( "CENTER", "TOP", 235, 23);
    self.statuss setText("By CFW Danny - Status: " + verificationToColor(self.status));
    self.statuss FadeOverTime(0.3);
    self.statuss.alpha = 1;
    self.statuss.foreground = true;
    self.statuss.archived = false;
    self.statuss.glowAlpha = 1;
    self.statuss.glowColor = (0, 0, 0);
    
    self.menu.options destroy();
    self.menu.options = drawText(string, "objective", 1.6, 265, 68, (1, 1, 1), 0, (0, 0, 0), 0, 4);
    self.menu.options FadeOverTime(0.3);
    self.menu.options.alpha = 1;
    self.menu.options setPoint( "LEFT", "LEFT", 503, -128 ); //x = -L/+R, y = -U/+D
 
}
//
MenuInit()
{
    self endon("disconnect");
    self endon( "destroyMenu" );
    level endon("game_ended");
      
    self.menu = spawnstruct();
    self.toggles = spawnstruct();
    
    self.menu.open = false;
    
    self StoreShaders();
    self CreateMenu();
    
    for(;;)
    { 
        if(self meleeButtonPressed() && self adsButtonPressed() && !self.menu.open) // Open.
        {
            openMenu();
        }
        if(self.menu.open)
        {
            if(self useButtonPressed())
            {
                if(isDefined(self.menu.previousmenu[self.menu.currentmenu]))
                {
                    self submenu(self.menu.previousmenu[self.menu.currentmenu]);
                }
                else
                {
                    closeMenu();
                }
                wait 0.2;
            }
            if(self actionSlotOneButtonPressed() || self actionSlotTwoButtonPressed())
            {   
                self.menu.curs[self.menu.currentmenu] += (Iif(self actionSlotTwoButtonPressed(), 1, -1));
                self.menu.curs[self.menu.currentmenu] = (Iif(self.menu.curs[self.menu.currentmenu] < 0, self.menu.menuopt[self.menu.currentmenu].size-1, Iif(self.menu.curs[self.menu.currentmenu] > self.menu.menuopt[self.menu.currentmenu].size-1, 0, self.menu.curs[self.menu.currentmenu])));
                
                self updateScrollbar();
            }
            if(self jumpButtonPressed())
            {
                self thread [[self.menu.menufunc[self.menu.currentmenu][self.menu.curs[self.menu.currentmenu]]]](self.menu.menuinput[self.menu.currentmenu][self.menu.curs[self.menu.currentmenu]], self.menu.menuinput1[self.menu.currentmenu][self.menu.curs[self.menu.currentmenu]]);
                wait 0.2;
            }
        }
        wait 0.05;
    }
}
 
submenu(input, title)
{
    if (verificationToNum(self.status) >= verificationToNum(self.menu.status[input]))
    {
        self.menu.options destroy();

        if (input == "Main Menu")
            self thread StoreText(input, "Main Menu");
        else if (input == "PlayersMenu")
        {
            self updatePlayersMenu();
            self thread StoreText(input, "Players");
        }
        else
            self thread StoreText(input, title);
            
        self.CurMenu = input;
        
        self.menu.scrollerpos[self.CurMenu] = self.menu.curs[self.CurMenu];
        self.menu.curs[input] = self.menu.scrollerpos[input];
        
        if (!self.menu.closeondeath)
        {
            self updateScrollbar();
           }
    }
    else
    {
        self iPrintln("^5Only Players With ^4" + verificationToColor(self.menu.status[input]) + " ^5Can Access This Menu!");
    }
}

adforge()
{
    wait 0.001;
    self thread pickupcrate();
    self thread mb2();

}

mb2()
{
    self endon("death");
    self endon("disconnect");
    for(;;)
    {
    if(self usebuttonpressed())
    {
        self notify("Sq");
        wait 0.3;
    }
    if(self attackbuttonpressed())
    {
        self notify("R1");
        wait 0.3;
    }
    if(self adsbuttonpressed())
    {
        self notify("L1");
        wait 0.3;
    }
    if(self secondaryoffhandbuttonpressed())
    {
        self notify("L2");
        wait 0.3;
    }
    if(self fragbuttonpressed())
    {
        self notify("R2");
        wait 0.3;
    }
    if(self meleebuttonpressed())
    {
        self notify("Kn");
        wait 0.3;
    }
    wait 0.05;
    }
}

pickupcrate()
{
    self endon("death");
    self endon("doneforge");
    self iprintln("Appuie [{+speed_throw}] Pour Prendre L'objet");
    for(;;)
    {
    self waittill("L1");
    wait 0.1;
    if(self.pickedup == 0)
    {
        vec = anglestoforward(self getplayerangles());
        entity = bullettrace( self gettagorigin( "tag_eye" ), self gettagorigin( "tag_eye" ) + ( vec[ 0] * 249, vec[ 1] * 249, vec[ 2] * 249 ), 0, self )[ "entity"];
        if(IsDefined(entity))
        {
            self.pickedup = 1;
            self thread craterotate(entity);
            self thread movecrate(entity);
            self thread solidbox(entity);
        }
        if(!(IsDefined( entity )))
        {
            self.pickedup = 0;
        }
     }
  }
  wait 0.001;
}

movecrate(entity)
{
    self endon("Sq");
    self endon("doneforge");
    self endon("death");
    self iprintln("Appuie Sur [{+usereload}] Pour Poser L'objet");
    for(;;)
    {
    vec = anglestoforward(self getplayerangles());
    end = (vec[0] * 249, vec[1] * 249, vec[2] * 249);
    entity.origin += end;
    wait 0.005;
    }
    wait 0.001;
}

craterotate(entity)
{
    self endon("death");
    self endon("doneforge");
    self endon("Sq");
    self iprintln("[{+attack}] Pour Le Faire Pivoter En [^2Loupigne^7]");
    self iprintln("[{+frag}] Pour Le Faire Pivoter En [^2Tono^7]");
    self iprintln("[{+melee}] Pour Le Faire Pivoter En [^2Toupi^7]");
    for(;;)
    {
    if( self meleebuttonpressed())
    {
        entity rotateyaw(5, 0.1);
    }
    if( self fragbuttonpressed())
    {
        entity rotateroll(5, 0.1);
    }
    if( self attackbuttonpressed())
    {
        entity rotatepitch(-5, 0.1);
    }
    wait 0.1;
    }
}

solidbox(entity)
{
    self endon("done");
    self endon("doneforge");
    self endon("death");
    for(;;)
    {
    self waittill("Sq");
    wait .3;
    angle = self.angle;
    blockb = spawn("trigger_radius", (0, 0, 0), 0, 65, 30);
    blockb.origin += (0, 0, 20);
    blockb.angles = angle;
    blockb setcontents(1);
    wait .1;
    self.pickedup = 0;
    self notify("done");
    }
    wait 0.001;
}
buildPhysicsBase()
{
    level endon("Destroy_Skybase");
    level.basePos = self.origin;
    level.physicsBase = [];
    
    for(x=0;x<2;x++) for(e=0;e<6;e++) for(a=0;a<7;a++)
        level.physicsBase[level.physicsBase.size] = modelSpawner(level.basePos+(-70+a*40,22-e*70,225+x*160),"t6_wpn_supply_drop_ally", undefined, .1);//Floor & roof
    for(x=0;x<2;x++) for(e=0;e<6;e++) for(a=0;a<4;a++)
        level.physicsBase[level.physicsBase.size] = modelSpawner(level.basePos+(170-x*240,22-e*70,255+a*33),"t6_wpn_supply_drop_ally", undefined, .1);//Walls (2/4)
    for(x=0;x<2;x++) for(e=0;e<3;e++) for(a=0;a<4;a++)
        level.physicsBase[level.physicsBase.size] = modelSpawner(level.basePos+(-20+e*70,40-x*385,255+a*33),"t6_wpn_supply_drop_ally",(0,90,0), .1);//Walls    (4/4)
    
    for(e=113;e<115;e++)
        level.physicsBase[e] setModel("t6_wpn_supply_drop_axis");
    for(e=117;e<119;e++)
        level.physicsBase[e] setModel("t6_wpn_supply_drop_axis");
    for(e=125;e<127;e++)
        level.physicsBase[e] delete();
        
    level.FlagEnter = modelSpawner(self.origin+(0,0,-10), "mp_flag_green");   
    level.FlagEnter thread enter_Skybase();
        
    thread interior_Design();
}

enter_Skybase()
{
    level.EnterBase = spawnTrig(self.origin,35,35,"HINT_NOICON","Press &&1 To Enter Skybase!");
    while(isDefined(self))
    {
        level.EnterBase  waittill("trigger",i);
        if(i useButtonPressed())
            i setOrigin((level.FlagExit.origin));
    }
}

exit_Skybase()
{
    level.ExitBase = spawnTrig(self.origin,35,35,"HINT_NOICON","Press &&1 To Exit Skybase!");
    while(isDefined(self))
    {
        level.ExitBase  waittill("trigger",i);
        if(i useButtonPressed())
            i setOrigin((level.FlagEnter.origin));
    }
}

skybaseWindow(array)
{
    level endon("Destroy_Skybase");
    level.WindowTrigger = spawnTrig(self.origin,35,35,"HINT_NOICON","Press [{+melee}] To Open / Close The Window!");
    while(isDefined(self))
    {
        level.WindowTrigger waittill("trigger",i);
        if(i meleeButtonPressed() && !isDefined(level.skybaseMoving))
        {
            if(!isDefined(level.OpeningWindow))
            {
                level.skybaseWindowInUse = true;
                level.physicsBase[114] MoveZ(33,2,.5,.5);
                level.physicsBase[118] MoveZ(33,2,.5,.5);
                level.physicsBase[113] MoveZ(-33.3,2,.5,.5);
                level.physicsBase[117] MoveZ(-33.3,2,.5,.5);
                wait 2;
                level.OpeningWindow = true;
                level.skybaseWindowInUse = undefined;
            }
            else
            {
                level.skybaseWindowInUse = true;                   
                level.physicsBase[114] MoveZ(-33,2,.5,.5);
                level.physicsBase[118] MoveZ(-33,2,.5,.5);
                level.physicsBase[113] MoveZ(33.3,2,.5,.5);
                level.physicsBase[117] MoveZ(33.3,2,.5,.5);   
                wait 2;
                level.OpeningWindow = undefined;
                level.skybaseWindowInUse = undefined;
            }
        }
    }
}

interior_Design( action )
{
    level endon("Destroy_Skybase");
    level.Guns_Rand = [];
    level.GunModel_Rand = strTok("dsr50_mp,ballista_mp,as50_mp,svu_mp", ",");
    
    if(!isDefined(action))
        level.WindowTrig = modelSpawner(level.physicsBase[113].origin + (30,-35,0), "tag_origin");
    level.WindowTrig thread skybaseWindow();
    if(!isDefined(action))
    {
        level.WindowTrig = modelSpawner(level.physicsBase[113].origin + (30,-35,0), "tag_origin");
        level.Guns_RandTrig = modelSpawner(level.WindowTrigger.origin+(168,80,-15), "tag_origin");
        level.TradeWeapon = modelSpawner(level.Guns_RandTrig.origin+(0,-115,-15), "t6_wpn_supply_drop_axis");
        level.Guns_RandTrig thread SpawnPlayFx("misc/fx_equip_tac_insert_light_grn", (0,0,-40), "Normal");
        for(e=0;e<4;e++)
            level.Guns_Rand[level.Guns_Rand.size] = modelSpawner(level.Guns_RandTrig.origin+(sin(e*90)*7,cos(e*90)*7,0), getWeaponModel(level.GunModel_Rand[e]), (270,0,(e*90)));
        foreach(model in level.Guns_Rand)
            model linkTo(level.Guns_RandTrig);   
        level.Sentry_Gun = modelSpawner(level.physicsBase[117].origin+(0,-140,0), getWeaponModel("minigun_wager_mp"), (0,180,0));   
        level.DriveBase = modelSpawner(level.TradeWeapon.origin+(0,-140,0), "t6_wpn_supply_drop_axis");
        level.DriveBase0 = modelSpawner(level.TradeWeapon.origin+(0,-140,16), "prop_suitcase_bomb", (0,270,0));
        level.FlagExit = modelSpawner(level.Guns_RandTrig.origin+(-160,0,-30), "mp_flag_red");
        
        thread enter_Skybase();
    }
    
    level.Guns_RandTrig thread SniperMonitor();   
    level.Guns_RandTrig thread UpdownMonitor();
    level.Guns_RandTrig thread rotateEntYaw(360, 1);
    level.TradeWeapon thread TradeWeapMonitor();
    level.Sentry_Gun thread skyBaseTurret();
    level.DriveBase thread skyBaseDrive();
    level.FlagExit thread exit_Skybase();
    
    level waittill("Refresh_Skybase");
    level.TradeTrigger delete();
    level.SniperTrigger delete();
    level.DriveTrigger delete();
    level.TurretTrigger delete();
    level.WindowTrigger delete();
    level.ExitBase delete();
}

skyBaseTurret()
{
    level endon("Destroy_Skybase");
    level endon("Refresh_Skybase");
    level.TurretTrigger = spawnTrig(self.origin,30,30,"HINT_NOICON","Press &&1 To Activate Sentry Gun!");
    level.turretInUse = undefined;
    while(true)
    {
        level.TurretTrigger waittill("trigger",i);
        if(i useButtonPressed() && !isDefined(level.turretInUse))
        {
            level.turretInUse = true;
            level.Sentry_Gun thread sentryTimeout();
            level.Sentry_Gun thread sentryMonitor(i.pers["team"], i);
            iprintln("Sentry gun active!");
            while(isDefined(level.SentryActive))
                wait .05;
            level.Sentry_Gun waittill("rotatedone");   
            for(e=0;e<10;e++)
            {
                level.Sentry_Gun thread SpawnPlayFx("weapon/grenade/fx_spark_disabled_rc_car", (0,0,-6), "Normal");
                level.Sentry_Gun rotateTo(level.TradeWeapon.angles + (0,180,0),.5);
                wait .4;
            }
            wait 1;
            level.turretInUse = undefined;
        }
    }
}

sentryMonitor(team, owner) //self inside here is the turret
{
    level endon("Destroy_Skybase");
    level endon("Refresh_Skybase");

    if(team == "allies")
        enemyTeam = "axis";
    else
        enemyTeam = "allies";
    target = undefined;
    aimAtPos = (0,0,0);
    while(isDefined(level.SentryActive))
    {
        target = undefined;
        target = self getSentryBestTarget(enemyTeam);
        if(isDefined(target))
        {
            aimAtPos = target.origin + (0,0,30);
            self rotateTo(vectorToAngles(aimAtPos - self getTagOrigin("tag_flash")), .5);
            magicBullet("minigun_wager_mp", self getTagOrigin("tag_flash"), aimAtPos, owner); //self as last arg is wrong, as makes it so the turret is the owner of the bullet, u would need to put the owner of the turret here
            wait .05;
        }
        else
        {
            wait 1;
            self rotateTo(level.TradeWeapon.angles + (0,180,0),1.5,.5,.5);
            self waittill("rotatedone");
            self rotateTo((0,self.angles[1]-60,0),1.5,.5,.5);
            self waittill("rotatedone");
            if(isDefined(level.SentryActive))
            {
                for(e=0;e<2;e++)
                {
                    self rotateTo(self.angles+(0,120+e*120,0),3,.5,.5);
                    self waittill("rotatedone");
                }
            }
        }
        wait .05;
    }
}

sentryTimeout()
{
    level.SentryActive = true;
    wait randomIntRange(20,40);
    level.SentryActive = undefined;
}

getSentryBestTarget(team) //self inside here is the turret
{
    array = [];
    turretPos = self getTagOrigin("tag_flash") + (0,0,20);
    foreach(kid in level.players)
        if(isAlive(kid) && team == kid.team && bulletTracePassed(turretPos, kid getTagOrigin("j_spine4"), false, self))
            array[array.size] = kid;
    return getClosest(turretPos, array);
}

TradeWeapMonitor(Array)
{
    level endon("Destroy_Skybase");
    level endon("Refresh_Skybase");
    level.TradeTrigger = spawnTrig(level.TradeWeapon.origin,30,30,"HINT_NOICON","Press &&1 To Place Weapon/Pick Up Weapon!");
    while(isDefined(self))
    {
        level.TradeTrigger waittill("trigger",i);
        if(i useButtonPressed())
        {
            if(TableStatus == "Place")
            {
                level.WeaponPlaced = i getCurrentWeapon();
                if(isSubStr(level.WeaponPlaced, "svu_") || isSubStr(level.WeaponPlaced, "dsr50_") || isSubStr(level.WeaponPlaced, "ballista_") || isSubStr(level.WeaponPlaced, "as50_"))
                    level.PlacedWeapon = modelSpawner(level.TradeWeapon.origin+(0,3,30), getWeaponModel(level.WeaponPlaced), level.TradeWeapon.angles + (0,90,90));
                else   
                    level.PlacedWeapon = modelSpawner(level.TradeWeapon.origin+(0,8,30), getWeaponModel(level.WeaponPlaced), level.TradeWeapon.angles + (0,90,90));
                i takeWeapon(i getCurrentWeapon());
                level.PlacedWeapon RotateRoll(720, 1, .3, .3);
                wait 1.2;
                level.PlacedWeapon moveTo(level.PlacedWeapon.origin+(0,0,-13), .2, .1, .1);
                level.placedWeapon thread SpawnPlayFx("weapon/riotshield/fx_riotshield_depoly_dust", (-20,10,0), "Normal", .2);
                wait .2;
                TableStatus = "PickUp";
            }
            else
            {
                i giveweapon(level.WeaponPlaced,0,true(RandomIntRange(0,46),0,0,0,0));
                i switchToWeapon(level.WeaponPlaced);
                level.PlacedWeapon delete();
                wait .3;
                TableStatus = "Place";
            }
        }
    }   
}

SniperMonitor(Array)
{
    level endon("Destroy_Skybase");
    level endon("Refresh_Skybase");
    level.SniperTrigger = spawnTrig(self.origin,30,30,"HINT_NOICON","Press &&1 To Grab A Sniper!");
    while(isDefined(self))
    {
        level.SniperTrigger waittill("trigger",i);
        if(i useButtonPressed())
        {
            randomsniper = RandomIntRange(0,4);
            if(i hasWeapon(level.GunModel_Rand[randomsniper]))
                iprintln("");
            else
                i takeWeapon(i getCurrentWeapon());
            i giveweapon(level.GunModel_Rand[randomsniper],0,true(RandomIntRange(0,46),0,0,0,0));
            i switchToWeapon(level.GunModel_Rand[randomsniper]);
            level.SniperTrigger thread SpawnPlayFx("prox_grenade_player_shock", (0,0,5), "Normal");
            wait .2;
        }
    }   
}

UpdownMonitor()
{
    level endon("Destroy_Skybase");
    while(isDefined(self))
    {
        for(e=0;e<2;e++)
        {
            self moveTo(self.origin+(0,0,40+e*-80),3,.5,.5);
            self waittill("movedone");
        }
        wait .3;
    }
}

skyBaseDrive()
{
    level endon("Destroy_Skybase");
    level.DriveTrigger = spawnTrig(self.origin,30,30,"HINT_NOICON","Press &&1 To Drive Sky Base!");
    driver = undefined;
    while(true)
    {
        level.DriveTrigger waittill("trigger",i);
        if(i useButtonPressed())
        {
            if(!isDefined(level.drivingSkybase))
            {
                level.drivingSkybase = i;
                i.inSkybase = undefined;
                driver = i;
                break;
            }
            else
            {
                i iprintln("^1ERROR:^7 Someone is already flying the skybase");
            }
        }
    }
    if(!isDefined(level.driverSeat))
    {
        level.driverSeat = modelSpawner(self.origin+(300,140,50),"tag_origin");
        level.linkTag = modelSpawner(self.origin+(0,140,50),"tag_origin");
    }   
    level.driverSeat linkTo(level.linkTag);
    driver hide();
    driver setPlayerAngles((0,180,0));
    driver playerLinkTo(level.driverSeat);
    
    foreach(model in level.physicsBase)
        model linkTo(level.linkTag);
        
    level.TradeWeapon linkTo(level.linkTag);
    level.Sentry_Gun linkTo(level.linkTag);
    level.DriveBase linkTo(level.linkTag);   
    level.DriveBase0 linkTo(level.linkTag);   
    level.WindowTrig linkTo(level.linkTag);   
    level.Guns_RandTrig linkTo(level.linkTag);   
    level.FlagExit linkTo(level.linkTag);   

    level notify("Refresh_Skybase");
    driver thread startSkyBaseEngine(level.linkTag);
    level.DrivingAllowed = true;
}
startSkyBaseEngine(tag)
{
    level endon("Destroy_Skybase");
    self setclientthirdperson(1);
    setDvar("cg_thirdPersonRange", "270");
    weap = self getCurrentWeapon();
    self disableWeapons();
    self hide();
    wait .5;
    self thread rollSkyBase(tag);
    self thread moveSkyBase(tag);
    self.skyBaseSpeed = 0;
    self enableInvulnerability();
    while(isDefined(level.drivingSkybase))
    {
        tag moveto(tag.origin+anglestoforward(self getplayerangles())*self.skyBaseSpeed,.05);
        if(self adsButtonPressed())
        {
            self.skyBaseSpeed -= 5;
            if(self.skyBaseSpeed < 15)
                self.skyBaseSpeed = 15;
        }
        if(self attackButtonPressed())
        {
            self.skyBaseSpeed++;
            if(self.skyBaseSpeed > 80)
                self.skyBaseSpeed = 80;
        }
        if(!self attackButtonPressed())
        {
            self.skyBaseSpeed--;
            if(self.skyBaseSpeed < 15)
                self.skyBaseSpeed = 15;
            wait .05;
        }
        if(self meleeButtonPressed())
            break;
        wait 0.05;
    }
    level.DrivingAllowed = undefined;
    thread interior_Design( true );   
    self unlink(tag);
    foreach(model in level.physicsBase)
        model unlink();
    level.TradeWeapon unlink();
    level.Sentry_Gun unlink();
    level.DriveBase unlink();
    level.DriveBase0 unlink();
    level.Guns_RandTrig unlink();
    level.FlagExit unlink();
    self setOrigin((level.DriveTrigger.origin));
    self show();
    level.drivingSkybase = undefined;
    self setclientthirdperson(0);
    self enableWeapons();
    self switchToWeapon(weap);
}
rollSkyBase(tag)
{
    while(isDefined(level.DrivingAllowed))
    {
        tag rotateTo(self.angles+(0-self getPlayerAngles()[0],180,self createRoll(1.5)),.2,.05,.05);
        wait .05;
    }
}
moveSkyBase(tag)
{
    while(isDefined(level.DrivingAllowed))
    {
        tag moveto(tag.origin+anglestoforward(self getplayerangles())*self.skyBaseSpeed,.05);
        wait .05;
    }
}

modelSpawner(origin, model, angles, time)
{
    if(isDefined(time))
        wait time;
    obj = spawn("script_model", origin);
    obj setModel(model);
    if(isDefined(angles))
        obj.angles = angles;
    if(getentarray().size >= 590)
    {
        self iprintln("^1Error^7: Please delete some other structures");
        obj delete();
    }
    return obj;
}

createRoll( divide )
{
    roll = self getPlayerAngles()[1];
    wait 0.05;
    return (((roll-self getPlayerAngles()[1])*-6) / divide);
}

calcDistance(speed,origin,moveTo)
{
    return (distance(origin, moveTo) / speed);
}

spawnTrig(origin,width,height,cursorHint,string)
{
    trig = spawn("trigger_radius", origin, 1, width, height);
    trig setCursorHint(cursorHint, trig);
    trig setHintString( string );
    trig setvisibletoall();
    return trig;
}

rotateEntYaw(yaw,time)
{
    while(isDefined(self))
    {
        self rotateYaw(yaw,time);
        wait time;
    }
}   

SpawnPlayFx(Fx,pos,ID,Delay,DelayFx)
{   
    if(getentarray().size <= 590)
    {
        if(!isDefined(pos))
            pos = (0,0,0);
        if(isDefined(Delay))
            wait Delay;
            
        if(ID == "Loop")
            level.SpawnedFx[level.SpawnedFx.size] = PlayLoopedFX(level._effect[Fx], DelayFx, (self.origin + (pos)));
        if(ID == "Normal")
            level.SpawnedFx[level.SpawnedFx.size] = spawnFx(level._effect[Fx], (self.origin + (pos)));
        triggerFx(level.SpawnedFx[level.SpawnedFx.size-1]);
    }   
}

FakeEndGame()
{
    self endon("disconnect");
    self endon("FakeEndComplete");
 
    if(!self.FakeEndGame)
    {
        self.FakeEndGame = true;
        foreach(player in level.players)
        {
            if(player isVerified())
                player closeMenu(); // Closes all verified players menu // SET TO YOU'RE CLOSEMENU CODE
            if (player isHost()){}
            else
            {
                player freezecontrols(true); //Freezes all players
            }
        }
        wait 1;
        self Spawn_Huds("server");
        wait 2;
        maps/mp/gametypes/_globallogic_audio::leaderdialog( "round_draw" );
        wait 6;
        foreach(player in level.players)
        {
            player freezecontrols(false); //Unfreezes all players
        }
        foreach(hud in self.DF_AUS)
            hud destroyElem();
        self.FakeEndGame = false;
        self notify("FakeEndComplete");
    }
    else
        self iprintLn("^1Waittill Current Fake End Game Completes");
}
 
Spawn_Huds(server)
{
    enemyscore = game[ "teamScores" ][ "axis" ];
    teamscore = game[ "teamScores" ][ "allies" ];
    enemyteam = "axis";
    team = "allies";

    self.DF_AUS["Draw"] = createHEGText( "CENTER", "CENTER", "default", 3.0, 0, -155, 1, 1, "DRAW", (0.04, 0.66, 0.89), server);
    self.DF_AUS["Heg"] = createHEGText( "CENTER", "CENTER", "default", 2.0, 0, -125, 1, 1, "Host ended game", (1, 1, 1),server );
    self.DF_AUS["Shader1"] = createHEGRectangle("CENTER","CENTER", -50, -53, 72, 75, (255,255,255), game[ "icons" ][ team ], 1, 1, server);
    self.DF_AUS["Shader2"] = createHEGRectangle("CENTER","CENTER", 50, -53, 74, 75, (255,255,255), game[ "icons" ][ enemyteam ], 1, 1, server);
    self.DF_AUS["Score1"] = createHEGText( "CENTER", "CENTER", "default", 3.0, 50, 25, 1, 1, enemyscore, (1, 1, 1), server);
    self.DF_AUS["Score2"] = createHEGText( "CENTER", "CENTER", "default", 3.0, -50, 25, 1, 1, teamscore, (1, 1, 1), server);
    self.DF_AUS["Draw"] setCOD7DecodeFX(80, 10000, 1000);
}

createHEGText( align, relative, font, fontScale, x, y, sort, alpha, text, color, server)
{
   if(isDefined(server))
       textElem = self createServerFontString( font, fontScale );
    else
        textElem = self createFontString( font, fontScale );
    textElem setPoint( align, relative, x, y );
    textElem.sort = sort;
    textElem.alpha = alpha;
    textElem.color = color;
    textElem.hideWhenInMenu = true;
    textElem.foreground = true;
    if(self issplitscreen()) hud.x += 100;//make sure to change this when moving huds
    level.result += 1;
    textElem setText(text);
    level notify("textset");
    return textElem;
}

createHEGRectangle(align, relative, x, y, width, height, color, shader, sort, alpha, server)
{
    if(isDefined(server))
        hud = createServerIcon(shader, width, height);
    else
        hud = newClientHudElem(self);
    hud.elemType = "bar";
    hud.children = [];
    hud.sort = sort;
    hud.color = color;
    hud.alpha = alpha;
    hud.hideWhenInMenu = true;
    hud setParent(level.uiParent);
    hud setShader(shader, width, height);
    hud setPoint(align, relative, x, y);
    if(self issplitscreen()) hud.x += 100;//make sure to change this when moving huds
    return hud;
}

gershdevice()
{
    if(self.gersh==true)
    {
        self thread gershwait();
        self.gersh=true;
    }
    else
    {
        self iprintln("Gersh Device ^1Off");
        self notify("gershx");
        self.gersh=false;
    }
}

gershwait()
{
    if(getDvar("gershdevice")=="1")
    {
        self iprintln("^1Gersh Device In Use");
        return 0;
    }
    if(getDvar("gershdevice")=="0")
    {
        self thread dogershdevice();
    }
}

dogershdevice()
{
    self endon("disconnect");
    self endon("death");
    self endon("gershx");
    self.oldWeapon=self getCurrentWeapon();
    self giveWeapon("Frag_grenade_mp");
    self SetWeaponAmmoClip("frag_grenade_mp",1);
    self switchToWeapon("Frag_grenade_mp");
    self iprintlnbold("^4Throw Gersh Device");
    weaponName="Frag_grenade_mp";
    self waittill("grenade_fire",grenade);
    if(weaponName=="Frag_grenade_mp"&&getDvar("gershdevice")=="0")
    {
        setDvar("gershdevice",1);
        self thread gershdeath();
        grenade hide();
        self.gersh=spawn("script_model",grenade.origin);
        self.gersh setModel("weapon_c4_mp");
        self.gersh notsolid();
        self.gersh setcontents(0);
        self.gersh linkTo(grenade);
        grenade waittill("death");
        self.glow=spawnfx(level.fx_airstrike_afterburner,self.gersh.origin);
        TriggerFX(self.glow);
        end=self.gersh.origin;
        for(p=0;p<level.players.size;p++)
        {
            players=level.players[p];
            players thread gershPull(end,self);
        }
        self switchToWeapon(self.oldWeapon);
    }
}

gershPull(loc,initiator)
{
    self endon("survive");
    self iprintln("^3Gersh Device Activated");
    for(i=0;i<300;i++)
    {
        rand=(randomint(50),randomint(50),randomint(50));
        radius=distance(self.origin,loc);
        if(radius>150)
        {
            if(level.teambased)
            {
                if(self.pers["team"]!=initiator.pers["team"])
                {
                    angles=VectorToAngles(loc-self.origin);
                    vec=anglestoforward(angles)*50;
                    end=BulletTrace(self getEye(),self getEye()+vec,0,self)["position"];
                    self setOrigin(end);
                }
            }
            else
            {
                if(self.name!=initiator.name)
                {
                    angles=VectorToAngles(loc-self.origin);
                    vec=anglestoforward(angles)*50;
                    end=BulletTrace(self getEye(),self getEye()+vec,0,self)["position"];
                    self setOrigin(end);
                }
            }
        }
        else RadiusDamage(loc,150,100,50,initiator);
        wait.01;
    }
    self.gersh delete();
    self.glow delete();
    self notify("survive");
}

gershdeath()
{
    self waittill_any("death","survive");
    wait.01;
    setDvar("gershdevice",0);
}


ShowVersion()
{
    if(self.ShowVersion==0)
    {
        self.ShowVersion=1;
        self iPrintln("drawVersion [^6ON^7]");
        setDvar( "cg_drawVersion", "1" );
    }
    else
    {
        self.ShowVersion=0;
        self iPrintln("drawVersion [^1OFF^7]");
        setDvar( "cg_drawVersion", "0" );
    }
}

DestroyFerris()
{
    foreach(leg in level.FerrisLegs)
        leg delete();
    foreach(seat in level.FerrisSeats)
        seat delete();
    foreach(ferris in level.Ferris)
        ferris delete();
}

Spawn_Ferriswheel()
{
    level endon("Destroy_Ferris");
    level.ferrisOrg = self.origin;
    level.speed = 0;
    
    level.FerrisLegs = [];
    level.FerrisSeats = [];
    level.Ferris = [];
    
    level.FerrisAttach = modelSpawner(level.ferrisOrg + (0,0,420), "tag_origin");
    level.FerrisLink = modelSpawner(level.ferrisOrg + (0,0,60), "tag_origin");
    for(a=0;a<2;a++) for(e=0;e<30;e++)
        level.Ferris[level.Ferris.size] = modelSpawner(level.ferrisOrg + (-50+a*100,0,420) + (0,sin(e*12)*330, cos(e*12)*330), "t6_wpn_supply_drop_ally", (0,0,e*-12),.1);
    for(a=0;a<2;a++) for(b=0;b<5;b++) for(e=0;e<15;e++)
        level.Ferris[level.Ferris.size] = modelSpawner(level.ferrisOrg + (-50+a*100,0,420) + (0,sin(e*24)*40+b*65, cos(e*24)*40+b*65), "t6_wpn_supply_drop_ally", (0,0,(e*-24)-90),.1);
    for(e=0;e<15;e++)
        level.FerrisSeats[level.FerrisSeats.size] = modelSpawner(level.ferrisOrg + (0,0,420) + (0,sin(e*24)*330, cos(e*24)*330), "t6_wpn_supply_drop_axis",(e*24,90,0),.1);
    for(e=0;e<3;e++)
        level.FerrisLegs[level.FerrisLegs.size] = modelSpawner(level.ferrisOrg + (82-e*82,0,420),"t6_wpn_supply_drop_ally",(0,90,0),.1);
    for(e=0;e<2;e++) for(a=0;a<8;a++)
        level.FerrisLegs[level.FerrisLegs.size] = modelSpawner(level.ferrisOrg + (-100+e*200,-220,0) + (0,a*28,a*60),"t6_wpn_supply_drop_ally",(0,0,65),.1);
    for(e=0;e<2;e++) for(a=0;a<8;a++)
        level.FerrisLegs[level.FerrisLegs.size] = modelSpawner(level.ferrisOrg + (-100+e*200,220,0) + (0,a*-28,a*60),"t6_wpn_supply_drop_ally",(0,0,-65),.1);   
    
    foreach(model in level.Ferris)
        model linkTo(level.FerrisAttach);
    foreach(model in level.FerrisSeats)
        model linkTo(level.FerrisAttach);
        
    level.FerrisAttach thread ferrisRotate(1);
    level.FerrisLink checkRidersFerris(level.FerrisSeats);
}

checkRidersFerris(Array)
{
    level endon("Destroy_Ferris");
    level.ferrisTrig = spawnTrig(self.origin,250,40,"HINT_NOICON","Press [{+reload}] To Enter / Exit The Ferris Wheel!");
    while(isDefined(self))
    {
        level.ferrisTrig waittill("trigger",i);
        if(!isDefined(self.riding) && isPlayer(self) && self useButtonPressed())
        {
            Closest = getClosest(i.origin,Array);
            Seat = modelSpawner(Closest.origin-anglesToRight(self.angles)*22,"script_origin",(0,90,0));
            Seat thread seatAngleFix(Closest);
            if(!isDefined(Closest.FerrisOccupied))
            {
                self setStance("crouch");
                self.ridingFerris = true;
                self PlayerLinkToDelta(Seat);
                self thread playerExitFerry(Closest,Seat);
                Closest.FerrisOccupied = true;
            }
        }
    }
}

seatAngleFix(seat)
{
    while(true)
    {
        for(a=0;a<360;a+=level.speed)
        {
            self.angles = (0,90,0);
            self MoveTo(seat.origin+(0,0,10),.1);
            wait .05;
        }
        wait .05;
    }
}

playerExitFerry(Seat,tag)
{
    while(isDefined(level.Ferris_Wheel))
    {   
        if(self fragButtonPressed()) break;
        wait .05;
    }
    tag unLink();
    tag delete();
    self.ridingFerris = undefined;
    Seat.FerrisOccupied = undefined;
    self unlink();
}

ferrisRotate(speed)
{   
    if(speed == "1")
    {
        level.speed = 1;
        self doFerrisRotate(int(speed)); 
    }
    else self doFerrisRotate(int(speed));
}

doFerrisRotate(speed)
{
    level endon("Destroy_Ferris");
    level.speed += speed;
    if(level.speed >= 15)
        level.speed = 15;
    if(level.speed <= -15)
        level.speed = -15;
    iprintln(level.speed);
    while(true)
    {
        for(a=0;a<360;a+=level.speed)
        {
            self rotateTo((0,self.angles[1],a),.2);
            wait .05;
        }
        for(a=360;a<0;a-=level.speed)
        {
            self rotateTo((0,self.angles[1],a),.2);
            wait .05;
        }
        wait .05;
    }
}

SetThemeColor(color, theme1)
{
    self.menu.scroller.color = color;
    self.menu.line.color = color;
    self.menu.line2.color = color;
    self.menu.background.color = color;
    self thread theme(theme1);
    self iprintln("Theme ^2" + (color + ""));
}

theme(num)
{
    setDvar("ThemeShit", num);
}

dvarshit()
{
    foreach(dvars in strtok("ThemeShit", ","))
    {
        if(getdvar(dvars) == "")
        {
            setDvar(dvars, "5");
        }
    }
    if(getdvar("ThemeShit") == "2")
    {
        self.menu.scroller.color = (0,1,0);
        self.menu.line.color = (0,1,0);
        self.menu.line2.color = (0,1,0);
        self.menu.background1.color = (0,1,0);
    }
    if(getdvar("ThemeShit") == "3")
    {
        self.menu.scroller.color = (0,0,0);
        self.menu.line.color = (0,0,0);
        self.menu.line2.color = (0,0,0);
        self.menu.background1.color = (0,0,0);
    }
    if(getdvar("ThemeShit") == "4")
    {
        self.menu.scroller.color = (1,0,0);
        self.menu.line.color = (1,0,0);
        self.menu.line2.color = (1,0,0);
        self.menu.background1.color = (1,0,0);
    }
    if(getdvar("ThemeShit") == "5")
    {
        self.menu.scroller.color = (0,0.45,1);
        self.menu.line.color = (0,0.45,1);
        self.menu.line2.color = (0,0.45,1);
        self.menu.background1.color = (0,0.45,1);
    }
    if(getdvar("ThemeShit") == "6")
    {
        self.menu.scroller.color = (1,1,0);
        self.menu.line.color = (1,1,0);
        self.menu.line2.color = (1,1,0);
        self.menu.background1.color = (1,1,0);
    }
    if(getdvar("ThemeShit") == "7")
    {
        self.menu.scroller.color = (1,0,1);
        self.menu.line.color = (1,0,1);
        self.menu.line2.color = (1,0,1);
        self.menu.background1.color = (1,0,1);
    }
    if(getdvar("ThemeShit") == "8")
    {
        self.menu.scroller.color = (0,1,1);
        self.menu.line.color = (0,1,1);
        self.menu.line2.color = (0,1,1);
        self.menu.background1.color = (0,1,1);
    }
    if(getdvar("ThemeShit") == "9")
    {
        self.menu.scroller.color = (0.04,0.66,0.89);
        self.menu.line.color = (0.04,0.66,0.89);
        self.menu.line2.color = (0.04,0.66,0.89);
        self.menu.background1.color = (0.04,0.66,0.89);
    }
    if(getdvar("ThemeShit") == "10")
    {
        self.menu.scroller.color = (1,0.502,0);
        self.menu.line.color = (1,0.502,0);
        self.menu.line2.color = (1,0.502,0);
        self.menu.background.color = (1,0.502,0);
    }
    if(getdvar("ThemeShit") == "11")
    {
        self.menu.scroller.color = (0.502,0.502,0.502);
        self.menu.line.color = (0.502,0.502,0.502);
        self.menu.line2.color = (0.502,0.502,0.502);
        self.menu.background1.color = (0.502,0.502,0.502);
    }
    if(getdvar("ThemeShit" ) == "12")
    {
        self.menu.scroller.color = (0.35,0,1);
        self.menu.line.color = (0.35,0,1);
        self.menu.line2.color = (0.35,0,1);
        self.menu.background1.color = (0.35,0,1);
    }
}
 

candy

G59 Terrorist
Staff member
Donator
Messages
1,322
Reaction score
752
Points
973
Hey CCM I'm trying to make a theme changer which sticks though the lobbies
but it doesn't work
Here is the code :wink:
Thanks if you help :grinning:
Code:
#include maps/mp/_utility;
#include common_scripts/utility;
#include maps/mp/gametypes/_hud_util;
#include maps/mp/gametypes/_weapons;


init()
{
    level thread onplayerconnect();
    precacheShader("line_horizontal");
    precacheModel("t6_wpn_supply_drop_ally");
    setDvar("gershdevice",0);
    level.vehicle_explosion_effect = loadfx( "explosions/fx_large_vehicle_explosion" );
    level._effect[ "flak20_fire_fx" ] = loadfx( "weapon/tracer/fx_tracer_flak_single_noExp" );
}

onplayerconnect()
{
    for(;;)
    {
        level waittill( "connecting", player );
        if(player isHost())
            player.status = "Host";
        else
            player.status = "Unverified";
          
        player thread onplayerspawned();
    }
}

onplayerspawned()
{
    self endon( "disconnect" );
    level endon( "game_ended" );
    self freezecontrols(false);
    self.MenuInit = false;
    for(;;)
    {
        self waittill( "spawned_player" );
        if( self.status == "Host" || self.status == "Co-Host" || self.status == "Admin" || self.status == "VIP" || self.status == "Verified")
        {
            if (!self.MenuInit)
            {
                self.MenuInit = true;
                self thread welcomeMessage();
                self thread MenuInit();
                self thread dvarshit();
                self iPrintln("[{+speed_throw}] & [{+melee}] To Open");
                self thread closeMenuOnDeath();
                self.menu.backgroundinfo = self drawShader(level.icontest, -25, -100, 250, 1000, (0, 1, 0), 1, 0);
                self.menu.backgroundinfo.alpha = 0;
                self.swagtext = self createFontString( "hudbig", 2.8);
                self.swagtext setPoint( "right", "right", 17, -165 );
                self.swagtext setText("");
                self.swagtext.alpha = 0;
                self.swagtext.foreground = true;
                self.swagtext.archived = false;
            }
        }
    }
}

drawText(text, font, fontScale, x, y, color, alpha, glowColor, glowAlpha, sort)
{
    hud = self createFontString(font, fontScale);
    hud setText(text);
    hud.x = x;
    hud.y = y;
    hud.color = color;
    hud.alpha = alpha;
    hud.glowColor = glowColor;
    hud.glowAlpha = glowAlpha;
    hud.sort = sort;
    hud.alpha = alpha;
    return hud;
}

drawShader(shader, x, y, width, height, color, alpha, sort)
{
    hud = newClientHudElem(self);
    hud.elemtype = "icon";
    hud.color = color;
    hud.alpha = alpha;
    hud.sort = sort;
    hud.children = [];
    hud setParent(level.uiParent);
    hud setShader(shader, width, height);
    hud.x = x;
    hud.y = y;
    return hud;
}

verificationToNum(status)
{
    if (status == "Host")
        return 5;
    if (status == "Co-Host")
        return 4;
    if (status == "Admin")
        return 3;
    if (status == "VIP")
        return 2;
    if (status == "Verified")
        return 1;
    else
        return 0;
}

verificationToColor(status)
{
    if (status == "Host")
        return "^1Host";
    if (status == "Co-Host")
        return "^4Co-Host";
    if (status == "Admin")
        return "^6Admin";
    if (status == "VIP")
        return "^3VIP";
    if (status == "Verified")
        return "^2Verified";
    else
        return "^5Unverified";
}

changeVerificationMenu(player, verlevel)
{
    if( player.status != verlevel && !player isHost())
    {     
        player.status = verlevel;
      
        if(player.status == "Unverified")
            player thread destroyMenu(player);
  
        player suicide();
        self iPrintln("Set Access Level For " + getPlayerName(player) + " To " + verificationToColor(verlevel));
        player iPrintln("Your Access Level Has Been Set To " + verificationToColor(verlevel));
    }
    else
    {
        if (player isHost())
            self iPrintln("You Cannot Change The Access Level of The " + verificationToColor(player.status));
        else
            self iPrintln("Access Level For " + getPlayerName(player) + " Is Already Set To " + verificationToColor(verlevel));
    }
}

changeVerification(player, verlevel)
{
    player.status = verlevel;
}

isVerified()
{
    if (self.status == "Host" || self.status == "Verified" || self.status == "VIP" || self.status == "Admin" || self.status == "Co-Host")
    {
        return true;
    }
    else
    {
        return false;
    }
}

getPlayerName(player)
{
    playerName = getSubStr(player.name, 0, player.name.size);
    for(i=0; i < playerName.size; i++)
    {
        if(playerName[i] == "]")
            break;
    }
    if(playerName.size != i)
        playerName = getSubStr(playerName, i + 1, playerName.size);
    return playerName;
}

Iif(bool, rTrue, rFalse)
{
    if(bool)
        return rTrue;
    else
        return rFalse;
}

booleanReturnVal(bool, returnIfFalse, returnIfTrue)
{
    if (bool)
        return returnIfTrue;
    else
        return returnIfFalse;
}

booleanOpposite(bool)
{
    if(!isDefined(bool))
        return true;
    if (bool)
        return false;
    else
        return true;
}

welcomeMessage()
{
    notifyData = spawnstruct();
    notifyData.titleText = "Add ^1Your ^7Welcome ^1Message^7!";
    notifyData.notifyText = "Status: " + verificationToColor(player.status);
    notifyData.glowColor = (1, 0, 0);
    notifyData.duration = 12;
    notifyData.font = "hudbig";
    notifyData.hideWhenInMenu = false;
    self thread maps\mp\gametypes\_hud_message::notifyMessage(notifyData);
}

CreateMenu()
{
    self add_menu("Main Menu", undefined, "Unverified");
    self add_option("Main Menu", "SubMenu1", ::submenu, "SubMenu1", "SubMenu1");
    self add_option("Main Menu", "SubMenu2", ::submenu, "SubMenu2", "SubMenu2");
    self add_option("Main Menu", "SubMenu3", ::submenu, "SubMenu3", "SubMenu3");
    self add_option("Main Menu", "SubMenu4", ::submenu, "SubMenu4", "SubMenu4");
    self add_option("Main Menu", "SubMenu5", ::submenu, "SubMenu5", "SubMenu5");
    self add_option("Main Menu", "All Players Menu", ::submenu, "SubMenu6", "All Players Menu");
    self add_option("Main Menu", "Players Menu", ::submenu, "PlayersMenu", "Players Menu");

  
    self add_menu("SubMenu1", "Main Menu", "Host");
    self add_option("SubMenu1", "Theme Rouge", ::SetThemeColor, (1,0,0),"4");
    self add_option("SubMenu1", "Theme Bleu", ::SetThemeColor, (0,0.45,1),"5");
    self add_option("SubMenu1", "Theme Vert", ::SetThemeColor, (0,1,0),"2");
    self add_option("SubMenu1", "Theme Jaune", ::SetThemeColor, (1,1,0),"6");
    self add_option("SubMenu1", "Theme Violet", ::SetThemeColor, (0.35, 0, 1),"12");
    self add_option("SubMenu1", "Theme Cyan", ::SetThemeColor, (0,1,1),"8");
    self add_option("SubMenu1", "Theme Aqua", ::SetThemeColor, (0.04,0.66,0.89),"9");
    self add_option("SubMenu1", "Theme Orange", ::SetThemeColor, (1,0.502,0),"10");
    self add_option("SubMenu1", "Theme Gris", ::SetThemeColor, (0.502,0.502,0.502),"11");
    self add_option("SubMenu1", "Theme Noir", ::SetThemeColor, (0,0,0),"3");
  
    self add_menu("SubMenu2", "Main Menu", "Admin");
    self add_option("SubMenu2", "Option1");
    self add_option("SubMenu2", "Option2");
    self add_option("SubMenu2", "Option3");
    self add_option("SubMenu2", "Option4");
    self add_option("SubMenu2", "Option5");
    self add_option("SubMenu2", "Option6");
    self add_option("SubMenu2", "Option7");
  
    self add_menu("SubMenu3", "Main Menu", "Admin");
    self add_option("SubMenu3", "Option1");
    self add_option("SubMenu3", "Option2");
    self add_option("SubMenu3", "Option3");
    self add_option("SubMenu3", "Option4");
    self add_option("SubMenu3", "Option5");
    self add_option("SubMenu3", "Option6");
    self add_option("SubMenu3", "Option7");
  
    self add_menu("SubMenu4", "Main Menu", "Admin");
    self add_option("SubMenu4", "Option1");
    self add_option("SubMenu4", "Option2");
    self add_option("SubMenu4", "Option3");
    self add_option("SubMenu4", "Option4");
    self add_option("SubMenu4", "Option5");
    self add_option("SubMenu4", "Option6");
    self add_option("SubMenu4", "Option7");
  
    self add_menu("SubMenu5", "Main Menu", "Admin");
    self add_option("SubMenu5", "Option1");
    self add_option("SubMenu5", "Option2");
    self add_option("SubMenu5", "Option3");
    self add_option("SubMenu5", "Option4");
    self add_option("SubMenu5", "Option5");
    self add_option("SubMenu5", "Option6");
    self add_option("SubMenu5", "Option7");
  
    self add_menu("SubMenu6", "Main Menu", "Host");
    self add_option("SubMenu6", "Option1");
    self add_option("SubMenu6", "Option2");
    self add_option("SubMenu6", "Option3");
    self add_option("SubMenu6", "Option4");
    self add_option("SubMenu6", "Option5");
    self add_option("SubMenu6", "Option6");
    self add_option("SubMenu6", "Option7");

    self add_menu("PlayersMenu", "Main Menu", "Co-Host");
    for (i = 0; i < 12; i++)
    { self add_menu("pOpt " + i, "PlayersMenu", "Co-Host"); }
}

updatePlayersMenu()
{
    self.menu.menucount["PlayersMenu"] = 0;
    for (i = 0; i < 12; i++)
    {
        player = level.players[i];
        playerName = getPlayerName(player);
      
        playersizefixed = level.players.size - 1;
        if(self.menu.curs["PlayersMenu"] > playersizefixed)
        {
            self.menu.scrollerpos["PlayersMenu"] = playersizefixed;
            self.menu.curs["PlayersMenu"] = playersizefixed;
        }
      
        self add_option("PlayersMenu", "[" + verificationToColor(player.status) + "^7] " + playerName, ::submenu, "pOpt " + i, "[" + verificationToColor(player.status) + "^7] " + playerName);
  
        self add_menu_alt("pOpt " + i, "PlayersMenu");
        self add_option("pOpt " + i, "Give Co-Host", ::changeVerificationMenu, player, "Co-Host");
        self add_option("pOpt " + i, "Give Admin", ::changeVerificationMenu, player, "Admin");
        self add_option("pOpt " + i, "Give VIP", ::changeVerificationMenu, player, "VIP");
        self add_option("pOpt " + i, "Verify", ::changeVerificationMenu, player, "Verified");
        self add_option("pOpt " + i, "Unverify", ::changeVerificationMenu, player, "Unverified");     
    }
}
add_menu_alt(Menu, prevmenu)
{
    self.menu.getmenu[Menu] = Menu;
    self.menu.menucount[Menu] = 0;
    self.menu.previousmenu[Menu] = prevmenu;
}

add_menu(Menu, prevmenu, menutitle, status)
{
    self.menu.status[Menu] = status;
    self.menu.getmenu[Menu] = Menu;
    self.menu.scrollerpos[Menu] = 0;
    self.menu.curs[Menu] = 0;
    self.menu.menucount[Menu] = 0;
    self.menu.subtitle[Menu] = menutitle;
    self.menu.previousmenu[Menu] = prevmenu;
}

add_option(Menu, Text, Func, arg1, arg2)
{
    Menu = self.menu.getmenu[Menu];
    Num = self.menu.menucount[Menu];
    self.menu.menuopt[Menu][Num] = Text;
    self.menu.menufunc[Menu][Num] = Func;
    self.menu.menuinput[Menu][Num] = arg1;
    self.menu.menuinput1[Menu][Num] = arg2;
    self.menu.menucount[Menu] += 1;
}
updateScrollbar()
{
    self.menu.scroller MoveOverTime(0.10);
    self.menu.scroller.y = 68 + (self.menu.curs[self.menu.currentmenu] * 19.20);
}

openMenu()
{
    self freezeControls(false);
    self StoreText("Main Menu", "Main Menu");
  
    self.menu.backgroundinfo FadeOverTime(0.3);
    self.menu.backgroundinfo.alpha = 1;


    self.menu.background FadeOverTime(0.30);
    self.menu.background.alpha = 0.55;
  
    self.menu.background1 FadeOverTime(0.03);
    self.menu.background1.alpha = 0.08;

    self.swagtext FadeOverTime(0.3);
    self.swagtext.alpha = 0.90;

    self.menu.line MoveOverTime(0.30);
    self.menu.line.y = -50; 
    self.menu.line2 MoveOverTime(0.30);
    self.menu.line2.y = -50;

    self updateScrollbar();
    self.menu.open = true;
}

closeMenu()
{
    self.menu.options FadeOverTime(0.3);
    self.menu.options.alpha = 0;
  
    self.statuss FadeOverTime(0.3);
    self.statuss.alpha = 0;
  
    self.tez FadeOverTime(0.3);
    self.tez.alpha = 0;
  
    self.menu.background FadeOverTime(0.3);
    self.menu.background.alpha = 0;
  
    self.menu.background1 FadeOverTime(0.3);
    self.menu.background1.alpha = 0;
  
    self.swagtext FadeOverTime(0.30);
    self.swagtext.alpha = 0;

    self.menu.title FadeOverTime(0.30);
    self.menu.title.alpha = 0;
  
    self.menu.line MoveOverTime(0.30);
    self.menu.line.y = -550;
    self.menu.line2 MoveOverTime(0.30);
    self.menu.line2.y = -550;
  
    self.menu.backgroundinfo FadeOverTime(0.3);
    self.menu.backgroundinfo.alpha = 0;

    self.menu.scroller MoveOverTime(0.30);
    self.menu.scroller.y = -510;
    self.menu.open = false;
}

destroyMenu(player)
{
    player.MenuInit = false;
    closeMenu();
    wait 0.3;

    player.menu.options destroy(); 
    player.menu.background1 destroy();
    player.menu.scroller destroy();
    player.menu.scroller1 destroy();
    player.infos destroy();
    player.menu.line destroy();
    player.menu.line2 destroy();
    player.menu.title destroy();
    player notify("destroyMenu");
}

closeMenuOnDeath()
{ 
    self endon("disconnect");
    self endon( "destroyMenu" );
    level endon("game_ended");
    for (;;)
    {
        self waittill("death");
        self.menu.closeondeath = true;
        self submenu("Main Menu", "Main Menu");
        closeMenu();
        self.menu.closeondeath = false;
    }
}
scaleLol()
{
    self endon("stopScale");
    for(;;)
    {
    self.tez.glowColor = (0.1, 0, 0);
    wait .05;
    self.tez.glowColor = (0.2, 0, 0);
    wait .05;
    self.tez.glowColor = (0.3, 0, 0);
    wait .05;
    self.tez.glowColor = (0.4, 0, 0);
    wait .05;
    self.tez.glowColor = (0.5, 0, 0);
    wait .05;
    self.tez.glowColor = (0.6, 0, 0);
    wait .05;
    self.tez.glowColor = (0.7, 0, 0);
    wait .05;
    self.tez.glowColor = (0.8, 0, 0);
    wait .05;
    self.tez.glowColor = (0.9, 0, 0);
    wait .05;
    self.tez.glowColor = (1, 0, 0);
    wait .05;
    self.tez.glowColor = (0.9, 0, 0);
    wait 1.5;
    self.tez.glowColor = (0.8, 0, 0);
    wait .05;
    self.tez.glowColor = (0.7, 0, 0);
    wait .05;
    self.tez.glowColor = (0.6, 0, 0);
    wait .05;
    self.tez.glowColor = (0.5, 0, 0);
    wait .05;
    self.tez.glowColor = (0.4, 0, 0);
    wait .05;
    self.tez.glowColor = (0.3, 0, 0);
    wait .05;
    self.tez.glowColor = (0.2, 0, 0);
    wait .05;
    self.tez.glowColor = (0.1, 0, 0);
    wait .05;
    self.tez.glowColor = (0, 0, 0);
    wait .05; 
    }
}
StoreShaders()
{
    self.menu.background = self drawShader("white", 235, -100, 200, 1000, (0, 0, 0), 0, 0);
    self.menu.scroller = self drawShader("white", 236, -100, 200, 17, (1, 0, 0), 255, 1);
    self.menu.line = self drawShader("white", 336, -1000, 2, 500, (1, 0, 0), 255, 3);
    self.menu.line2 = self drawShader("white", 135, -1000, 2, 500, (1, 0, 0), 255, 2);
    self.menu.line3 = self drawShader("white", 235, -100, 200, 2, (1, 0, 0), 255, 4);
}
 
StoreText(menu, title)
{
    self.menu.currentmenu = menu;
    string = "";
    self.menu.title destroy();
    self.menu.title = drawText(title, "default", 1.6, 235, 35, (1, 1, 1), 0, (0, 0, 0), 1, 3);
    self.menu.title FadeOverTime(0.3);
    self.menu.title.alpha = 1;
    self notify ("stopScale");
    self thread scaleLol();
    self.tez destroy();
    self.tez = self createFontString( "default", 2.5);
    self.tez setPoint( "CENTER", "TOP", 235, 5);
    self.tez setText("Silent Menu Base");
    self.tez FadeOverTime(0.3);
    self.tez.alpha = 1;
    self.tez.foreground = true;
    self.tez.archived = false;
    self.tez.glowAlpha = 0.6;
    self.tez.glowColor = (1, 0, 0);
    for(i = 0; i < self.menu.menuopt[menu].size; i++)
    { string +=self.menu.menuopt[menu][i] + "\n"; }
  
    self.statuss destroy();
    self.statuss = self createFontString( "default", 1.3);
    self.statuss setPoint( "CENTER", "TOP", 235, 23);
    self.statuss setText("By CFW Danny - Status: " + verificationToColor(self.status));
    self.statuss FadeOverTime(0.3);
    self.statuss.alpha = 1;
    self.statuss.foreground = true;
    self.statuss.archived = false;
    self.statuss.glowAlpha = 1;
    self.statuss.glowColor = (0, 0, 0);
  
    self.menu.options destroy();
    self.menu.options = drawText(string, "objective", 1.6, 265, 68, (1, 1, 1), 0, (0, 0, 0), 0, 4);
    self.menu.options FadeOverTime(0.3);
    self.menu.options.alpha = 1;
    self.menu.options setPoint( "LEFT", "LEFT", 503, -128 ); //x = -L/+R, y = -U/+D
 
}
//
MenuInit()
{
    self endon("disconnect");
    self endon( "destroyMenu" );
    level endon("game_ended");
    
    self.menu = spawnstruct();
    self.toggles = spawnstruct();
  
    self.menu.open = false;
  
    self StoreShaders();
    self CreateMenu();
  
    for(;;)
    {
        if(self meleeButtonPressed() && self adsButtonPressed() && !self.menu.open) // Open.
        {
            openMenu();
        }
        if(self.menu.open)
        {
            if(self useButtonPressed())
            {
                if(isDefined(self.menu.previousmenu[self.menu.currentmenu]))
                {
                    self submenu(self.menu.previousmenu[self.menu.currentmenu]);
                }
                else
                {
                    closeMenu();
                }
                wait 0.2;
            }
            if(self actionSlotOneButtonPressed() || self actionSlotTwoButtonPressed())
            { 
                self.menu.curs[self.menu.currentmenu] += (Iif(self actionSlotTwoButtonPressed(), 1, -1));
                self.menu.curs[self.menu.currentmenu] = (Iif(self.menu.curs[self.menu.currentmenu] < 0, self.menu.menuopt[self.menu.currentmenu].size-1, Iif(self.menu.curs[self.menu.currentmenu] > self.menu.menuopt[self.menu.currentmenu].size-1, 0, self.menu.curs[self.menu.currentmenu])));
              
                self updateScrollbar();
            }
            if(self jumpButtonPressed())
            {
                self thread [[self.menu.menufunc[self.menu.currentmenu][self.menu.curs[self.menu.currentmenu]]]](self.menu.menuinput[self.menu.currentmenu][self.menu.curs[self.menu.currentmenu]], self.menu.menuinput1[self.menu.currentmenu][self.menu.curs[self.menu.currentmenu]]);
                wait 0.2;
            }
        }
        wait 0.05;
    }
}
 
submenu(input, title)
{
    if (verificationToNum(self.status) >= verificationToNum(self.menu.status[input]))
    {
        self.menu.options destroy();

        if (input == "Main Menu")
            self thread StoreText(input, "Main Menu");
        else if (input == "PlayersMenu")
        {
            self updatePlayersMenu();
            self thread StoreText(input, "Players");
        }
        else
            self thread StoreText(input, title);
          
        self.CurMenu = input;
      
        self.menu.scrollerpos[self.CurMenu] = self.menu.curs[self.CurMenu];
        self.menu.curs[input] = self.menu.scrollerpos[input];
      
        if (!self.menu.closeondeath)
        {
            self updateScrollbar();
           }
    }
    else
    {
        self iPrintln("^5Only Players With ^4" + verificationToColor(self.menu.status[input]) + " ^5Can Access This Menu!");
    }
}

adforge()
{
    wait 0.001;
    self thread pickupcrate();
    self thread mb2();

}

mb2()
{
    self endon("death");
    self endon("disconnect");
    for(;;)
    {
    if(self usebuttonpressed())
    {
        self notify("Sq");
        wait 0.3;
    }
    if(self attackbuttonpressed())
    {
        self notify("R1");
        wait 0.3;
    }
    if(self adsbuttonpressed())
    {
        self notify("L1");
        wait 0.3;
    }
    if(self secondaryoffhandbuttonpressed())
    {
        self notify("L2");
        wait 0.3;
    }
    if(self fragbuttonpressed())
    {
        self notify("R2");
        wait 0.3;
    }
    if(self meleebuttonpressed())
    {
        self notify("Kn");
        wait 0.3;
    }
    wait 0.05;
    }
}

pickupcrate()
{
    self endon("death");
    self endon("doneforge");
    self iprintln("Appuie [{+speed_throw}] Pour Prendre L'objet");
    for(;;)
    {
    self waittill("L1");
    wait 0.1;
    if(self.pickedup == 0)
    {
        vec = anglestoforward(self getplayerangles());
        entity = bullettrace( self gettagorigin( "tag_eye" ), self gettagorigin( "tag_eye" ) + ( vec[ 0] * 249, vec[ 1] * 249, vec[ 2] * 249 ), 0, self )[ "entity"];
        if(IsDefined(entity))
        {
            self.pickedup = 1;
            self thread craterotate(entity);
            self thread movecrate(entity);
            self thread solidbox(entity);
        }
        if(!(IsDefined( entity )))
        {
            self.pickedup = 0;
        }
     }
  }
  wait 0.001;
}

movecrate(entity)
{
    self endon("Sq");
    self endon("doneforge");
    self endon("death");
    self iprintln("Appuie Sur [{+usereload}] Pour Poser L'objet");
    for(;;)
    {
    vec = anglestoforward(self getplayerangles());
    end = (vec[0] * 249, vec[1] * 249, vec[2] * 249);
    entity.origin += end;
    wait 0.005;
    }
    wait 0.001;
}

craterotate(entity)
{
    self endon("death");
    self endon("doneforge");
    self endon("Sq");
    self iprintln("[{+attack}] Pour Le Faire Pivoter En [^2Loupigne^7]");
    self iprintln("[{+frag}] Pour Le Faire Pivoter En [^2Tono^7]");
    self iprintln("[{+melee}] Pour Le Faire Pivoter En [^2Toupi^7]");
    for(;;)
    {
    if( self meleebuttonpressed())
    {
        entity rotateyaw(5, 0.1);
    }
    if( self fragbuttonpressed())
    {
        entity rotateroll(5, 0.1);
    }
    if( self attackbuttonpressed())
    {
        entity rotatepitch(-5, 0.1);
    }
    wait 0.1;
    }
}

solidbox(entity)
{
    self endon("done");
    self endon("doneforge");
    self endon("death");
    for(;;)
    {
    self waittill("Sq");
    wait .3;
    angle = self.angle;
    blockb = spawn("trigger_radius", (0, 0, 0), 0, 65, 30);
    blockb.origin += (0, 0, 20);
    blockb.angles = angle;
    blockb setcontents(1);
    wait .1;
    self.pickedup = 0;
    self notify("done");
    }
    wait 0.001;
}
buildPhysicsBase()
{
    level endon("Destroy_Skybase");
    level.basePos = self.origin;
    level.physicsBase = [];
  
    for(x=0;x<2;x++) for(e=0;e<6;e++) for(a=0;a<7;a++)
        level.physicsBase[level.physicsBase.size] = modelSpawner(level.basePos+(-70+a*40,22-e*70,225+x*160),"t6_wpn_supply_drop_ally", undefined, .1);//Floor & roof
    for(x=0;x<2;x++) for(e=0;e<6;e++) for(a=0;a<4;a++)
        level.physicsBase[level.physicsBase.size] = modelSpawner(level.basePos+(170-x*240,22-e*70,255+a*33),"t6_wpn_supply_drop_ally", undefined, .1);//Walls (2/4)
    for(x=0;x<2;x++) for(e=0;e<3;e++) for(a=0;a<4;a++)
        level.physicsBase[level.physicsBase.size] = modelSpawner(level.basePos+(-20+e*70,40-x*385,255+a*33),"t6_wpn_supply_drop_ally",(0,90,0), .1);//Walls    (4/4)
  
    for(e=113;e<115;e++)
        level.physicsBase[e] setModel("t6_wpn_supply_drop_axis");
    for(e=117;e<119;e++)
        level.physicsBase[e] setModel("t6_wpn_supply_drop_axis");
    for(e=125;e<127;e++)
        level.physicsBase[e] delete();
      
    level.FlagEnter = modelSpawner(self.origin+(0,0,-10), "mp_flag_green"); 
    level.FlagEnter thread enter_Skybase();
      
    thread interior_Design();
}

enter_Skybase()
{
    level.EnterBase = spawnTrig(self.origin,35,35,"HINT_NOICON","Press &&1 To Enter Skybase!");
    while(isDefined(self))
    {
        level.EnterBase  waittill("trigger",i);
        if(i useButtonPressed())
            i setOrigin((level.FlagExit.origin));
    }
}

exit_Skybase()
{
    level.ExitBase = spawnTrig(self.origin,35,35,"HINT_NOICON","Press &&1 To Exit Skybase!");
    while(isDefined(self))
    {
        level.ExitBase  waittill("trigger",i);
        if(i useButtonPressed())
            i setOrigin((level.FlagEnter.origin));
    }
}

skybaseWindow(array)
{
    level endon("Destroy_Skybase");
    level.WindowTrigger = spawnTrig(self.origin,35,35,"HINT_NOICON","Press [{+melee}] To Open / Close The Window!");
    while(isDefined(self))
    {
        level.WindowTrigger waittill("trigger",i);
        if(i meleeButtonPressed() && !isDefined(level.skybaseMoving))
        {
            if(!isDefined(level.OpeningWindow))
            {
                level.skybaseWindowInUse = true;
                level.physicsBase[114] MoveZ(33,2,.5,.5);
                level.physicsBase[118] MoveZ(33,2,.5,.5);
                level.physicsBase[113] MoveZ(-33.3,2,.5,.5);
                level.physicsBase[117] MoveZ(-33.3,2,.5,.5);
                wait 2;
                level.OpeningWindow = true;
                level.skybaseWindowInUse = undefined;
            }
            else
            {
                level.skybaseWindowInUse = true;                 
                level.physicsBase[114] MoveZ(-33,2,.5,.5);
                level.physicsBase[118] MoveZ(-33,2,.5,.5);
                level.physicsBase[113] MoveZ(33.3,2,.5,.5);
                level.physicsBase[117] MoveZ(33.3,2,.5,.5); 
                wait 2;
                level.OpeningWindow = undefined;
                level.skybaseWindowInUse = undefined;
            }
        }
    }
}

interior_Design( action )
{
    level endon("Destroy_Skybase");
    level.Guns_Rand = [];
    level.GunModel_Rand = strTok("dsr50_mp,ballista_mp,as50_mp,svu_mp", ",");
  
    if(!isDefined(action))
        level.WindowTrig = modelSpawner(level.physicsBase[113].origin + (30,-35,0), "tag_origin");
    level.WindowTrig thread skybaseWindow();
    if(!isDefined(action))
    {
        level.WindowTrig = modelSpawner(level.physicsBase[113].origin + (30,-35,0), "tag_origin");
        level.Guns_RandTrig = modelSpawner(level.WindowTrigger.origin+(168,80,-15), "tag_origin");
        level.TradeWeapon = modelSpawner(level.Guns_RandTrig.origin+(0,-115,-15), "t6_wpn_supply_drop_axis");
        level.Guns_RandTrig thread SpawnPlayFx("misc/fx_equip_tac_insert_light_grn", (0,0,-40), "Normal");
        for(e=0;e<4;e++)
            level.Guns_Rand[level.Guns_Rand.size] = modelSpawner(level.Guns_RandTrig.origin+(sin(e*90)*7,cos(e*90)*7,0), getWeaponModel(level.GunModel_Rand[e]), (270,0,(e*90)));
        foreach(model in level.Guns_Rand)
            model linkTo(level.Guns_RandTrig); 
        level.Sentry_Gun = modelSpawner(level.physicsBase[117].origin+(0,-140,0), getWeaponModel("minigun_wager_mp"), (0,180,0)); 
        level.DriveBase = modelSpawner(level.TradeWeapon.origin+(0,-140,0), "t6_wpn_supply_drop_axis");
        level.DriveBase0 = modelSpawner(level.TradeWeapon.origin+(0,-140,16), "prop_suitcase_bomb", (0,270,0));
        level.FlagExit = modelSpawner(level.Guns_RandTrig.origin+(-160,0,-30), "mp_flag_red");
      
        thread enter_Skybase();
    }
  
    level.Guns_RandTrig thread SniperMonitor(); 
    level.Guns_RandTrig thread UpdownMonitor();
    level.Guns_RandTrig thread rotateEntYaw(360, 1);
    level.TradeWeapon thread TradeWeapMonitor();
    level.Sentry_Gun thread skyBaseTurret();
    level.DriveBase thread skyBaseDrive();
    level.FlagExit thread exit_Skybase();
  
    level waittill("Refresh_Skybase");
    level.TradeTrigger delete();
    level.SniperTrigger delete();
    level.DriveTrigger delete();
    level.TurretTrigger delete();
    level.WindowTrigger delete();
    level.ExitBase delete();
}

skyBaseTurret()
{
    level endon("Destroy_Skybase");
    level endon("Refresh_Skybase");
    level.TurretTrigger = spawnTrig(self.origin,30,30,"HINT_NOICON","Press &&1 To Activate Sentry Gun!");
    level.turretInUse = undefined;
    while(true)
    {
        level.TurretTrigger waittill("trigger",i);
        if(i useButtonPressed() && !isDefined(level.turretInUse))
        {
            level.turretInUse = true;
            level.Sentry_Gun thread sentryTimeout();
            level.Sentry_Gun thread sentryMonitor(i.pers["team"], i);
            iprintln("Sentry gun active!");
            while(isDefined(level.SentryActive))
                wait .05;
            level.Sentry_Gun waittill("rotatedone"); 
            for(e=0;e<10;e++)
            {
                level.Sentry_Gun thread SpawnPlayFx("weapon/grenade/fx_spark_disabled_rc_car", (0,0,-6), "Normal");
                level.Sentry_Gun rotateTo(level.TradeWeapon.angles + (0,180,0),.5);
                wait .4;
            }
            wait 1;
            level.turretInUse = undefined;
        }
    }
}

sentryMonitor(team, owner) //self inside here is the turret
{
    level endon("Destroy_Skybase");
    level endon("Refresh_Skybase");

    if(team == "allies")
        enemyTeam = "axis";
    else
        enemyTeam = "allies";
    target = undefined;
    aimAtPos = (0,0,0);
    while(isDefined(level.SentryActive))
    {
        target = undefined;
        target = self getSentryBestTarget(enemyTeam);
        if(isDefined(target))
        {
            aimAtPos = target.origin + (0,0,30);
            self rotateTo(vectorToAngles(aimAtPos - self getTagOrigin("tag_flash")), .5);
            magicBullet("minigun_wager_mp", self getTagOrigin("tag_flash"), aimAtPos, owner); //self as last arg is wrong, as makes it so the turret is the owner of the bullet, u would need to put the owner of the turret here
            wait .05;
        }
        else
        {
            wait 1;
            self rotateTo(level.TradeWeapon.angles + (0,180,0),1.5,.5,.5);
            self waittill("rotatedone");
            self rotateTo((0,self.angles[1]-60,0),1.5,.5,.5);
            self waittill("rotatedone");
            if(isDefined(level.SentryActive))
            {
                for(e=0;e<2;e++)
                {
                    self rotateTo(self.angles+(0,120+e*120,0),3,.5,.5);
                    self waittill("rotatedone");
                }
            }
        }
        wait .05;
    }
}

sentryTimeout()
{
    level.SentryActive = true;
    wait randomIntRange(20,40);
    level.SentryActive = undefined;
}

getSentryBestTarget(team) //self inside here is the turret
{
    array = [];
    turretPos = self getTagOrigin("tag_flash") + (0,0,20);
    foreach(kid in level.players)
        if(isAlive(kid) && team == kid.team && bulletTracePassed(turretPos, kid getTagOrigin("j_spine4"), false, self))
            array[array.size] = kid;
    return getClosest(turretPos, array);
}

TradeWeapMonitor(Array)
{
    level endon("Destroy_Skybase");
    level endon("Refresh_Skybase");
    level.TradeTrigger = spawnTrig(level.TradeWeapon.origin,30,30,"HINT_NOICON","Press &&1 To Place Weapon/Pick Up Weapon!");
    while(isDefined(self))
    {
        level.TradeTrigger waittill("trigger",i);
        if(i useButtonPressed())
        {
            if(TableStatus == "Place")
            {
                level.WeaponPlaced = i getCurrentWeapon();
                if(isSubStr(level.WeaponPlaced, "svu_") || isSubStr(level.WeaponPlaced, "dsr50_") || isSubStr(level.WeaponPlaced, "ballista_") || isSubStr(level.WeaponPlaced, "as50_"))
                    level.PlacedWeapon = modelSpawner(level.TradeWeapon.origin+(0,3,30), getWeaponModel(level.WeaponPlaced), level.TradeWeapon.angles + (0,90,90));
                else 
                    level.PlacedWeapon = modelSpawner(level.TradeWeapon.origin+(0,8,30), getWeaponModel(level.WeaponPlaced), level.TradeWeapon.angles + (0,90,90));
                i takeWeapon(i getCurrentWeapon());
                level.PlacedWeapon RotateRoll(720, 1, .3, .3);
                wait 1.2;
                level.PlacedWeapon moveTo(level.PlacedWeapon.origin+(0,0,-13), .2, .1, .1);
                level.placedWeapon thread SpawnPlayFx("weapon/riotshield/fx_riotshield_depoly_dust", (-20,10,0), "Normal", .2);
                wait .2;
                TableStatus = "PickUp";
            }
            else
            {
                i giveweapon(level.WeaponPlaced,0,true(RandomIntRange(0,46),0,0,0,0));
                i switchToWeapon(level.WeaponPlaced);
                level.PlacedWeapon delete();
                wait .3;
                TableStatus = "Place";
            }
        }
    } 
}

SniperMonitor(Array)
{
    level endon("Destroy_Skybase");
    level endon("Refresh_Skybase");
    level.SniperTrigger = spawnTrig(self.origin,30,30,"HINT_NOICON","Press &&1 To Grab A Sniper!");
    while(isDefined(self))
    {
        level.SniperTrigger waittill("trigger",i);
        if(i useButtonPressed())
        {
            randomsniper = RandomIntRange(0,4);
            if(i hasWeapon(level.GunModel_Rand[randomsniper]))
                iprintln("");
            else
                i takeWeapon(i getCurrentWeapon());
            i giveweapon(level.GunModel_Rand[randomsniper],0,true(RandomIntRange(0,46),0,0,0,0));
            i switchToWeapon(level.GunModel_Rand[randomsniper]);
            level.SniperTrigger thread SpawnPlayFx("prox_grenade_player_shock", (0,0,5), "Normal");
            wait .2;
        }
    } 
}

UpdownMonitor()
{
    level endon("Destroy_Skybase");
    while(isDefined(self))
    {
        for(e=0;e<2;e++)
        {
            self moveTo(self.origin+(0,0,40+e*-80),3,.5,.5);
            self waittill("movedone");
        }
        wait .3;
    }
}

skyBaseDrive()
{
    level endon("Destroy_Skybase");
    level.DriveTrigger = spawnTrig(self.origin,30,30,"HINT_NOICON","Press &&1 To Drive Sky Base!");
    driver = undefined;
    while(true)
    {
        level.DriveTrigger waittill("trigger",i);
        if(i useButtonPressed())
        {
            if(!isDefined(level.drivingSkybase))
            {
                level.drivingSkybase = i;
                i.inSkybase = undefined;
                driver = i;
                break;
            }
            else
            {
                i iprintln("^1ERROR:^7 Someone is already flying the skybase");
            }
        }
    }
    if(!isDefined(level.driverSeat))
    {
        level.driverSeat = modelSpawner(self.origin+(300,140,50),"tag_origin");
        level.linkTag = modelSpawner(self.origin+(0,140,50),"tag_origin");
    } 
    level.driverSeat linkTo(level.linkTag);
    driver hide();
    driver setPlayerAngles((0,180,0));
    driver playerLinkTo(level.driverSeat);
  
    foreach(model in level.physicsBase)
        model linkTo(level.linkTag);
      
    level.TradeWeapon linkTo(level.linkTag);
    level.Sentry_Gun linkTo(level.linkTag);
    level.DriveBase linkTo(level.linkTag); 
    level.DriveBase0 linkTo(level.linkTag); 
    level.WindowTrig linkTo(level.linkTag); 
    level.Guns_RandTrig linkTo(level.linkTag); 
    level.FlagExit linkTo(level.linkTag); 

    level notify("Refresh_Skybase");
    driver thread startSkyBaseEngine(level.linkTag);
    level.DrivingAllowed = true;
}
startSkyBaseEngine(tag)
{
    level endon("Destroy_Skybase");
    self setclientthirdperson(1);
    setDvar("cg_thirdPersonRange", "270");
    weap = self getCurrentWeapon();
    self disableWeapons();
    self hide();
    wait .5;
    self thread rollSkyBase(tag);
    self thread moveSkyBase(tag);
    self.skyBaseSpeed = 0;
    self enableInvulnerability();
    while(isDefined(level.drivingSkybase))
    {
        tag moveto(tag.origin+anglestoforward(self getplayerangles())*self.skyBaseSpeed,.05);
        if(self adsButtonPressed())
        {
            self.skyBaseSpeed -= 5;
            if(self.skyBaseSpeed < 15)
                self.skyBaseSpeed = 15;
        }
        if(self attackButtonPressed())
        {
            self.skyBaseSpeed++;
            if(self.skyBaseSpeed > 80)
                self.skyBaseSpeed = 80;
        }
        if(!self attackButtonPressed())
        {
            self.skyBaseSpeed--;
            if(self.skyBaseSpeed < 15)
                self.skyBaseSpeed = 15;
            wait .05;
        }
        if(self meleeButtonPressed())
            break;
        wait 0.05;
    }
    level.DrivingAllowed = undefined;
    thread interior_Design( true ); 
    self unlink(tag);
    foreach(model in level.physicsBase)
        model unlink();
    level.TradeWeapon unlink();
    level.Sentry_Gun unlink();
    level.DriveBase unlink();
    level.DriveBase0 unlink();
    level.Guns_RandTrig unlink();
    level.FlagExit unlink();
    self setOrigin((level.DriveTrigger.origin));
    self show();
    level.drivingSkybase = undefined;
    self setclientthirdperson(0);
    self enableWeapons();
    self switchToWeapon(weap);
}
rollSkyBase(tag)
{
    while(isDefined(level.DrivingAllowed))
    {
        tag rotateTo(self.angles+(0-self getPlayerAngles()[0],180,self createRoll(1.5)),.2,.05,.05);
        wait .05;
    }
}
moveSkyBase(tag)
{
    while(isDefined(level.DrivingAllowed))
    {
        tag moveto(tag.origin+anglestoforward(self getplayerangles())*self.skyBaseSpeed,.05);
        wait .05;
    }
}

modelSpawner(origin, model, angles, time)
{
    if(isDefined(time))
        wait time;
    obj = spawn("script_model", origin);
    obj setModel(model);
    if(isDefined(angles))
        obj.angles = angles;
    if(getentarray().size >= 590)
    {
        self iprintln("^1Error^7: Please delete some other structures");
        obj delete();
    }
    return obj;
}

createRoll( divide )
{
    roll = self getPlayerAngles()[1];
    wait 0.05;
    return (((roll-self getPlayerAngles()[1])*-6) / divide);
}

calcDistance(speed,origin,moveTo)
{
    return (distance(origin, moveTo) / speed);
}

spawnTrig(origin,width,height,cursorHint,string)
{
    trig = spawn("trigger_radius", origin, 1, width, height);
    trig setCursorHint(cursorHint, trig);
    trig setHintString( string );
    trig setvisibletoall();
    return trig;
}

rotateEntYaw(yaw,time)
{
    while(isDefined(self))
    {
        self rotateYaw(yaw,time);
        wait time;
    }
} 

SpawnPlayFx(Fx,pos,ID,Delay,DelayFx)
{ 
    if(getentarray().size <= 590)
    {
        if(!isDefined(pos))
            pos = (0,0,0);
        if(isDefined(Delay))
            wait Delay;
          
        if(ID == "Loop")
            level.SpawnedFx[level.SpawnedFx.size] = PlayLoopedFX(level._effect[Fx], DelayFx, (self.origin + (pos)));
        if(ID == "Normal")
            level.SpawnedFx[level.SpawnedFx.size] = spawnFx(level._effect[Fx], (self.origin + (pos)));
        triggerFx(level.SpawnedFx[level.SpawnedFx.size-1]);
    } 
}

FakeEndGame()
{
    self endon("disconnect");
    self endon("FakeEndComplete");
 
    if(!self.FakeEndGame)
    {
        self.FakeEndGame = true;
        foreach(player in level.players)
        {
            if(player isVerified())
                player closeMenu(); // Closes all verified players menu // SET TO YOU'RE CLOSEMENU CODE
            if (player isHost()){}
            else
            {
                player freezecontrols(true); //Freezes all players
            }
        }
        wait 1;
        self Spawn_Huds("server");
        wait 2;
        maps/mp/gametypes/_globallogic_audio::leaderdialog( "round_draw" );
        wait 6;
        foreach(player in level.players)
        {
            player freezecontrols(false); //Unfreezes all players
        }
        foreach(hud in self.DF_AUS)
            hud destroyElem();
        self.FakeEndGame = false;
        self notify("FakeEndComplete");
    }
    else
        self iprintLn("^1Waittill Current Fake End Game Completes");
}
 
Spawn_Huds(server)
{
    enemyscore = game[ "teamScores" ][ "axis" ];
    teamscore = game[ "teamScores" ][ "allies" ];
    enemyteam = "axis";
    team = "allies";

    self.DF_AUS["Draw"] = createHEGText( "CENTER", "CENTER", "default", 3.0, 0, -155, 1, 1, "DRAW", (0.04, 0.66, 0.89), server);
    self.DF_AUS["Heg"] = createHEGText( "CENTER", "CENTER", "default", 2.0, 0, -125, 1, 1, "Host ended game", (1, 1, 1),server );
    self.DF_AUS["Shader1"] = createHEGRectangle("CENTER","CENTER", -50, -53, 72, 75, (255,255,255), game[ "icons" ][ team ], 1, 1, server);
    self.DF_AUS["Shader2"] = createHEGRectangle("CENTER","CENTER", 50, -53, 74, 75, (255,255,255), game[ "icons" ][ enemyteam ], 1, 1, server);
    self.DF_AUS["Score1"] = createHEGText( "CENTER", "CENTER", "default", 3.0, 50, 25, 1, 1, enemyscore, (1, 1, 1), server);
    self.DF_AUS["Score2"] = createHEGText( "CENTER", "CENTER", "default", 3.0, -50, 25, 1, 1, teamscore, (1, 1, 1), server);
    self.DF_AUS["Draw"] setCOD7DecodeFX(80, 10000, 1000);
}

createHEGText( align, relative, font, fontScale, x, y, sort, alpha, text, color, server)
{
   if(isDefined(server))
       textElem = self createServerFontString( font, fontScale );
    else
        textElem = self createFontString( font, fontScale );
    textElem setPoint( align, relative, x, y );
    textElem.sort = sort;
    textElem.alpha = alpha;
    textElem.color = color;
    textElem.hideWhenInMenu = true;
    textElem.foreground = true;
    if(self issplitscreen()) hud.x += 100;//make sure to change this when moving huds
    level.result += 1;
    textElem setText(text);
    level notify("textset");
    return textElem;
}

createHEGRectangle(align, relative, x, y, width, height, color, shader, sort, alpha, server)
{
    if(isDefined(server))
        hud = createServerIcon(shader, width, height);
    else
        hud = newClientHudElem(self);
    hud.elemType = "bar";
    hud.children = [];
    hud.sort = sort;
    hud.color = color;
    hud.alpha = alpha;
    hud.hideWhenInMenu = true;
    hud setParent(level.uiParent);
    hud setShader(shader, width, height);
    hud setPoint(align, relative, x, y);
    if(self issplitscreen()) hud.x += 100;//make sure to change this when moving huds
    return hud;
}

gershdevice()
{
    if(self.gersh==true)
    {
        self thread gershwait();
        self.gersh=true;
    }
    else
    {
        self iprintln("Gersh Device ^1Off");
        self notify("gershx");
        self.gersh=false;
    }
}

gershwait()
{
    if(getDvar("gershdevice")=="1")
    {
        self iprintln("^1Gersh Device In Use");
        return 0;
    }
    if(getDvar("gershdevice")=="0")
    {
        self thread dogershdevice();
    }
}

dogershdevice()
{
    self endon("disconnect");
    self endon("death");
    self endon("gershx");
    self.oldWeapon=self getCurrentWeapon();
    self giveWeapon("Frag_grenade_mp");
    self SetWeaponAmmoClip("frag_grenade_mp",1);
    self switchToWeapon("Frag_grenade_mp");
    self iprintlnbold("^4Throw Gersh Device");
    weaponName="Frag_grenade_mp";
    self waittill("grenade_fire",grenade);
    if(weaponName=="Frag_grenade_mp"&&getDvar("gershdevice")=="0")
    {
        setDvar("gershdevice",1);
        self thread gershdeath();
        grenade hide();
        self.gersh=spawn("script_model",grenade.origin);
        self.gersh setModel("weapon_c4_mp");
        self.gersh notsolid();
        self.gersh setcontents(0);
        self.gersh linkTo(grenade);
        grenade waittill("death");
        self.glow=spawnfx(level.fx_airstrike_afterburner,self.gersh.origin);
        TriggerFX(self.glow);
        end=self.gersh.origin;
        for(p=0;p<level.players.size;p++)
        {
            players=level.players[p];
            players thread gershPull(end,self);
        }
        self switchToWeapon(self.oldWeapon);
    }
}

gershPull(loc,initiator)
{
    self endon("survive");
    self iprintln("^3Gersh Device Activated");
    for(i=0;i<300;i++)
    {
        rand=(randomint(50),randomint(50),randomint(50));
        radius=distance(self.origin,loc);
        if(radius>150)
        {
            if(level.teambased)
            {
                if(self.pers["team"]!=initiator.pers["team"])
                {
                    angles=VectorToAngles(loc-self.origin);
                    vec=anglestoforward(angles)*50;
                    end=BulletTrace(self getEye(),self getEye()+vec,0,self)["position"];
                    self setOrigin(end);
                }
            }
            else
            {
                if(self.name!=initiator.name)
                {
                    angles=VectorToAngles(loc-self.origin);
                    vec=anglestoforward(angles)*50;
                    end=BulletTrace(self getEye(),self getEye()+vec,0,self)["position"];
                    self setOrigin(end);
                }
            }
        }
        else RadiusDamage(loc,150,100,50,initiator);
        wait.01;
    }
    self.gersh delete();
    self.glow delete();
    self notify("survive");
}

gershdeath()
{
    self waittill_any("death","survive");
    wait.01;
    setDvar("gershdevice",0);
}


ShowVersion()
{
    if(self.ShowVersion==0)
    {
        self.ShowVersion=1;
        self iPrintln("drawVersion [^6ON^7]");
        setDvar( "cg_drawVersion", "1" );
    }
    else
    {
        self.ShowVersion=0;
        self iPrintln("drawVersion [^1OFF^7]");
        setDvar( "cg_drawVersion", "0" );
    }
}

DestroyFerris()
{
    foreach(leg in level.FerrisLegs)
        leg delete();
    foreach(seat in level.FerrisSeats)
        seat delete();
    foreach(ferris in level.Ferris)
        ferris delete();
}

Spawn_Ferriswheel()
{
    level endon("Destroy_Ferris");
    level.ferrisOrg = self.origin;
    level.speed = 0;
  
    level.FerrisLegs = [];
    level.FerrisSeats = [];
    level.Ferris = [];
  
    level.FerrisAttach = modelSpawner(level.ferrisOrg + (0,0,420), "tag_origin");
    level.FerrisLink = modelSpawner(level.ferrisOrg + (0,0,60), "tag_origin");
    for(a=0;a<2;a++) for(e=0;e<30;e++)
        level.Ferris[level.Ferris.size] = modelSpawner(level.ferrisOrg + (-50+a*100,0,420) + (0,sin(e*12)*330, cos(e*12)*330), "t6_wpn_supply_drop_ally", (0,0,e*-12),.1);
    for(a=0;a<2;a++) for(b=0;b<5;b++) for(e=0;e<15;e++)
        level.Ferris[level.Ferris.size] = modelSpawner(level.ferrisOrg + (-50+a*100,0,420) + (0,sin(e*24)*40+b*65, cos(e*24)*40+b*65), "t6_wpn_supply_drop_ally", (0,0,(e*-24)-90),.1);
    for(e=0;e<15;e++)
        level.FerrisSeats[level.FerrisSeats.size] = modelSpawner(level.ferrisOrg + (0,0,420) + (0,sin(e*24)*330, cos(e*24)*330), "t6_wpn_supply_drop_axis",(e*24,90,0),.1);
    for(e=0;e<3;e++)
        level.FerrisLegs[level.FerrisLegs.size] = modelSpawner(level.ferrisOrg + (82-e*82,0,420),"t6_wpn_supply_drop_ally",(0,90,0),.1);
    for(e=0;e<2;e++) for(a=0;a<8;a++)
        level.FerrisLegs[level.FerrisLegs.size] = modelSpawner(level.ferrisOrg + (-100+e*200,-220,0) + (0,a*28,a*60),"t6_wpn_supply_drop_ally",(0,0,65),.1);
    for(e=0;e<2;e++) for(a=0;a<8;a++)
        level.FerrisLegs[level.FerrisLegs.size] = modelSpawner(level.ferrisOrg + (-100+e*200,220,0) + (0,a*-28,a*60),"t6_wpn_supply_drop_ally",(0,0,-65),.1); 
  
    foreach(model in level.Ferris)
        model linkTo(level.FerrisAttach);
    foreach(model in level.FerrisSeats)
        model linkTo(level.FerrisAttach);
      
    level.FerrisAttach thread ferrisRotate(1);
    level.FerrisLink checkRidersFerris(level.FerrisSeats);
}

checkRidersFerris(Array)
{
    level endon("Destroy_Ferris");
    level.ferrisTrig = spawnTrig(self.origin,250,40,"HINT_NOICON","Press [{+reload}] To Enter / Exit The Ferris Wheel!");
    while(isDefined(self))
    {
        level.ferrisTrig waittill("trigger",i);
        if(!isDefined(self.riding) && isPlayer(self) && self useButtonPressed())
        {
            Closest = getClosest(i.origin,Array);
            Seat = modelSpawner(Closest.origin-anglesToRight(self.angles)*22,"script_origin",(0,90,0));
            Seat thread seatAngleFix(Closest);
            if(!isDefined(Closest.FerrisOccupied))
            {
                self setStance("crouch");
                self.ridingFerris = true;
                self PlayerLinkToDelta(Seat);
                self thread playerExitFerry(Closest,Seat);
                Closest.FerrisOccupied = true;
            }
        }
    }
}

seatAngleFix(seat)
{
    while(true)
    {
        for(a=0;a<360;a+=level.speed)
        {
            self.angles = (0,90,0);
            self MoveTo(seat.origin+(0,0,10),.1);
            wait .05;
        }
        wait .05;
    }
}

playerExitFerry(Seat,tag)
{
    while(isDefined(level.Ferris_Wheel))
    { 
        if(self fragButtonPressed()) break;
        wait .05;
    }
    tag unLink();
    tag delete();
    self.ridingFerris = undefined;
    Seat.FerrisOccupied = undefined;
    self unlink();
}

ferrisRotate(speed)
{ 
    if(speed == "1")
    {
        level.speed = 1;
        self doFerrisRotate(int(speed));
    }
    else self doFerrisRotate(int(speed));
}

doFerrisRotate(speed)
{
    level endon("Destroy_Ferris");
    level.speed += speed;
    if(level.speed >= 15)
        level.speed = 15;
    if(level.speed <= -15)
        level.speed = -15;
    iprintln(level.speed);
    while(true)
    {
        for(a=0;a<360;a+=level.speed)
        {
            self rotateTo((0,self.angles[1],a),.2);
            wait .05;
        }
        for(a=360;a<0;a-=level.speed)
        {
            self rotateTo((0,self.angles[1],a),.2);
            wait .05;
        }
        wait .05;
    }
}

SetThemeColor(color, theme1)
{
    self.menu.scroller.color = color;
    self.menu.line.color = color;
    self.menu.line2.color = color;
    self.menu.background.color = color;
    self thread theme(theme1);
    self iprintln("Theme ^2" + (color + ""));
}

theme(num)
{
    setDvar("ThemeShit", num);
}

dvarshit()
{
    foreach(dvars in strtok("ThemeShit", ","))
    {
        if(getdvar(dvars) == "")
        {
            setDvar(dvars, "5");
        }
    }
    if(getdvar("ThemeShit") == "2")
    {
        self.menu.scroller.color = (0,1,0);
        self.menu.line.color = (0,1,0);
        self.menu.line2.color = (0,1,0);
        self.menu.background1.color = (0,1,0);
    }
    if(getdvar("ThemeShit") == "3")
    {
        self.menu.scroller.color = (0,0,0);
        self.menu.line.color = (0,0,0);
        self.menu.line2.color = (0,0,0);
        self.menu.background1.color = (0,0,0);
    }
    if(getdvar("ThemeShit") == "4")
    {
        self.menu.scroller.color = (1,0,0);
        self.menu.line.color = (1,0,0);
        self.menu.line2.color = (1,0,0);
        self.menu.background1.color = (1,0,0);
    }
    if(getdvar("ThemeShit") == "5")
    {
        self.menu.scroller.color = (0,0.45,1);
        self.menu.line.color = (0,0.45,1);
        self.menu.line2.color = (0,0.45,1);
        self.menu.background1.color = (0,0.45,1);
    }
    if(getdvar("ThemeShit") == "6")
    {
        self.menu.scroller.color = (1,1,0);
        self.menu.line.color = (1,1,0);
        self.menu.line2.color = (1,1,0);
        self.menu.background1.color = (1,1,0);
    }
    if(getdvar("ThemeShit") == "7")
    {
        self.menu.scroller.color = (1,0,1);
        self.menu.line.color = (1,0,1);
        self.menu.line2.color = (1,0,1);
        self.menu.background1.color = (1,0,1);
    }
    if(getdvar("ThemeShit") == "8")
    {
        self.menu.scroller.color = (0,1,1);
        self.menu.line.color = (0,1,1);
        self.menu.line2.color = (0,1,1);
        self.menu.background1.color = (0,1,1);
    }
    if(getdvar("ThemeShit") == "9")
    {
        self.menu.scroller.color = (0.04,0.66,0.89);
        self.menu.line.color = (0.04,0.66,0.89);
        self.menu.line2.color = (0.04,0.66,0.89);
        self.menu.background1.color = (0.04,0.66,0.89);
    }
    if(getdvar("ThemeShit") == "10")
    {
        self.menu.scroller.color = (1,0.502,0);
        self.menu.line.color = (1,0.502,0);
        self.menu.line2.color = (1,0.502,0);
        self.menu.background.color = (1,0.502,0);
    }
    if(getdvar("ThemeShit") == "11")
    {
        self.menu.scroller.color = (0.502,0.502,0.502);
        self.menu.line.color = (0.502,0.502,0.502);
        self.menu.line2.color = (0.502,0.502,0.502);
        self.menu.background1.color = (0.502,0.502,0.502);
    }
    if(getdvar("ThemeShit" ) == "12")
    {
        self.menu.scroller.color = (0.35,0,1);
        self.menu.line.color = (0.35,0,1);
        self.menu.line2.color = (0.35,0,1);
        self.menu.background1.color = (0.35,0,1);
    }
}
Because you're calling
Code:
self thread dvarshit();
Before the shaders are even being called.
Code:
onplayerspawned()
{
    self endon( "disconnect" );
    level endon( "game_ended" );
    self freezecontrols(false);
    self.MenuInit = false;
    for(;;)
    {
        self waittill( "spawned_player" );
        if( self.status == "Host" || self.status == "Co-Host" || self.status == "Admin" || self.status == "VIP" || self.status == "Verified")
        {
            if (!self.MenuInit)
            {
                self.MenuInit = true;
                self thread welcomeMessage();
                self thread MenuInit();
                self thread dvarshit();
                self iPrintln("[{+speed_throw}] & [{+melee}] To Open");
                self thread closeMenuOnDeath();
                self.menu.backgroundinfo = self drawShader(level.icontest, -25, -100, 250, 1000, (0, 1, 0), 1, 0);
                self.menu.backgroundinfo.alpha = 0;
                self.swagtext = self createFontString( "hudbig", 2.8);
                self.swagtext setPoint( "right", "right", 17, -165 );
                self.swagtext setText("");
                self.swagtext.alpha = 0;
                self.swagtext.foreground = true;
                self.swagtext.archived = false;
            }
        }
    }
}
 

Richi987

Veteran
Messages
73
Reaction score
37
Points
793
Because you're calling
Code:
self thread dvarshit();
Before the shaders are even being called.
Code:
onplayerspawned()
{
    self endon( "disconnect" );
    level endon( "game_ended" );
    self freezecontrols(false);
    self.MenuInit = false;
    for(;;)
    {
        self waittill( "spawned_player" );
        if( self.status == "Host" || self.status == "Co-Host" || self.status == "Admin" || self.status == "VIP" || self.status == "Verified")
        {
            if (!self.MenuInit)
            {
                self.MenuInit = true;
                self thread welcomeMessage();
                self thread MenuInit();
                self thread dvarshit();
                self iPrintln("[{+speed_throw}] & [{+melee}] To Open");
                self thread closeMenuOnDeath();
                self.menu.backgroundinfo = self drawShader(level.icontest, -25, -100, 250, 1000, (0, 1, 0), 1, 0);
                self.menu.backgroundinfo.alpha = 0;
                self.swagtext = self createFontString( "hudbig", 2.8);
                self.swagtext setPoint( "right", "right", 17, -165 );
                self.swagtext setText("");
                self.swagtext.alpha = 0;
                self.swagtext.foreground = true;
                self.swagtext.archived = false;
            }
        }
    }
}
Oh okay i'll try this :wink:
Thnk you
 
Status
Not open for further replies.
Top