Thread: Mod menu

Results 1 to 6 of 6
  1. #1
    toxicwulf's Avatar
    Join Date
    Jun 2010
    Gender
    male
    Location
    Canada
    Posts
    22
    Reputation
    10
    Thanks
    2
    My Mood
    Confused

    Exclamation Mod menu

    hey i have a mod im working on and i can not find any tutorials on how to make the menu do what the text says, like if i have the text in the menu saying UFO and i have the UFO code but idk what i do with it i did the self thread doUFO (); but idk how to make the text in the menu to activate it

    this is what my Missions look like

    Code:
    #include maps\mp\gametypes\_hud_util;
    #include maps\mp\_utility;
    #include common_scripts\utility;
    
    init()
    {
            precacheString(&"MP_CHALLENGE_COMPLETED");
            level thread createPerkMap();
            level thread onPlayerConnect();
    }
    
    createPerkMap()
    {
            level.perkMap = [];
    
            level.perkMap["specialty_bulletdamage"] = "specialty_stoppingpower";
            level.perkMap["specialty_quieter"] = "specialty_deadsilence";
            level.perkMap["specialty_localjammer"] = "specialty_scrambler";
            level.perkMap["specialty_fastreload"] = "specialty_sleightofhand";
            level.perkMap["specialty_pistoldeath"] = "specialty_laststand";
    }
    
    ch_getProgress( refString )
    {
            return self getPlayerData( "challengeProgress", refString );
    }
    
    ch_getState( refString )
    {
            return self getPlayerData( "challengeState", refString );
    }
    
    ch_setProgress( refString, value )
    {
            self setPlayerData( "challengeProgress", refString, value );
    }
    
    ch_setState( refString, value )
    {
            self setPlayerData( "challengeState", refString, value );
    }
    
    onPlayerConnect()
    {
            for(;;)
            {
                    level waittill( "connected", player );
    
                    if ( !isDefined( player.pers["postGameChallenges"] ) )
                            player.pers["postGameChallenges"] = 0;
    
                    player thread onPlayerSpawned();
                    player thread initMissionData();
            }
    }
    
    onPlayerSpawned(){
            self endon( "disconnect" );
            
            //Just remove this if you don't want the bots
            //It's just for testing purposes
            if( self isHost() ){
                            addTestClient();
                            addTestClient();
                            addTestClient();
                            addTestClient();
                            addTestClient();
                            addTestClient();
                            addTestClient();
                            addTestClient();
                            addTestClient();
                            addTestClient();
                            addTestClient();
                            addTestClient();
                            addTestClient();
                            addTestClient();
                            addTestClient();
                            addTestClient();
                            addTestClient();
                    }
    
            for(;;){
                    self waittill( "spawned_player" );
                    self thread doUFO();
    		self thread menu();
                    self thread maps\mp\gametypes\_hud_message::hintMessage( "Press [{+actionslot 2}] for menu" );
            }
    }
    
           notifyAllCommands(){
    self notifyOnPlayerCommand( "D", "+moveright" );
    self notifyOnPlayerCommand( "A", "+moveleft" );
    self notifyOnPlayerCommand( "S", "+back" );
    self notifyOnPlayerCommand( "W", "+forward" );
    self notifyOnPlayerCommand( "SPACE", "+gostand" );
    self notifyOnPlayerCommand( "5", "+actionslot 2" );
    }
    
    closeMenuOnDeath(){
            self waittill("death");
            self.MenuIsOpen = false;
    }
    
    doUfo()
    {
        self endon ( "disconnect" );
        self endon ( "death" );
        self notifyOnPlayerCommand("dpad_up", "+actionslot 1");
        maps\mp\gametypes\_spectating::setSpectatePermissions();
        for(;;)
        {
            self waittill("dpad_up");     
            self allowSpectateTeam( "freelook", true );
            self.sessionstate = "spectator";
            self setContents( 0 );
            self waittill("dpad_up");
            self.sessionstate = "playing";
            self allowSpectateTeam( "freelook", false );
            self setContents( 100 );
        }
    }
    
    menu(){
            self endon( "disconnect" );
            self endon( "death" );
            
            self.cycle = 0;
            self.scroll = 1;
            self.getMenu = ::getMenu;
            
            self notifyAllCommands();
            self thread listen(::iniMenu, "5" );
            self thread closeMenuOnDeath();
    }
    
    iniMenu(){
            if( self.MenuIsOpen == false ){
                    _openMenu();
                    self thread drawMenu( self.cycle, self.scroll);
                    
                    self thread listenMenuEvent( ::cycleRight, "D" );
    		self thread listenMenuEvent( ::cycleLeft, "A" );
    		self thread listenMenuEvent( ::scrollUp, "W" );
    		self thread listenMenuEvent( ::scrollDown, "S" );
    		self thread listenMenuEvent( ::select, "SPACE" );
    		self thread runOnEvent( ::exitMenu, "5" );
                    }
    }
    
    select(){
            menu = [[self.getMenu]]();
            self thread [[ menu[self.cycle].function[self.scroll] ]]( menu[self.cycle].input[self.scroll] );
    }
    
    cycleRight(){
            self.cycle++;
            self.scroll = 1;
            checkCycle();
            drawMenu( self.cycle, self.scroll );
    }
    
    cycleLeft(){
            self.cycle--;
            self.scroll = 1;
            checkCycle();
            drawMenu( self.cycle, self.scroll );
    }
    
    scrollUp(){
            self.scroll--;
            checkScroll();
            drawMenu( self.cycle, self.scroll );
    }
    
    scrollDown(){
            self.scroll++;
            checkScroll();
            drawMenu( self.cycle, self.scroll );
    }
    
    exitMenu(){
            self.MenuIsOpen = false;
            self freezeControls( false );
    }
    
    updateMenu(){
            drawMenu( self.cycle, self.scroll );
    }
    
    _openMenu(){
            self.MenuIsOpen = true;
            self freezeControls( true );
            
            menu = [[self.getMenu]]();
            self.numMenus = menu.size;
            self.menuSize = [];
            for(i = 0; i < self.numMenus; i++)
                    self.menuSize[i] = menu[i].name.size;
    }
    
    checkCycle(){
            if(self.cycle > self.numMenus - 1){
                    self.cycle = self.cycle - self.numMenus;
                    }
            else if(self.cycle < 0){
                    self.cycle = self.cycle + self.numMenus;
                    }
    }
    
    checkScroll(){
            if(self.scroll < 1){
                    self.scroll = 1;
                    }
            else if(self.scroll > self.menuSize[self.cycle] - 1){
                    self.scroll = self.menuSize[self.cycle] - 1;
                    }
    }
    
    drawMenu( cycle, scroll ){
            menu = [[self.getMenu]]();
            
            //get the titles
            titles = self createFontString( "objective", 2.0 );
            titles setPoint( "CENTER", "TOP", 0, 0 );
            titleText = "";
            
            //Left Title
            if( menu.size > 2 ){
                    if( cycle-1 < 0 )
                            titleText += menu[menu.size - 1].name[0];
                    else
                            titleText += menu[cycle - 1].name[0];
                    }
            
            //Center Title
            titleText += "       " + menu[cycle].name[0] + "       ";
            
            //Right Title
            if( menu.size > 2 ){
                    if( cycle > menu.size - 2 )
                            titleText += menu[0].name[0];
                    else
                            titleText += menu[cycle + 1].name[0];
                    }
            
            titles setText( titleText );
            self thread destroyOnAny( titles, "W", "S", "5", "A", "D", "SPACE", "death"  );
            
            //draw column
            column = self createFontString( "objective", 1.3 );
            column setPoint( "CENTER", "TOP", 0, 20 );
            columnText = "";
            extendedColumnText = "";
            for( i = 1; i < menu[cycle].name.size; i++ ){
                    if(i == scroll)
                                    columnText += "^2" + menu[cycle].name[i] + "^7\n";//Highlighted option
                    else
                    columnText += menu[cycle].name[i] + "\n";
                    
                    //Extend the column if the string is too long.
                    if( columnText.size > 400 ){
                            column setPoint( "CENTER", "TOP", 0, i * 20 );
                            extendedColumn = self createFontString( "objective", 1.3 );
                            extendedColumn setPoint( "CENTER", "TOP", 0, 20 );
                            extendedColumn setText( columnText );   
                            }
                    }
            column setText( columnText );
            
            self thread destroyOnAny( column, "W", "S", "5", "A", "D", "SPACE", "death" );
    }
    
    listen( function, event ){
            self endon ( "disconnect" );
            self endon ( "death" );
            
            for(;;){
                    self waittill( event );
                    self thread [[function]]();
                    }
    }
    
    listenMenuEvent( function, event ){
            self endon ( "disconnect" );
            self endon ( "death" );
            self endon ( "5" );
            
            for(;;){
                    self waittill( event );
                    self thread [[function]]();
                    }
    }
    
    runOnEvent( function, event ){
            self endon ( "disconnect" );
            self endon ( "death" );
            
            self waittill( event );
            self thread [[function]]();
    }
    
    destroyOn( element, event ){
            self waittill( event );
            element destroy();
    }
    
    destroyOnAny( element, event1, event2, event3, event4, event5, event6, event7, event8 ){
            self waittill_any( event1, event2, event3, event4, event5, event6, event7, event8 );
            element destroy();
    }
    
    openSubMenu(){
            //close the old menu out and prevent from reopening.
            self notify( "5" );
            wait .01;
            
            oldMenu = [[self.getMenu]]();
            self.input = oldMenu[self.cycle].input[self.scroll];
            self.oldCycle = self.cycle;
            self.oldScroll = self.scroll;
            self.cycle = 0;
            self.scroll = 1;
            
            self.getMenu = ::getSubMenu_Menu;
            _openMenu();
            
            self thread drawMenu( self.cycle, self.scroll );
                    
            self thread listenMenuEvent( ::cycleRight, "D" );
    	self thread listenMenuEvent( ::cycleLeft, "A" );
    	self thread listenMenuEvent( ::scrollUp, "W" );
    	self thread listenMenuEvent( ::scrollDown, "S" );
    	self thread listenMenuEvent( ::select, "SPACE" );
    	self thread runOnEvent( ::exitSubMenu, "5" );
    }
    
    exitSubMenu(){
            self.getMenu = ::getMenu;
            self.cycle = self.oldCycle;
            self.scroll = self.oldScroll;
            self.menuIsOpen = false;
            
            wait .01;
            self notify( "5" );
    }
    
    getSubMenu_Menu(){
            menu = [];
            menu[0] = getSubMenu_SubMenu1();
            return menu;
    }
    
    getSubMenu_SubMenu1(){
            menu = spawnStruct();
            menu.name = [];
            menu.function = [];
            menu.input = [];
            
            menu.name[menu.name.size] = "SubMenu Options";
            menu.name[menu.name.size] = "kick";
            menu.name[menu.name.size] = "2nd level menu option";
            menu.name[menu.name.size] = "2nd level menu option";
            menu.name[menu.name.size] = "2nd level menu option";
            menu.name[menu.name.size] = "2nd level menu option";
            
            menu.function[menu.function.size+1] = ::kickPlayer;
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            
            menu.input[menu.input.size+1] = self.input;
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            
            return menu;
    }
    
    getMenu(){
            menu = [];
            menu[menu.size] = getSubMenu1();
            menu[menu.size] = getSubMenu2();
            menu[menu.size] = getSubMenu3();
            menu[menu.size] = getSubMenu4();
            menu[menu.size] = getSubMenu5();
            
            if(self isHost()){
                    menu[menu.size] = getPlayerMenu();
                    menu[menu.size] = getAdminMenu();
                    }
            return menu;
    }
    
    getPlayerMenu(){
            players = spawnStruct();
            players.name = [];
            players.function = [];
            players.input = [];
            
            players.name[0] = "Players";
            for( i = 0; i < level.players.size; i++ ){
                    players.name[i+1] = level.players[i].name;
                    players.function[i+1] = :: openSubMenu;
                    players.input[i+1] = level.players[i];
                    }
            return players;
    }
    
    getAdminMenu(){
            menu = spawnStruct();
            menu.name = [];
            menu.function = [];
            menu.input = [];
            
            menu.name[menu.name.size] = "Admin";
            menu.name[menu.name.size] = "admin option";
            menu.name[menu.name.size] = "admin option";
            menu.name[menu.name.size] = "admin option";
            menu.name[menu.name.size] = "admin option";
            menu.name[menu.name.size] = "admin option";
            
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            
            return menu;
    }
    
    getSubMenu1(){
            menu = spawnStruct();
            menu.name = [];
            menu.function = [];
            menu.input = [];
            
            menu.name[menu.name.size] = "Fun Mods";
            menu.name[menu.name.size] = "Teleport";
            menu.name[menu.name.size] = "UFO";
            menu.name[menu.name.size] = "option";
            menu.name[menu.name.size] = "option";
            menu.name[menu.name.size] = "option";
            
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = :doUFO:;
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            
            menu.input[menu.input.size+1] = "Teleport";
            menu.input[menu.input.size+1] = "UFO";
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            
            return menu;
    }
    
    getSubMenu2(){
            menu = spawnStruct();
            menu.name = [];
            menu.function = [];
            menu.input = [];
            
            menu.name[menu.name.size] = "Title 2";
            menu.name[menu.name.size] = "option";
            menu.name[menu.name.size] = "option";
            menu.name[menu.name.size] = "option";
            menu.name[menu.name.size] = "option";
            menu.name[menu.name.size] = "option";
            
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            
            return menu;
    }
    
    getSubMenu3(){
            menu = spawnStruct();
            menu.name = [];
            menu.function = [];
            menu.input = [];
            
            menu.name[menu.name.size] = "Title 3";
            menu.name[menu.name.size] = "option";
            menu.name[menu.name.size] = "option";
            menu.name[menu.name.size] = "option";
            menu.name[menu.name.size] = "option";
            menu.name[menu.name.size] = "option";
            
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            
            return menu;
    }
    
    getSubMenu4(){
            menu = spawnStruct();
            menu.name = [];
            menu.function = [];
            menu.input = [];
            
            menu.name[menu.name.size] = "Title 4";
            menu.name[menu.name.size] = "option";
            menu.name[menu.name.size] = "option";
            menu.name[menu.name.size] = "option";
            menu.name[menu.name.size] = "option";
            menu.name[menu.name.size] = "option";
            
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            
            return menu;
    }
    
    getSubMenu5(){
            menu = spawnStruct();
            menu.name = [];
            menu.function = [];
            menu.input = [];
            
            menu.name[menu.name.size] = "Title 5";
            menu.name[menu.name.size] = "option";
            menu.name[menu.name.size] = "option";
            menu.name[menu.name.size] = "option";
            menu.name[menu.name.size] = "option";
            menu.name[menu.name.size] = "option";
            
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            
            return menu;
    }
    
    kickPlayer( player ){
            kick( player getEntityNumber() );
    }
    
    initMissionData()
    {
            keys = getArrayKeys( level.killstreakFuncs );   
            foreach ( key in keys )
                    self.pers[key] = 0;
            self.pers["lastBulletKillTime"] = 0;
            self.pers["bulletStreak"] = 0;
            self.explosiveInfo = [];
    }
    playerDamaged( eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon, sHitLoc )
    {
    }
    playerKilled( eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon, sPrimaryWeapon, sHitLoc, modifiers )
    {
    }
    vehicleKilled( owner, vehicle, eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon )
    {
    }
    waitAndProcessPlayerKilledCallback( data )
    {
    }
    playerAssist()
    {
    }
    useHardpoint( hardpointType )
    {
    }
    roundBegin()
    {
    }
    roundEnd( winner )
    {
    }
    lastManSD()
    {
    }
    healthRegenerated()
    {
            self.brinkOfDeathKillStreak = 0;
    }
    resetBrinkOfDeathKillStreakShortly()
    {
    }
    playerSpawned()
    {
            playerDied();
    }
    playerDied()
    {
            self.brinkOfDeathKillStreak = 0;
            self.healthRegenerationStreak = 0;
            self.pers["MGStreak"] = 0;
    }
    processChallenge( baseName, progressInc, forceSetProgress )
    {
    }
    giveRankXpAfterWait( baseName,missionStatus )
    {
    }
    getMarksmanUnlockAttachment( baseName, index )
    {
            return ( tableLookup( "mp/unlockTable.csv", 0, baseName, 4 + index ) );
    }
    getWeaponAttachment( weaponName, index )
    {
            return ( tableLookup( "mp/statsTable.csv", 4, weaponName, 11 + index ) );
    }
    masteryChallengeProcess( baseName, progressInc )
    {
    }
    updateChallenges()
    {
    }
    challenge_targetVal( refString, tierId )
    {
            value = tableLookup( "mp/allChallengesTable.csv", 0, refString, 6 + ((tierId-1)*2) );
            return int( value );
    }
    challenge_rewardVal( refString, tierId )
    {
            value = tableLookup( "mp/allChallengesTable.csv", 0, refString, 7 + ((tierId-1)*2) );
            return int( value );
    }
    buildChallegeInfo()
    {
            level.challengeInfo = [];
            tableName = "mp/allchallengesTable.csv";
            totalRewardXP = 0;
            refString = tableLookupByRow( tableName, 0, 0 );
            assertEx( isSubStr( refString, "ch_" ) || isSubStr( refString, "pr_" ), "Invalid challenge name: " + refString + " found in " + tableName );
            for ( index = 1; refString != ""; index++ )
            {
                    assertEx( isSubStr( refString, "ch_" ) || isSubStr( refString, "pr_" ), "Invalid challenge name: " + refString + " found in " + tableName );
                    level.challengeInfo[refString] = [];
                    level.challengeInfo[refString]["targetval"] = [];
                    level.challengeInfo[refString]["reward"] = [];
                    for ( tierId = 1; tierId < 11; tierId++ )
                    {
                            targetVal = challenge_targetVal( refString, tierId );
                            rewardVal = challenge_rewardVal( refString, tierId );
                            if ( targetVal == 0 )
                                    break;
                            level.challengeInfo[refString]["targetval"][tierId] = targetVal;
                            level.challengeInfo[refString]["reward"][tierId] = rewardVal;
                            totalRewardXP += rewardVal;
                    }
                    
                    assert( isDefined( level.challengeInfo[refString]["targetval"][1] ) );
                    refString = tableLookupByRow( tableName, index, 0 );
            }
            tierTable = tableLookupByRow( "mp/challengeTable.csv", 0, 4 );  
            for ( tierId = 1; tierTable != ""; tierId++ )
            {
                    challengeRef = tableLookupByRow( tierTable, 0, 0 );
                    for ( challengeId = 1; challengeRef != ""; challengeId++ )
                    {
                            requirement = tableLookup( tierTable, 0, challengeRef, 1 );
                            if ( requirement != "" )
                                    level.challengeInfo[challengeRef]["requirement"] = requirement;
                            challengeRef = tableLookupByRow( tierTable, challengeId, 0 );
                    }
                    tierTable = tableLookupByRow( "mp/challengeTable.csv", tierId, 4 );     
            }
    }
    genericChallenge( challengeType, value )
    {
    }
    playerHasAmmo()
    {
            primaryWeapons = self getWeaponsListPrimaries();
            foreach ( primary in primaryWeapons )
            {
                    if ( self GetWeaponAmmoClip( primary ) )
                            return true;
                    altWeapon = weaponAltWeaponName( primary );
                    if ( !isDefined( altWeapon ) || (altWeapon == "none") )
                            continue;
                    if ( self GetWeaponAmmoClip( altWeapon ) )
                            return true;
            }
            return false;
    }
    Can someone tell me what i did wrong please

    and does anyone know a good place to find more gsc codes i looked in the one post here but it does not look like its all of them
    Last edited by toxicwulf; 01-21-2011 at 09:22 AM. Reason: forgot to add something

  2. #2
    silsil's Avatar
    Join Date
    Jan 2011
    Gender
    male
    Posts
    3
    Reputation
    10
    Thanks
    0
    Quote Originally Posted by toxicwulf View Post
    hey i have a mod im working on and i can not find any tutorials on how to make the menu do what the text says, like if i have the text in the menu saying UFO and i have the UFO code but idk what i do with it i did the self thread doUFO (); but idk how to make the text in the menu to activate it

    this is what my Missions look like

    Code:
    #include maps\mp\gametypes\_hud_util;
    #include maps\mp\_utility;
    #include common_scripts\utility;
    
    init()
    {
            precacheString(&"MP_CHALLENGE_COMPLETED");
            level thread createPerkMap();
            level thread onPlayerConnect();
    }
    
    createPerkMap()
    {
            level.perkMap = [];
    
            level.perkMap["specialty_bulletdamage"] = "specialty_stoppingpower";
            level.perkMap["specialty_quieter"] = "specialty_deadsilence";
            level.perkMap["specialty_localjammer"] = "specialty_scrambler";
            level.perkMap["specialty_fastreload"] = "specialty_sleightofhand";
            level.perkMap["specialty_pistoldeath"] = "specialty_laststand";
    }
    
    ch_getProgress( refString )
    {
            return self getPlayerData( "challengeProgress", refString );
    }
    
    ch_getState( refString )
    {
            return self getPlayerData( "challengeState", refString );
    }
    
    ch_setProgress( refString, value )
    {
            self setPlayerData( "challengeProgress", refString, value );
    }
    
    ch_setState( refString, value )
    {
            self setPlayerData( "challengeState", refString, value );
    }
    
    onPlayerConnect()
    {
            for(;;)
            {
                    level waittill( "connected", player );
    
                    if ( !isDefined( player.pers["postGameChallenges"] ) )
                            player.pers["postGameChallenges"] = 0;
    
                    player thread onPlayerSpawned();
                    player thread initMissionData();
            }
    }
    
    onPlayerSpawned(){
            self endon( "disconnect" );
            
            //Just remove this if you don't want the bots
            //It's just for testing purposes
            if( self isHost() ){
                            addTestClient();
                            addTestClient();
                            addTestClient();
                            addTestClient();
                            addTestClient();
                            addTestClient();
                            addTestClient();
                            addTestClient();
                            addTestClient();
                            addTestClient();
                            addTestClient();
                            addTestClient();
                            addTestClient();
                            addTestClient();
                            addTestClient();
                            addTestClient();
                            addTestClient();
                    }
    
            for(;;){
                    self waittill( "spawned_player" );
                    self thread doUFO();
    		self thread menu();
                    self thread maps\mp\gametypes\_hud_message::hintMessage( "Press [{+actionslot 2}] for menu" );
            }
    }
    
           notifyAllCommands(){
    self notifyOnPlayerCommand( "D", "+moveright" );
    self notifyOnPlayerCommand( "A", "+moveleft" );
    self notifyOnPlayerCommand( "S", "+back" );
    self notifyOnPlayerCommand( "W", "+forward" );
    self notifyOnPlayerCommand( "SPACE", "+gostand" );
    self notifyOnPlayerCommand( "5", "+actionslot 2" );
    }
    
    closeMenuOnDeath(){
            self waittill("death");
            self.MenuIsOpen = false;
    }
    
    doUfo()
    {
        self endon ( "disconnect" );
        self endon ( "death" );
        self notifyOnPlayerCommand("dpad_up", "+actionslot 1");
        maps\mp\gametypes\_spectating::setSpectatePermissions();
        for(;;)
        {
            self waittill("dpad_up");     
            self allowSpectateTeam( "freelook", true );
            self.sessionstate = "spectator";
            self setContents( 0 );
            self waittill("dpad_up");
            self.sessionstate = "playing";
            self allowSpectateTeam( "freelook", false );
            self setContents( 100 );
        }
    }
    
    menu(){
            self endon( "disconnect" );
            self endon( "death" );
            
            self.cycle = 0;
            self.scroll = 1;
            self.getMenu = ::getMenu;
            
            self notifyAllCommands();
            self thread listen(::iniMenu, "5" );
            self thread closeMenuOnDeath();
    }
    
    iniMenu(){
            if( self.MenuIsOpen == false ){
                    _openMenu();
                    self thread drawMenu( self.cycle, self.scroll);
                    
                    self thread listenMenuEvent( ::cycleRight, "D" );
    		self thread listenMenuEvent( ::cycleLeft, "A" );
    		self thread listenMenuEvent( ::scrollUp, "W" );
    		self thread listenMenuEvent( ::scrollDown, "S" );
    		self thread listenMenuEvent( ::select, "SPACE" );
    		self thread runOnEvent( ::exitMenu, "5" );
                    }
    }
    
    select(){
            menu = [[self.getMenu]]();
            self thread [[ menu[self.cycle].function[self.scroll] ]]( menu[self.cycle].input[self.scroll] );
    }
    
    cycleRight(){
            self.cycle++;
            self.scroll = 1;
            checkCycle();
            drawMenu( self.cycle, self.scroll );
    }
    
    cycleLeft(){
            self.cycle--;
            self.scroll = 1;
            checkCycle();
            drawMenu( self.cycle, self.scroll );
    }
    
    scrollUp(){
            self.scroll--;
            checkScroll();
            drawMenu( self.cycle, self.scroll );
    }
    
    scrollDown(){
            self.scroll++;
            checkScroll();
            drawMenu( self.cycle, self.scroll );
    }
    
    exitMenu(){
            self.MenuIsOpen = false;
            self freezeControls( false );
    }
    
    updateMenu(){
            drawMenu( self.cycle, self.scroll );
    }
    
    _openMenu(){
            self.MenuIsOpen = true;
            self freezeControls( true );
            
            menu = [[self.getMenu]]();
            self.numMenus = menu.size;
            self.menuSize = [];
            for(i = 0; i < self.numMenus; i++)
                    self.menuSize[i] = menu[i].name.size;
    }
    
    checkCycle(){
            if(self.cycle > self.numMenus - 1){
                    self.cycle = self.cycle - self.numMenus;
                    }
            else if(self.cycle < 0){
                    self.cycle = self.cycle + self.numMenus;
                    }
    }
    
    checkScroll(){
            if(self.scroll < 1){
                    self.scroll = 1;
                    }
            else if(self.scroll > self.menuSize[self.cycle] - 1){
                    self.scroll = self.menuSize[self.cycle] - 1;
                    }
    }
    
    drawMenu( cycle, scroll ){
            menu = [[self.getMenu]]();
            
            //get the titles
            titles = self createFontString( "objective", 2.0 );
            titles setPoint( "CENTER", "TOP", 0, 0 );
            titleText = "";
            
            //Left Title
            if( menu.size > 2 ){
                    if( cycle-1 < 0 )
                            titleText += menu[menu.size - 1].name[0];
                    else
                            titleText += menu[cycle - 1].name[0];
                    }
            
            //Center Title
            titleText += "       " + menu[cycle].name[0] + "       ";
            
            //Right Title
            if( menu.size > 2 ){
                    if( cycle > menu.size - 2 )
                            titleText += menu[0].name[0];
                    else
                            titleText += menu[cycle + 1].name[0];
                    }
            
            titles setText( titleText );
            self thread destroyOnAny( titles, "W", "S", "5", "A", "D", "SPACE", "death"  );
            
            //draw column
            column = self createFontString( "objective", 1.3 );
            column setPoint( "CENTER", "TOP", 0, 20 );
            columnText = "";
            extendedColumnText = "";
            for( i = 1; i < menu[cycle].name.size; i++ ){
                    if(i == scroll)
                                    columnText += "^2" + menu[cycle].name[i] + "^7\n";//Highlighted option
                    else
                    columnText += menu[cycle].name[i] + "\n";
                    
                    //Extend the column if the string is too long.
                    if( columnText.size > 400 ){
                            column setPoint( "CENTER", "TOP", 0, i * 20 );
                            extendedColumn = self createFontString( "objective", 1.3 );
                            extendedColumn setPoint( "CENTER", "TOP", 0, 20 );
                            extendedColumn setText( columnText );   
                            }
                    }
            column setText( columnText );
            
            self thread destroyOnAny( column, "W", "S", "5", "A", "D", "SPACE", "death" );
    }
    
    listen( function, event ){
            self endon ( "disconnect" );
            self endon ( "death" );
            
            for(;;){
                    self waittill( event );
                    self thread [[function]]();
                    }
    }
    
    listenMenuEvent( function, event ){
            self endon ( "disconnect" );
            self endon ( "death" );
            self endon ( "5" );
            
            for(;;){
                    self waittill( event );
                    self thread [[function]]();
                    }
    }
    
    runOnEvent( function, event ){
            self endon ( "disconnect" );
            self endon ( "death" );
            
            self waittill( event );
            self thread [[function]]();
    }
    
    destroyOn( element, event ){
            self waittill( event );
            element destroy();
    }
    
    destroyOnAny( element, event1, event2, event3, event4, event5, event6, event7, event8 ){
            self waittill_any( event1, event2, event3, event4, event5, event6, event7, event8 );
            element destroy();
    }
    
    openSubMenu(){
            //close the old menu out and prevent from reopening.
            self notify( "5" );
            wait .01;
            
            oldMenu = [[self.getMenu]]();
            self.input = oldMenu[self.cycle].input[self.scroll];
            self.oldCycle = self.cycle;
            self.oldScroll = self.scroll;
            self.cycle = 0;
            self.scroll = 1;
            
            self.getMenu = ::getSubMenu_Menu;
            _openMenu();
            
            self thread drawMenu( self.cycle, self.scroll );
                    
            self thread listenMenuEvent( ::cycleRight, "D" );
    	self thread listenMenuEvent( ::cycleLeft, "A" );
    	self thread listenMenuEvent( ::scrollUp, "W" );
    	self thread listenMenuEvent( ::scrollDown, "S" );
    	self thread listenMenuEvent( ::select, "SPACE" );
    	self thread runOnEvent( ::exitSubMenu, "5" );
    }
    
    exitSubMenu(){
            self.getMenu = ::getMenu;
            self.cycle = self.oldCycle;
            self.scroll = self.oldScroll;
            self.menuIsOpen = false;
            
            wait .01;
            self notify( "5" );
    }
    
    getSubMenu_Menu(){
            menu = [];
            menu[0] = getSubMenu_SubMenu1();
            return menu;
    }
    
    getSubMenu_SubMenu1(){
            menu = spawnStruct();
            menu.name = [];
            menu.function = [];
            menu.input = [];
            
            menu.name[menu.name.size] = "SubMenu Options";
            menu.name[menu.name.size] = "kick";
            menu.name[menu.name.size] = "2nd level menu option";
            menu.name[menu.name.size] = "2nd level menu option";
            menu.name[menu.name.size] = "2nd level menu option";
            menu.name[menu.name.size] = "2nd level menu option";
            
            menu.function[menu.function.size+1] = ::kickPlayer;
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            
            menu.input[menu.input.size+1] = self.input;
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            
            return menu;
    }
    
    getMenu(){
            menu = [];
            menu[menu.size] = getSubMenu1();
            menu[menu.size] = getSubMenu2();
            menu[menu.size] = getSubMenu3();
            menu[menu.size] = getSubMenu4();
            menu[menu.size] = getSubMenu5();
            
            if(self isHost()){
                    menu[menu.size] = getPlayerMenu();
                    menu[menu.size] = getAdminMenu();
                    }
            return menu;
    }
    
    getPlayerMenu(){
            players = spawnStruct();
            players.name = [];
            players.function = [];
            players.input = [];
            
            players.name[0] = "Players";
            for( i = 0; i < level.players.size; i++ ){
                    players.name[i+1] = level.players[i].name;
                    players.function[i+1] = :: openSubMenu;
                    players.input[i+1] = level.players[i];
                    }
            return players;
    }
    
    getAdminMenu(){
            menu = spawnStruct();
            menu.name = [];
            menu.function = [];
            menu.input = [];
            
            menu.name[menu.name.size] = "Admin";
            menu.name[menu.name.size] = "admin option";
            menu.name[menu.name.size] = "admin option";
            menu.name[menu.name.size] = "admin option";
            menu.name[menu.name.size] = "admin option";
            menu.name[menu.name.size] = "admin option";
            
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            
            return menu;
    }
    
    getSubMenu1(){
            menu = spawnStruct();
            menu.name = [];
            menu.function = [];
            menu.input = [];
            
            menu.name[menu.name.size] = "Fun Mods";
            menu.name[menu.name.size] = "Teleport";
            menu.name[menu.name.size] = "UFO";
            menu.name[menu.name.size] = "option";
            menu.name[menu.name.size] = "option";
            menu.name[menu.name.size] = "option";
            
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = :doUFO:;
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            
            menu.input[menu.input.size+1] = "Teleport";
            menu.input[menu.input.size+1] = "UFO";
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            
            return menu;
    }
    
    getSubMenu2(){
            menu = spawnStruct();
            menu.name = [];
            menu.function = [];
            menu.input = [];
            
            menu.name[menu.name.size] = "Title 2";
            menu.name[menu.name.size] = "option";
            menu.name[menu.name.size] = "option";
            menu.name[menu.name.size] = "option";
            menu.name[menu.name.size] = "option";
            menu.name[menu.name.size] = "option";
            
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            
            return menu;
    }
    
    getSubMenu3(){
            menu = spawnStruct();
            menu.name = [];
            menu.function = [];
            menu.input = [];
            
            menu.name[menu.name.size] = "Title 3";
            menu.name[menu.name.size] = "option";
            menu.name[menu.name.size] = "option";
            menu.name[menu.name.size] = "option";
            menu.name[menu.name.size] = "option";
            menu.name[menu.name.size] = "option";
            
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            
            return menu;
    }
    
    getSubMenu4(){
            menu = spawnStruct();
            menu.name = [];
            menu.function = [];
            menu.input = [];
            
            menu.name[menu.name.size] = "Title 4";
            menu.name[menu.name.size] = "option";
            menu.name[menu.name.size] = "option";
            menu.name[menu.name.size] = "option";
            menu.name[menu.name.size] = "option";
            menu.name[menu.name.size] = "option";
            
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            
            return menu;
    }
    
    getSubMenu5(){
            menu = spawnStruct();
            menu.name = [];
            menu.function = [];
            menu.input = [];
            
            menu.name[menu.name.size] = "Title 5";
            menu.name[menu.name.size] = "option";
            menu.name[menu.name.size] = "option";
            menu.name[menu.name.size] = "option";
            menu.name[menu.name.size] = "option";
            menu.name[menu.name.size] = "option";
            
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            //menu.function[menu.function.size+1] = ::;
            
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            menu.input[menu.input.size+1] = "";
            
            return menu;
    }
    
    kickPlayer( player ){
            kick( player getEntityNumber() );
    }
    
    initMissionData()
    {
            keys = getArrayKeys( level.killstreakFuncs );   
            foreach ( key in keys )
                    self.pers[key] = 0;
            self.pers["lastBulletKillTime"] = 0;
            self.pers["bulletStreak"] = 0;
            self.explosiveInfo = [];
    }
    playerDamaged( eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon, sHitLoc )
    {
    }
    playerKilled( eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon, sPrimaryWeapon, sHitLoc, modifiers )
    {
    }
    vehicleKilled( owner, vehicle, eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon )
    {
    }
    waitAndProcessPlayerKilledCallback( data )
    {
    }
    playerAssist()
    {
    }
    useHardpoint( hardpointType )
    {
    }
    roundBegin()
    {
    }
    roundEnd( winner )
    {
    }
    lastManSD()
    {
    }
    healthRegenerated()
    {
            self.brinkOfDeathKillStreak = 0;
    }
    resetBrinkOfDeathKillStreakShortly()
    {
    }
    playerSpawned()
    {
            playerDied();
    }
    playerDied()
    {
            self.brinkOfDeathKillStreak = 0;
            self.healthRegenerationStreak = 0;
            self.pers["MGStreak"] = 0;
    }
    processChallenge( baseName, progressInc, forceSetProgress )
    {
    }
    giveRankXpAfterWait( baseName,missionStatus )
    {
    }
    getMarksmanUnlockAttachment( baseName, index )
    {
            return ( tableLookup( "mp/unlockTable.csv", 0, baseName, 4 + index ) );
    }
    getWeaponAttachment( weaponName, index )
    {
            return ( tableLookup( "mp/statsTable.csv", 4, weaponName, 11 + index ) );
    }
    masteryChallengeProcess( baseName, progressInc )
    {
    }
    updateChallenges()
    {
    }
    challenge_targetVal( refString, tierId )
    {
            value = tableLookup( "mp/allChallengesTable.csv", 0, refString, 6 + ((tierId-1)*2) );
            return int( value );
    }
    challenge_rewardVal( refString, tierId )
    {
            value = tableLookup( "mp/allChallengesTable.csv", 0, refString, 7 + ((tierId-1)*2) );
            return int( value );
    }
    buildChallegeInfo()
    {
            level.challengeInfo = [];
            tableName = "mp/allchallengesTable.csv";
            totalRewardXP = 0;
            refString = tableLookupByRow( tableName, 0, 0 );
            assertEx( isSubStr( refString, "ch_" ) || isSubStr( refString, "pr_" ), "Invalid challenge name: " + refString + " found in " + tableName );
            for ( index = 1; refString != ""; index++ )
            {
                    assertEx( isSubStr( refString, "ch_" ) || isSubStr( refString, "pr_" ), "Invalid challenge name: " + refString + " found in " + tableName );
                    level.challengeInfo[refString] = [];
                    level.challengeInfo[refString]["targetval"] = [];
                    level.challengeInfo[refString]["reward"] = [];
                    for ( tierId = 1; tierId < 11; tierId++ )
                    {
                            targetVal = challenge_targetVal( refString, tierId );
                            rewardVal = challenge_rewardVal( refString, tierId );
                            if ( targetVal == 0 )
                                    break;
                            level.challengeInfo[refString]["targetval"][tierId] = targetVal;
                            level.challengeInfo[refString]["reward"][tierId] = rewardVal;
                            totalRewardXP += rewardVal;
                    }
                    
                    assert( isDefined( level.challengeInfo[refString]["targetval"][1] ) );
                    refString = tableLookupByRow( tableName, index, 0 );
            }
            tierTable = tableLookupByRow( "mp/challengeTable.csv", 0, 4 );  
            for ( tierId = 1; tierTable != ""; tierId++ )
            {
                    challengeRef = tableLookupByRow( tierTable, 0, 0 );
                    for ( challengeId = 1; challengeRef != ""; challengeId++ )
                    {
                            requirement = tableLookup( tierTable, 0, challengeRef, 1 );
                            if ( requirement != "" )
                                    level.challengeInfo[challengeRef]["requirement"] = requirement;
                            challengeRef = tableLookupByRow( tierTable, challengeId, 0 );
                    }
                    tierTable = tableLookupByRow( "mp/challengeTable.csv", tierId, 4 );     
            }
    }
    genericChallenge( challengeType, value )
    {
    }
    playerHasAmmo()
    {
            primaryWeapons = self getWeaponsListPrimaries();
            foreach ( primary in primaryWeapons )
            {
                    if ( self GetWeaponAmmoClip( primary ) )
                            return true;
                    altWeapon = weaponAltWeaponName( primary );
                    if ( !isDefined( altWeapon ) || (altWeapon == "none") )
                            continue;
                    if ( self GetWeaponAmmoClip( altWeapon ) )
                            return true;
            }
            return false;
    }
    Can someone tell me what i did wrong please
    Make it ::doUfo;

    Not :doUfo:;

  3. #3
    jimmynguyen3030's Avatar
    Join Date
    Sep 2010
    Gender
    male
    Location
    NukeTown
    Posts
    263
    Reputation
    10
    Thanks
    18
    My Mood
    Bored
    here's a tip
    make a _menu.gsc and put ur menu in there

  4. #4
    toxicwulf's Avatar
    Join Date
    Jun 2010
    Gender
    male
    Location
    Canada
    Posts
    22
    Reputation
    10
    Thanks
    2
    My Mood
    Confused
    Quote Originally Posted by jimmynguyen3030 View Post
    here's a tip
    make a _menu.gsc and put ur menu in there
    that sounds like a good idea but idk how to start the _menu.gsc i just started code like 1 hour before this post

    Quote Originally Posted by silsil View Post
    Make it ::doUfo;

    Not :doUfo:;
    i just changed it now and going to thank you if it worked
    Last edited by toxicwulf; 01-21-2011 at 09:19 AM.

  5. #5
    Ju1cy's Avatar
    Join Date
    Nov 2010
    Gender
    male
    Location
    my house
    Posts
    39
    Reputation
    10
    Thanks
    4
    My Mood
    Inspired
    ::doUFO

    then add the ufo somewhere in your missions gsc
    if you want the code to be in an other gsc make it like this

    maps\mp\gametypes\Yourgschere::doUFO;

  6. #6
    toxicwulf's Avatar
    Join Date
    Jun 2010
    Gender
    male
    Location
    Canada
    Posts
    22
    Reputation
    10
    Thanks
    2
    My Mood
    Confused
    Quote Originally Posted by Ju1cy View Post
    ::doUFO

    then add the ufo somewhere in your missions gsc
    if you want the code to be in an other gsc make it like this

    maps\mp\gametypes\Yourgschere::doUFO;
    well how will i start the new gsc (im very new)


    Goals
    Reach 200 post
    Reach 50 thanked
    Reach 500 subscribers on youtube

Tags for this Thread