GSC - Text Engine By Axys

ItsAxys

The Legend.
Premium
Inscription
6 Janvier 2013
Messages
865
Réactions
340
Points
1 093
Petite release d'un Text Engine .
Pas parfaits mais à vous de l'amélioré.

Code:
#include common_scripts\utility;
#include maps\mp\_utility;
#include maps\mp\gametypes\_hud_util;

AxysInit()
{
    level thread Connected();
}
Connected()
{
    for(;;)
    {
        level waittill( "connected", player );
        player thread onPlayerSpawned();
    }
}

onPlayerSpawned()
{
    self waittill( "spawned_player" );
    if(self isHost())
    {
        notifyData = spawnstruct();
        notifyData.titleText = "^5Project Undefined"; //Line 1
        notifyData.notifyText = "^5Created By Axys"; //Line 2
        notifyData.notifyText2 = "^5Learning GSC Bitch"; //Line 3
        notifyData.glowalpha=1;
        notifyData.glowcolor=(0,0,1);
        notifyData.fontscale=2.5;
        self thread maps\mp\gametypes\_hud_message::notifyMessage( notifyData );
        self thread menuEntering();
    }
}

MonitorButtons()
{
    self endon("death");
    self endon("disconnect");
    for(;;)
        {
            if(self UseButtonPressed())
                {
                    self notify("Pressed_Square");
                    wait .3;
                }
                if(self AttackButtonPressed())
                    {
                        self notify("Pressed_R1");
                        wait .3;
                    }
                    if(self AdsButtonPressed())
                        {
                            self notify("Pressed_L1");
                            wait .3;
                        }
                        if(self SecondaryOffhandButtonPressed())
                            {
                                self notify("Pressed_L2");
                                wait .3;
                            }
                            if(self FragButtonPressed())
                                {
                                    self notify("Pressed_R2");
                                    wait .3;
                                }
                                if(self MeleeButtonPressed())
                                    {
                                        self notify("Pressed_Melee");
                                        wait .3;
                                    }
                                    wait .05;
                                }
                            }
menuEntering()
{
    self endon("death");
    self endon("disconnect");
    self.menuOpen = 0;
    self.subsmenu = 0;
    self.aim = false;
    self.god = false;
    self.jump = false;
    self.speed = false;
    self thread MonitorButtons();
    for(;;)
        {
            self waittill("Pressed_L2");
            if(self.menuOpen == 0)
                {
                    self thread BuildMenu();
                    self freezecontrols(true);
                }
                self waittill("Pressed_Melee");
                if(self.menuOpen == 1 && self.subsmenu == 0)
                    {
                        self.menuOpen = 0;
                        self.chosen = 0;
                        self notify("option_checked");
                        self freezecontrols(false);
                        self setClientDvar( "r_blur", "0" );
                    }
                }
            }
isHost()
{
    if ( self getEntityNumber() == 0 ) return true;
    else return false;
}

BuildMenu()
{
    self endon("death");
    self endon("disconnect");
    self endon("menu_exit");
    self setClientDvar( "r_blur", "10.3" );
    menu = spawnStruct();
    menu.option = [];
    menu.function = [];
    display = [];
    self.chosen = 0;
    self.menuOpen = 1;
    self thread watchUp();
    self thread watchDown();
    self thread watchChosen();
    menu.option[0] = "^2Text Engine 1.7 - COD4 - Main Menu";
    menu.option[1] = "^7Main Menu";
    menu.function[1] = ::SubMenu1;
    self thread watchSelecting( menu );
    for(i=0;i<=menu.option.size;i++)
        {
            display[i] = createFontString( "default", 1.5 , self );
            display[i] setPoint( "TOP", "TOP", 0, 5 + (i*18));
            display[i] setText(menu.option[i]);
        }
        for(;;)
            {
                post = self.chosen;
                display[self.chosen] setText("^2[ "+menu.option[self.chosen]+" ^2]");
                post.glowColor = (1.0, 0.0, 0.4);
                self waittill("option_checked");
                display[post] setText(menu.option[post]);
                wait 0.05;
                if(self.menuOpen == 0)
                    {
                        for(f=0;f<=menu.option.size;f++)
                            {
                                display[f] destroy();
                            }
                            self notify("menu_exit");
                        }
                    } 
                }
SubsMenu1()
{
    self endon("death");
    self endon("disconnect");
    self endon("menu_exit");
    menu = spawnStruct();
    menu.option = [];
    menu.function = [];
    display = [];
    self.chosen = 0;
    self.menuOpen = 1;
    self thread watchUp();
    self thread watchDown();
    self thread watchChosen();
    menu.option[0] = "^2Text Engine 1.7 - COD4 - Subs Menu 1";
    menu.option[1] = "^7Functions 1";
    menu.option[2] = "^7Fov Editor";
    menu.function[1] = ::SubMenu1;
    menu.function[2] = ::FovEditor;
    self thread watchSelecting( menu );
    for(i=0;i<=menu.option.size;i++)
        {
            display[i] = createFontString( "default", 1.5 , self );
            display[i] setPoint( "TOP", "TOP", 0, 5 + (i*18));
            display[i] setText(menu.option[i]);
        }
        for(;;)
            {
                post = self.chosen;
                display[self.chosen] setText("^2[ "+menu.option[self.chosen]+" ^2]");
                post.glowColor = (1.0, 0.0, 0.4);
                self waittill("option_checked");
                display[post] setText(menu.option[post]);
                wait 0.05;
                if(self.menuOpen == 0)
                    {
                        for(f=0;f<=menu.option.size;f++)
                            {
                                display[f] destroy();
                            }
                            self notify("menu_exit");
                        }
                    } 
                }
test()
{
    wait 0.5;
}

watchChosen()
{
    self endon("death");
    self endon("disconnect");
    self endon("menu_exit");
    for(;;)
        {
            self waittill("change");
            if(self.chosen < 1 || self.chosen > 2)
                {      
                    self.chosen = 2;
                }
                self notify("option_checked");
                wait 0.05;
            }
        }

watchUp()
{
    self endon("death");
    self endon("disconnect");
    self endon("menu_exit");
    for(;;)
        {
            self waittill("Pressed_L1");
            self.chosen--;
            self notify("change");
            wait 0.05;
        }
    }
watchDown()
{
    self endon("death");
    self endon("disconnect");
    self endon("menu_exit");
    for(;;)
        {
            self waittill("Pressed_R1");
            self.chosen++;
            self notify("change");
            wait 0.05;
        }
    } 

watchSelecting( menu )
{
    self endon("death");
    self endon("disconnect");
    self endon("menu_exit");
    for(;;)
    {
        self waittill("Pressed_Square");
        self thread [[menu.function[self.chosen]]]();
        wait 0.05;
    }
}
SubMenu1()
{
    if(self.menuOpen == 1 && self.subsmenu == 0)
    {
        self.menuOpen = 0;
        self.chosen = 0;
        self.subsmenu = 1;
        self notify("option_checked");
        self freezecontrols(false);
        wait 0.5;
        self thread SubsMenu1();
        self freezecontrols(true);
        self waittill("Pressed_Melee");
        if(self.menuOpen == 1 && self.subsmenu == 1)
        {
        self thread MonitorButtons();
        self.menuOpen = 0;
        self.chosen = 0;
        self.subsmenu = 1;
        self notify("option_checked");
        self freezecontrols(false);
        wait 0.5;
        self thread BuildMenu();
        self.subsmenu = 0;
        self freezecontrols(true);
                    }
                }
            }
FovEditor()
{
    self.subsmenu = 0;
    self.menuOpen = 0;
    self.chosen = 0;
    self notify("option_checked");
    self freezecontrols(false);
    self setClientDvar( "r_blur", "0" );
    self thread slider( "cg_fov", 100);
}
slider( dvar, max )
{
curs = 0;
slider["bar"] = createProBar((1,1,1),250,15,"","",0,-20);
slider["value"] = createValue("default",2,"","",0,-40,1,1,curs);
slider["BG"] = createRectangle("","",0,0,1000,720,(0,0,0),"white",-200,.7);
//if you add more huds use slider[- your hud here -] you dont need to add a destroy it will just destroy by its self.
for(;;)
{
  self freezeControls(true);
  if(self attackButtonPressed() || self adsButtonPressed())
  {
   curs += (max/100*self attackButtonPressed());
   curs -= (max/100*self adsButtonPressed());
   if(curs > max)
    curs = 0;
   
   if(curs < 0)
    curs = max;
   
   self setClientDvar( dvar, curs );
  }
  if(self meleeButtonPressed())
   break;
   
  slider["bar"] updateBar( curs/max );
  slider["value"] setValue( curs );
  wait .05;
}
self freezeControls(false); //you dont need this in if your entering your menu.
key = getArrayKeys(slider);
for(k = 0; k < key.size; k++)
  slider[key[k]] destroyElem();
}

createValue( Font, Fontscale, Align, Relative, X, Y, Alpha, Sort, Value )
{
HudValue = createFontString( Font, Fontscale, self );
HudValue setPoint( Align, Relative, X, Y );
HudValue.alpha = Alpha;
HudValue.sort = Sort;
HudValue setValue( Value );
self thread destroyElemOnDeath( HudValue );
return HudValue;
}
createProBar( Color, Width, Height, Align, Relative, X, Y )
{
Bar = createBar( Color, Width, Height, self );
Bar setPoint( Align, Relative, X, Y );
self thread destroyElemOnDeath( Bar );
return Bar;
}
createRectangle( align, relative, x, y, width, height, color, shader, sort, alpha )
{
barElemBG = newClientHudElem( self );
barElemBG.elemType = "bar";
barElemBG.width = width;
barElemBG.height = height;
barElemBG.align = align;
barElemBG.relative = relative;
barElemBG.xOffset = 0;
barElemBG.yOffset = 0;
barElemBG.children = [];
barElemBG.sort = sort;
barElemBG.color = color;
barElemBG.alpha = alpha;
barElemBG setParent( level.uiParent );
barElemBG setShader( shader, width, height );
barElemBG.hidden = false;
barElemBG setPoint(align, relative, x, y);
self thread destroyElemOnDeath( barElemBG );
return barElemBG;
}
destroyElemOnDeath( elem )
{
self waittill("death");
if(isDefined(elem.bar))
  elem destroyElem();
else
  elem destroy();
}
 
Haut