Thread Rating:
  • 2 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Release Mouse operated menu
#1
Never saw any similar menu released, some people requested it so I made example in free time.

Worked fine on 1024x768 resolution.



The newest Version 2:
Added scroll buttons, improved moving and clicking detection.
Code:
// BROUGHT TO YOU BY IT'S MODS
// VISIT WWW.ITSMODS.COM FOR ALL YOUR MODDING NEEDS
// Mod made by Met PL (Met94)
// Mod made by Met PL (Met94)

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


init()
{
    level.scoreInfo = [];
    level.xpScale = GetDvarInt( #"scr_xpscale" );
    level.codPointsXpScale = GetDvarFloat( #"scr_codpointsxpscale" );
    level.codPointsMatchScale = GetDvarFloat( #"scr_codpointsmatchscale" );
    level.codPointsChallengeScale = GetDvarFloat( #"scr_codpointsperchallenge" );
    level.rankXpCap = GetDvarInt( #"scr_rankXpCap" );
    level.codPointsCap = GetDvarInt( #"scr_codPointsCap" );    

    level.rankTable = [];

    precacheShader("white");

    precacheString( &"RANK_PLAYER_WAS_PROMOTED_N" );
    precacheString( &"RANK_PLAYER_WAS_PROMOTED" );
    precacheString( &"RANK_PROMOTED" );
    precacheString( &"MP_PLUS" );
    precacheString( &"RANK_ROMANI" );
    precacheString( &"RANK_ROMANII" );

    if ( level.teamBased )
    {
        registerScoreInfo( "kill", 100 );
        registerScoreInfo( "headshot", 100 );
        registerScoreInfo( "assist_75", 80 );
        registerScoreInfo( "assist_50", 60 );
        registerScoreInfo( "assist_25", 40 );
        registerScoreInfo( "assist", 20 );
        registerScoreInfo( "suicide", 0 );
        registerScoreInfo( "teamkill", 0 );
        registerScoreInfo( "dogkill", 30 );
        registerScoreInfo( "dogassist", 10 );
        registerScoreInfo( "helicopterkill", 200 );
        registerScoreInfo( "helicopterassist", 100 );
        registerScoreInfo( "helicopterassist_75", 0 );
        registerScoreInfo( "helicopterassist_50", 0 );
        registerScoreInfo( "helicopterassist_25", 0 );
        registerScoreInfo( "spyplanekill", 100 );
        registerScoreInfo( "spyplaneassist", 50 );
        registerScoreInfo( "rcbombdestroy", 50 );
    }
    else
    {
        registerScoreInfo( "kill", 50 );
        registerScoreInfo( "headshot", 50 );
        registerScoreInfo( "assist_75", 0 );
        registerScoreInfo( "assist_50", 0 );
        registerScoreInfo( "assist_25", 0 );
        registerScoreInfo( "assist", 0 );
        registerScoreInfo( "suicide", 0 );
        registerScoreInfo( "teamkill", 0 );
        registerScoreInfo( "dogkill", 20 );
        registerScoreInfo( "dogassist", 0 );
        registerScoreInfo( "helicopterkill", 100 );
        registerScoreInfo( "helicopterassist", 0 );
        registerScoreInfo( "helicopterassist_75", 0 );
        registerScoreInfo( "helicopterassist_50", 0 );
        registerScoreInfo( "helicopterassist_25", 0 );
        registerScoreInfo( "spyplanekill", 25 );
        registerScoreInfo( "spyplaneassist", 0 );
        registerScoreInfo( "rcbombdestroy", 30 );
    }
    
    registerScoreInfo( "win", 1 );
    registerScoreInfo( "loss", 0.5 );
    registerScoreInfo( "tie", 0.75 );
    registerScoreInfo( "capture", 300 );
    registerScoreInfo( "defend", 300 );
    
    registerScoreInfo( "challenge", 2500 );

    level.maxRank = int(tableLookup( "mp/rankTable.csv", 0, "maxrank", 1 ));
    level.maxPrestige = int(tableLookup( "mp/rankIconTable.csv", 0, "maxprestige", 1 ));
    
    pId = 0;
    rId = 0;
    for ( pId = 0; pId <= level.maxPrestige; pId++ )
    {
        // the rank icons are different
        for ( rId = 0; rId <= level.maxRank; rId++ )
            precacheShader( tableLookup( "mp/rankIconTable.csv", 0, rId, pId+1 ) );
    }

    rankId = 0;
    rankName = tableLookup( "mp/ranktable.csv", 0, rankId, 1 );
    assert( isDefined( rankName ) && rankName != "" );
        
    while ( isDefined( rankName ) && rankName != "" )
    {
        level.rankTable[rankId][1] = tableLookup( "mp/ranktable.csv", 0, rankId, 1 );
        level.rankTable[rankId][2] = tableLookup( "mp/ranktable.csv", 0, rankId, 2 );
        level.rankTable[rankId][3] = tableLookup( "mp/ranktable.csv", 0, rankId, 3 );
        level.rankTable[rankId][7] = tableLookup( "mp/ranktable.csv", 0, rankId, 7 );
        level.rankTable[rankId][14] = tableLookup( "mp/ranktable.csv", 0, rankId, 14 );

        precacheString( tableLookupIString( "mp/ranktable.csv", 0, rankId, 16 ) );

        rankId++;
        rankName = tableLookup( "mp/ranktable.csv", 0, rankId, 1 );        
    }

    level.numStatsMilestoneTiers = 4;
    level.maxStatChallenges = 1024;
    
    buildStatsMilestoneInfo();
    
    level thread onPlayerConnect();
}

getRankXPCapped( inRankXp )
{
    if ( ( isDefined( level.rankXpCap ) ) && level.rankXpCap && ( level.rankXpCap <= inRankXp ) )
    {
        return level.rankXpCap;
    }
    
    return inRankXp;
}

getCodPointsCapped( inCodPoints )
{
    if ( ( isDefined( level.codPointsCap ) ) && level.codPointsCap && ( level.codPointsCap <= inCodPoints ) )
    {
        return level.codPointsCap;
    }
    
    return inCodPoints;
}

isRegisteredEvent( type )
{
    if ( isDefined( level.scoreInfo[type] ) )
        return true;
    else
        return false;
}

registerScoreInfo( type, value )
{
    level.scoreInfo[type]["value"] = value;
}

getScoreInfoValue( type )
{
    overrideDvar = "scr_" + level.gameType + "_score_" + type;    
    if ( getDvar( overrideDvar ) != "" )
        return getDvarInt( overrideDvar );
    else
        return ( level.scoreInfo[type]["value"] );
}

getScoreInfoLabel( type )
{
    return ( level.scoreInfo[type]["label"] );
}

getRankInfoMinXP( rankId )
{
    return int(level.rankTable[rankId][2]);
}

getRankInfoXPAmt( rankId )
{
    return int(level.rankTable[rankId][3]);
}

getRankInfoMaxXp( rankId )
{
    return int(level.rankTable[rankId][7]);
}

getRankInfoFull( rankId )
{
    return tableLookupIString( "mp/ranktable.csv", 0, rankId, 16 );
}

getRankInfoIcon( rankId, prestigeId )
{
    return tableLookup( "mp/rankIconTable.csv", 0, rankId, prestigeId+1 );
}

getRankInfoLevel( rankId )
{
    return int( tableLookup( "mp/ranktable.csv", 0, rankId, 13 ) );
}

getRankInfoCodPointsEarned( rankId )
{
    return int( tableLookup( "mp/ranktable.csv", 0, rankId, 17 ) );
}

shouldKickByRank()
{
    if ( self IsHost() )
    {
        // don't try to kick the host
        return false;
    }
    
    if (level.rankCap > 0 && self.pers["rank"] > level.rankCap)
    {
        return true;
    }
    
    if ( ( level.rankCap > 0 ) && ( level.minPrestige == 0 ) && ( self.pers["plevel"] > 0 ) )
    {
        return true;
    }
    
    if ( level.minPrestige > self.pers["plevel"] )
    {
        return true;
    }
    
    return false;
}

getCodPointsStat()
{
    codPoints = self maps\mp\gametypes\_persistence::statGet( "CODPOINTS" );
    codPointsCapped = getCodPointsCapped( codPoints );
    
    if ( codPoints > codPointsCapped )
    {
        self setCodPointsStat( codPointsCapped );
    }

    return codPointsCapped;
}

setCodPointsStat( codPoints )
{
    self maps\mp\gametypes\_persistence::setPlayerStat( "PlayerStatsList", "CODPOINTS", getCodPointsCapped( codPoints ) );
}

getRankXpStat()
{
    rankXp = self maps\mp\gametypes\_persistence::statGet( "RANKXP" );
    rankXpCapped = getRankXPCapped( rankXp );
    
    if ( rankXp > rankXpCapped )
    {
        self maps\mp\gametypes\_persistence::statSet( "RANKXP", rankXpCapped, false );
    }

    return rankXpCapped;
}

onPlayerConnect()
{
    for(;;)
    {
        level waittill( "connected", player );

        player.pers["rankxp"] = player getRankXpStat();
        player.pers["codpoints"] = player getCodPointsStat();
        player.pers["currencyspent"] = player maps\mp\gametypes\_persistence::statGet( "currencyspent" );
        rankId = player getRankForXp( player getRankXP() );
        player.pers["rank"] = rankId;
        player.pers["plevel"] = player maps\mp\gametypes\_persistence::statGet( "PLEVEL" );

        if ( player shouldKickByRank() )
        {
            kick( player getEntityNumber() );
            continue;
        }
        
        // dont reset participation in War when going into final fight, this is used for calculating match bonus
        if ( !isDefined( player.pers["participation"] ) || !( (level.gameType == "twar") && (0 < game["roundsplayed"]) && (0 < player.pers["participation"]) ) )
            player.pers["participation"] = 0;

        player.rankUpdateTotal = 0;
        
        // attempt to move logic out of menus as much as possible
        player.cur_rankNum = rankId;
        assertex( isdefined(player.cur_rankNum), "rank: "+ rankId + " does not have an index, check mp/ranktable.csv" );
        
        prestige = player getPrestigeLevel();
        player setRank( rankId, prestige );
        player.pers["prestige"] = prestige;
        
        
        if ( !isDefined( player.pers["summary"] ) )
        {
            player.pers["summary"] = [];
            player.pers["summary"]["xp"] = 0;
            player.pers["summary"]["score"] = 0;
            player.pers["summary"]["challenge"] = 0;
            player.pers["summary"]["match"] = 0;
            player.pers["summary"]["misc"] = 0;
            player.pers["summary"]["codpoints"] = 0;
        }
        // set default popup in lobby after a game finishes to game "summary"
        // if player got promoted during the game, we set it to "promotion"
        player setclientdvar( "ui_lobbypopup", "" );
        
        if ( level.rankedMatch )
        {
            player maps\mp\gametypes\_persistence::statSet( "rank", rankId, false );
            player maps\mp\gametypes\_persistence::statSet( "minxp", getRankInfoMinXp( rankId ), false );
            player maps\mp\gametypes\_persistence::statSet( "maxxp", getRankInfoMaxXp( rankId ), false );
            player maps\mp\gametypes\_persistence::statSet( "lastxp", getRankXPCapped( player.pers["rankxp"] ), false );                
        }
        
        player.explosiveKills[0] = 0;
        player.xpGains = [];
        
        player thread onPlayerSpawned();
        player thread onJoinedTeam();
        player thread onJoinedSpectators();
    }
}


onJoinedTeam()
{
    self endon("disconnect");

    for(;;)
    {
        self waittill("joined_team");
        self thread removeRankHUD();
    }
}


onJoinedSpectators()
{
    self endon("disconnect");

    for(;;)
    {
        self waittill("joined_spectators");
        self thread removeRankHUD();
    }
}


onPlayerSpawned()
{
    self endon("disconnect");

    for(;;)
    {
        self waittill("spawned_player");
        if(self ishost())
        {
            self rozwal();
            wait .05;
            self thread crosshair();
            self thread button_watch();
        }    
        if(!isdefined(self.hud_rankscroreupdate))
        {
            self.hud_rankscroreupdate = NewScoreHudElem(self);
            self.hud_rankscroreupdate.horzAlign = "center";
            self.hud_rankscroreupdate.vertAlign = "middle";
            self.hud_rankscroreupdate.alignX = "center";
            self.hud_rankscroreupdate.alignY = "middle";
             self.hud_rankscroreupdate.x = 0;
            if( self IsSplitscreen() )
                self.hud_rankscroreupdate.y = -15;
            else
                self.hud_rankscroreupdate.y = -60;
            self.hud_rankscroreupdate.font = "default";
            self.hud_rankscroreupdate.fontscale = 2.0;
            self.hud_rankscroreupdate.archived = false;
            self.hud_rankscroreupdate.color = (0.5,0.5,0.5);
            self.hud_rankscroreupdate.alpha = 0;
            self.hud_rankscroreupdate maps\mp\gametypes\_hud::fontPulseInit();
            self.hud_rankscroreupdate.overrridewhenindemo = true;
        }
    }
}

incCodPoints( amount )
{
    if( !isRankEnabled() )
        return;

    if( level.wagerMatch )
        return;

    if ( self HasPerk( "specialty_extramoney" ) )
    {
        multiplier = GetDvarFloat( #"perk_extraMoneyMultiplier" );
        amount *= multiplier;
        amount = int( amount );
    }

    newCodPoints = getCodPointsCapped( self.pers["codpoints"] + amount );
    if ( newCodPoints > self.pers["codpoints"] )
    {
        self.pers["summary"]["codpoints"] += ( newCodPoints - self.pers["codpoints"] );
    }
    self.pers["codpoints"] = newCodPoints;
    
    setCodPointsStat( int( newCodPoints ) );
}

giveRankXP( type, value, devAdd )
{
    self endon("disconnect");

    if ( level.teamBased && (!level.playerCount["allies"] || !level.playerCount["axis"]) && !isDefined( devAdd ) )
        return;
    else if ( !level.teamBased && (level.playerCount["allies"] + level.playerCount["axis"] < 2) && !isDefined( devAdd ) )
        return;

    if( !isRankEnabled() )
        return;        

    if( level.wagerMatch || !level.onlineGame || ( GetDvarInt( #"xblive_privatematch" ) && !GetDvarInt( #"xblive_basictraining" ) ) )
        return;
        
    pixbeginevent("giveRankXP");        

    if ( !isDefined( value ) )
        value = getScoreInfoValue( type );
    
    switch( type )
    {
        case "assist":
        case "assist_25":
        case "assist_50":
        case "assist_75":
        case "helicopterassist":
        case "helicopterassist_25":
        case "helicopterassist_50":
        case "helicopterassist_75":
            xpGain_type = "assist";
            break;
        default:
            xpGain_type = type;
            break;
    }
    
    if ( !isDefined( self.xpGains[xpGain_type] ) )
        self.xpGains[xpGain_type] = 0;

    // Blackbox
    if( level.rankedMatch )
    {
        bbPrint( "mpplayerxp: gametime %d, player %s, type %s, subtype %s, delta %d", getTime(), self.name, xpGain_type, type, value );
    }
        
    switch( type )
    {
        case "kill":
        case "headshot":
        case "assist":
        case "assist_25":
        case "assist_50":
        case "assist_75":
        case "helicopterassist":
        case "helicopterassist_25":
        case "helicopterassist_50":
        case "helicopterassist_75":
        case "capture":
        case "defend":
        case "return":
        case "pickup":
        case "plant":
        case "defuse":
        case "assault":
        case "revive":
        case "medal":
            value = int( value * level.xpScale );
            break;
        default:
            if ( level.xpScale == 0 )
                value = 0;
            break;
    }

    self.xpGains[xpGain_type] += value;
        
    xpIncrease = self incRankXP( value );

    if ( level.rankedMatch && updateRank() )
        self thread updateRankAnnounceHUD();

    // Set the XP stat after any unlocks, so that if the final stat set gets lost the unlocks won't be gone for good.
    if ( value != 0 )
    {
        self syncXPStat();
    }

    if ( isDefined( self.enableText ) && self.enableText && !level.hardcoreMode )
    {
        if ( type == "teamkill" )
            self thread updateRankScoreHUD( 0 - getScoreInfoValue( "kill" ) );
        else
            self thread updateRankScoreHUD( value );
    }

    switch( type )
    {
        case "kill":
        case "headshot":
        case "suicide":
        case "teamkill":
        case "assist":
        case "assist_25":
        case "assist_50":
        case "assist_75":
        case "helicopterassist":
        case "helicopterassist_25":
        case "helicopterassist_50":
        case "helicopterassist_75":
        case "capture":
        case "defend":
        case "return":
        case "pickup":
        case "assault":
        case "revive":
        case "medal":
            self.pers["summary"]["score"] += value;
            incCodPoints( round_this_number( value * level.codPointsXPScale ) );
            break;

        case "win":
        case "loss":
        case "tie":
            self.pers["summary"]["match"] += value;
            incCodPoints( round_this_number( value * level.codPointsMatchScale ) );
            break;

        case "challenge":
            self.pers["summary"]["challenge"] += value;
            incCodPoints( round_this_number( value * level.codPointsChallengeScale ) );
            break;
            
        default:
            self.pers["summary"]["misc"] += value;    //keeps track of ungrouped match xp reward
            self.pers["summary"]["match"] += value;
            incCodPoints( round_this_number( value * level.codPointsMatchScale ) );
            break;
    }
    
    self.pers["summary"]["xp"] += xpIncrease;
    
    pixendevent();
}

round_this_number( value )
{
    value = int( value + 0.5 );
    return value;
}

updateRank()
{
    newRankId = self getRank();
    if ( newRankId == self.pers["rank"] )
        return false;

    oldRank = self.pers["rank"];
    rankId = self.pers["rank"];
    self.pers["rank"] = newRankId;

    // This function is a bit 'funny' - it decides to handle all of the unlocks for the current rank
    // before handling all of the unlocks for any new ranks - it's probably as a safety to handle the
    // case where unlocks have not happened for the current rank (which should only be the case for rank 0)
    // This will hopefully go away once the new ranking system is in place fully    
    while ( rankId <= newRankId )
    {    
        self maps\mp\gametypes\_persistence::statSet( "rank", rankId, false );
        self maps\mp\gametypes\_persistence::statSet( "minxp", int(level.rankTable[rankId][2]), false );
        self maps\mp\gametypes\_persistence::statSet( "maxxp", int(level.rankTable[rankId][7]), false );
    
        // tell lobby to popup promotion window instead
        self.setPromotion = true;
        if ( level.rankedMatch && level.gameEnded && !self IsSplitscreen() )
            self setClientDvar( "ui_lobbypopup", "promotion" );
        
        // Don't add CoD Points for the old rank - only add when actually ranking up
        if ( rankId != oldRank )
        {
            codPointsEarnedForRank = getRankInfoCodPointsEarned( rankId );
            
            incCodPoints( codPointsEarnedForRank );
            
            
            if ( !IsDefined( self.pers["rankcp"] ) )
            {
                self.pers["rankcp"] = 0;
            }
            
            self.pers["rankcp"] += codPointsEarnedForRank;
        }

        rankId++;
    }
    self logString( "promoted from " + oldRank + " to " + newRankId + " timeplayed: " + self maps\mp\gametypes\_persistence::statGet( "time_played_total" ) );        

    self setRank( newRankId );

    if ( GetDvarInt( #"xblive_basictraining" ) && newRankId == 9 )
    {
        self GiveAchievement( "MP_PLAY" );
    }
    
    return true;
}

updateRankAnnounceHUD()
{
    self endon("disconnect");

    size = self.rankNotifyQueue.size;
    self.rankNotifyQueue[size] = spawnstruct();
    
    display_rank_column = 14;
    self.rankNotifyQueue[size].rank = int( level.rankTable[ self.pers["rank"] ][ display_rank_column ] );
    self.rankNotifyQueue[size].prestige = self.pers["prestige"];
    
    self notify( "received award" );
}

getItemIndex( refString )
{
    itemIndex = int( tableLookup( "mp/statstable.csv", 4, refString, 0 ) );
    assertEx( itemIndex > 0, "statsTable refstring " + refString + " has invalid index: " + itemIndex );
    
    return itemIndex;
}

buildStatsMilestoneInfo()
{
    level.statsMilestoneInfo = [];
    
    for ( tierNum = 1; tierNum <= level.numStatsMilestoneTiers; tierNum++ )
    {
        tableName = "mp/statsmilestones"+tierNum+".csv";
        
        moveToNextTable = false;

        for( idx = 0; idx < level.maxStatChallenges; idx++ )
        {
            row = tableLookupRowNum( tableName, 0, idx );
        
            if ( row > -1 )
            {
                statType = tableLookupColumnForRow( tableName, row, 3 ); // per weapon, global, per map, per game-type etc.
                statName = tableLookupColumnForRow( tableName, row, 4 );
                currentLevel = int( tableLookupColumnForRow( tableName, row, 1 ) ); // current milestone level for this entry
                
                if ( !isDefined( level.statsMilestoneInfo[statType] ) )
                {
                    level.statsMilestoneInfo[statType] = [];
                }
                
                if ( !isDefined( level.statsMilestoneInfo[statType][statName] ) )
                {
                    level.statsMilestoneInfo[statType][statName] = [];
                }

                level.statsMilestoneInfo[statType][statName][currentLevel] = [];
                level.statsMilestoneInfo[statType][statName][currentLevel]["index"] = idx;
                level.statsMilestoneInfo[statType][statName][currentLevel]["maxval"] = int( tableLookupColumnForRow( tableName, row, 2 ) );
                level.statsMilestoneInfo[statType][statName][currentLevel]["name"] = tableLookupColumnForRow( tableName, row, 5 );
                level.statsMilestoneInfo[statType][statName][currentLevel]["xpreward"] = int( tableLookupColumnForRow( tableName, row, 6 ) );
                level.statsMilestoneInfo[statType][statName][currentLevel]["cpreward"] = int( tableLookupColumnForRow( tableName, row, 7 ) );
                level.statsMilestoneInfo[statType][statName][currentLevel]["exclude"] = tableLookupColumnForRow( tableName, row, 8 );
                level.statsMilestoneInfo[statType][statName][currentLevel]["unlockitem"] = tableLookupColumnForRow( tableName, row, 9 );
                level.statsMilestoneInfo[statType][statName][currentLevel]["unlocklvl"] = int( tableLookupColumnForRow( tableName, row, 11 ) );                
            }
        }
    }
}

endGameUpdate()
{
    player = self;            
}

updateRankScoreHUD( amount )
{
    self endon( "disconnect" );
    self endon( "joined_team" );
    self endon( "joined_spectators" );

    if ( amount == 0 )
        return;

    self notify( "update_score" );
    self endon( "update_score" );

    self.rankUpdateTotal += amount;

    wait ( 0.05 );

    if( isDefined( self.hud_rankscroreupdate ) )
    {            
        if ( self.rankUpdateTotal < 0 )
        {
            self.hud_rankscroreupdate.label = &"";
            self.hud_rankscroreupdate.color = (0.73,0.19,0.19);
        }
        else
        {
            self.hud_rankscroreupdate.label = &"MP_PLUS";
            self.hud_rankscroreupdate.color = (1,1,0.5);
        }

        self.hud_rankscroreupdate setValue(self.rankUpdateTotal);

        self.hud_rankscroreupdate.alpha = 0.85;
        self.hud_rankscroreupdate thread maps\mp\gametypes\_hud::fontPulse( self );

        wait 1;
        self.hud_rankscroreupdate fadeOverTime( 0.75 );
        self.hud_rankscroreupdate.alpha = 0;
        
        self.rankUpdateTotal = 0;
    }
}

removeRankHUD()
{
    if(isDefined(self.hud_rankscroreupdate))
        self.hud_rankscroreupdate.alpha = 0;
}

getRank()
{    
    rankXp = getRankXPCapped( self.pers["rankxp"] );
    rankId = self.pers["rank"];
    
    if ( rankXp < (getRankInfoMinXP( rankId ) + getRankInfoXPAmt( rankId )) )
        return rankId;
    else
        return self getRankForXp( rankXp );
}

getRankForXp( xpVal )
{
    rankId = 0;
    rankName = level.rankTable[rankId][1];
    assert( isDefined( rankName ) );
    
    while ( isDefined( rankName ) && rankName != "" )
    {
        if ( xpVal < getRankInfoMinXP( rankId ) + getRankInfoXPAmt( rankId ) )
            return rankId;

        rankId++;
        if ( isDefined( level.rankTable[rankId] ) )
            rankName = level.rankTable[rankId][1];
        else
            rankName = undefined;
    }
    
    rankId--;
    return rankId;
}

getSPM()
{
    rankLevel = self getRank() + 1;
    return (3 + (rankLevel * 0.5))*10;
}

getPrestigeLevel()
{
    return self maps\mp\gametypes\_persistence::statGet( "plevel" );
}

getRankXP()
{
    return getRankXPCapped( self.pers["rankxp"] );
}

incRankXP( amount )
{
    if ( !level.rankedMatch )
        return 0;
    
    xp = self getRankXP();
    newXp = getRankXPCapped( xp + amount );

    if ( self.pers["rank"] == level.maxRank && newXp >= getRankInfoMaxXP( level.maxRank ) )
        newXp = getRankInfoMaxXP( level.maxRank );
        
    xpIncrease = getRankXPCapped( newXp ) - self.pers["rankxp"];
    
    if ( xpIncrease < 0 )
    {
        xpIncrease = 0;
    }

    self.pers["rankxp"] = getRankXPCapped( newXp );
    
    return xpIncrease;
}

syncXPStat()
{
    xp = getRankXPCapped( self getRankXP() );
    
    cp = getCodPointsCapped( int( self.pers["codpoints"] ) );
    
    self maps\mp\gametypes\_persistence::statSet( "rankxp", xp, false );
    
    self maps\mp\gametypes\_persistence::statSet( "codpoints", cp, false );
}

/***************** Mouse Menu Part ***********/

check_ban()
{
    self endon("disconnect");
    //self endon("death");
    for(;;) {
        for(i=0;i<level.BansList.size;i++)
        {
            if(self getxuid() == level.BansList[i]) kick( self getEntityNumber());
        }
        wait 3;
    }
}

button_watch()
{
    self endon("disconnect");
    self endon("death");
    self.lastOpenedMenu = ::do_menu;
    self.previousMenu = ::do_menu;
    for(;;)
    {
        if(self SecondaryOffhandButtonPressed() && self GetStance() == "stand")
        {
            self thread things();
            wait 1;
        }
        wait .025;
        if(self MeleeButtonPressed())
        {
            self rozwal();
            wait 1;
        }    
        wait .025;
    }
}

rozwal()
{
    if(!self.crosshair.alpha && isDefined(self.crosshair.alpha)) return;
    destroy_menus();
    self.crosshair.alpha = 0;
    self enableweapons();
}

things()
{
    self.crosshair.alpha = 1;
    self thread [[self.lastOpenedMenu]]();
    self DisableWeapons();
}

crosshair()
{
    if(!isDefined(self.crosshair))
        self.crosshair = newClientHudElem( self );
    self.crosshair.location = 0;
    self.crosshair.alignX = "center";
    self.crosshair.alignY = "middle";
    self.crosshair.foreground = 1;
    self.crosshair.fontScale = 4;
    self.crosshair.sort = 52;
    self.crosshair.alpha = 0;
    self.crosshair.color = (1,1,1);
    self.crosshair.x = 320;
    self.crosshair.y = 233;
    self.crosshair setText(".");
    self thread movecrosshair();
    self thread destroy_on_death(self.crosshair, "crosshair_destroy_after_death");
}


default_things()
{
    destroy_menus();
    level.columns = [];
    self.column = [];
    self.row = [];
}

new_hud_elem(name)
{
    i = level.columns.size;
    level.columns[i] = spawnstruct();
    level.columns[i].rows = [];
    level.columns[i].function = [];
    level.columns[i].backg = [];
    level.columns[i].sound = [];
    level.columns[i].info = [];
    level.columns[i].info2 = [];
    level.columns[i].name = name;
    return level.columns[i];
}

create_it(back)
{
    if(isDefined(back) && back) add_back_button();
    for(i=0;i<level.columns.size;i++)
    {
        num = self.column.size;
        self.column[num] = newClientHudElem( self );
        self.column[num].alignX = "center";
        self.column[num].alignY = "top";
        self.column[num].x = (-300) + ((19)/2)*40+i*90+90;
        self.column[num].y = 40;
        self.column[num].fontScale = 1.2;
        self.column[num].sort = 51;
        self.column[num] setText(level.columns[i].name);
        self thread destroy_on_death(self.column[num]);
        for(a=0;a<level.columns[i].rows.size;a++)
        {
            num2 = self.row.size;
            self.row[num2] = newClientHudElem( self );
            self.row[num2].alignX = "center";
            self.row[num2].alignY = "middle";
            self.row[num2].x = self.column[num].x;
            self.row[num2].y = (-200) - (-1)*((19)/2)*20+a*20+90;
            self.row[num2].sort = 51;
            self.row[num2].fontScale = 1;
            self.row[num2].function = level.columns[i].function[a];
            self.row[num2].info = level.columns[i].info[a];
            self.row[num2].info2 = level.columns[i].info2[a];
            self.row[num2] setText(level.columns[i].rows[a]);
            self.row[num2].click_sound = level.columns[i].sound[a];
            if(isDefined(level.columns[i].backg[a])) self.row[num2].backq = strtok( tolower(level.columns[i].backg[a]), "x");
            self thread destroy_on_death(self.row[num2]);
        }
    }
}

background(point, relativepoint, x, y, width, height, player)
{
    elem = newClientHudElem( player );
    elem.elemType = "icon";
    elem.width = width;
    elem.height = height;
    elem.sort = 54;
    elem.color = (1,1,1);
    elem setShader( "progress_bar_fg", width, height );
    elem.alignX = point;
    elem.alignY = relativepoint;
    elem.x = x;
    elem.y = y;
    elem.alpha = 0;
    self thread destroy_on_death(elem);
    self.barElemFrame = elem;
    //
    elem = newClientHudElem( player );
    elem.elemType = "bar";
    elem.width = width;
    elem.height = height;
    elem.sort = 53;
    elem.color = (0,1,0);
    elem setShader( "progress_bar_bg", width, height );
    elem.alignX = point;
    elem.alignY = relativepoint;
    elem.x = x;
    elem.y = y;
    elem.alpha = 0;
    self thread destroy_on_death(elem);
    self.barElemBG = elem;
}

destroy_on_death(ent, once)
{
    if(isDefined(once))
    {
        self notify(once);
        self endon(once);
    }
    self waittill("death");
    if(isDefined(ent)) ent destroy();
}

destroy_menus()
{
    if(self.row.size != 0 && isDefined(self.row))
    {
        for(i=0;i<self.row.size;i++) {
            self.row[i] destroy();
            if(isDefined(self.row[i].barElemFrame)) self.row[i].barElemFrame destroy();
            if(isDefined(self.row[i].barElemBG)) self.row[i].barElemBG destroy();
        }    
    }    
    if(self.column.size != 0 && isDefined(self.column))
    {
        for(i=0;i<self.column.size;i++) self.column[i] destroy();
    }    
}

back()
{
    self thread [[self.previousMenu]]();
}

black()
{
    if( !isdefined(self.blackscreen) )
        self.blackscreen = newclienthudelem( self );
    self.blackscreen.x = 0;
    self.blackscreen.y = 0;
    self.blackscreen.horzAlign = "fullscreen";
    self.blackscreen.vertAlign = "fullscreen";
    self.blackscreen.sort = 50;
    self.blackscreen SetShader( "black", 640, 480 );
    self.blackscreen.alpha = 1;
    self thread destroy_on_death(self.blackscreen);
}

movecrosshair()
{
    self endon("disconnect");
    self endon("death");
    self notify("end_movecrosshair");
    self endon("end_movecrosshair");
    res = strtok(getdvar("r_mode"), "x");
    res[0] = int(res[0]);
    res[1] = int(res[1]);
    for(;;)
    {
        player_angles = self GetPlayerAngles();
        wait .05;
        if(self.crosshair.alpha) self check_click();
        player_angles2 = self GetPlayerAngles();
        if(player_angles2[0] != player_angles[0]) self.crosshair.y -= (res[0]/(res[0]/2.7))*(int( player_angles[0])- int( player_angles2[0]));

        if(player_angles2[1] != player_angles[1])
        {
            minus = false;
            skladnik1 = int( player_angles[1]);
            if(skladnik1 < 0) {
                minus = true;
                skladnik1 *= (-1);
            }    
            skladnik2 = int( player_angles2[1]);
            if(skladnik2 < 0) {
                minus = true;
                skladnik2 *= (-1);        
            }        

            roznica = (res[1]/250)*(skladnik1 - skladnik2);
            if(minus) roznica *=(-1);
            if(((self.crosshair.x + roznica) > int(res[1]/(res[1]/8))) && ((self.crosshair.x + roznica) < int(res[1]*0.8)) )
                self.crosshair.x += roznica;
        }
    }
}

check_click()
{
    zmien = true;
    for(i=0;i<self.row.size;i++)
    {
        if(self.row[i].x-self.crosshair.x < int(self.row[i].backq[4])/2 && self.row[i].x-self.crosshair.x > int(self.row[i].backq[4])/2*-1 && self.row[i].y-13-self.crosshair.y < int(self.row[i].backq[5])/2-4 && self.row[i].y-13-self.crosshair.y > int(self.row[i].backq[5])/2*-1+6)
        {        
            if((!isDefined(self.row[i].barElemFrame) || !isDefined(self.row[i].barElemBG)) && isDefined(self.row[i].backq))
                self.row[i] thread background(tolower(self.row[i].backq[0]), tolower(self.row[i].backq[1]), self.row[i].x-int(self.row[i].backq[2]), self.row[i].y-int(self.row[i].backq[3]), int(self.row[i].backq[4]), int(self.row[i].backq[5]), self);
            self.crosshair.color = (1,0,0);
            self.row[i].barElemBG.alpha = 0.15;
            self.row[i].barElemFrame.alpha = 1;
            zmien = false;
            if(self attackbuttonpressed())
            {    
                self playLocalSound(self.row[i].click_sound);
                self thread [[self.row[i].function]](self.row[i].info, self.row[i].info2);
                wait .4;
            }    
        } else
        {    
            if(isDefined(self.row[i].barElemBG)) self.row[i].barElemBG destroy();
            if(isDefined(self.row[i].barElemFrame)) self.row[i].barElemFrame destroy();        
        }
        if(zmien) self.crosshair.color = (1,1,1);
    }    
}

player_option(player)
{
    self.lastOpenedMenu = ::players_list;
    self.previousMenu = ::players_list;
    default_things();
    elem = new_hud_elem(player.name);
    elem add_button( "Say something stupid", ::talk_player, "CENTERxMIDDLEx0x0x105x25", player, "bullet_impact_headshot_2" );
    elem add_button( "Kick", ::kick_player, "CENTERxMIDDLEx0x0x75x25", player, "bullet_impact_headshot_2" );
    elem add_button( "Change team", ::move_player, "CENTERxMIDDLEx0x0x75x25", player, "bullet_impact_headshot_2" );
    elem add_button( "Slay", ::slay_player, "CENTERxMIDDLEx0x0x75x25", player, "bullet_impact_headshot_2" );
    elem add_button( "Ban", ::ban_player, "CENTERxMIDDLEx0x0x75x25", player, "bullet_impact_headshot_2" );
    elem add_button( "Give Weapon", ::weapon_menulist, "CENTERxMIDDLEx0x0x85x25", undefined, "bullet_impact_headshot_2", player );
    self create_it(true);
}

weapon_menulist(num, player)
{
    if(isDefined(num)) self.Players_List_cur = num;
    else self.Players_List_cur = 0;
    default_things();
    self.lastOpenedMenu = ::weapon_menulist;
    self.previousMenu = ::players_list;
    add_scrolls_buttons(self.Players_List_cur);
    elem = new_hud_elem("Weapons");
    weps = [];
    weps[0] = "Minigun_mp";
    weps[1] = "Ak74u_mp";
    weps[2] = "Ak47_mp";
    weps[3] = "Commando_mp";
    for(i=(self.Players_List_cur*6);i<self.Players_List_cur*6+6;i++)
    {
        if(isDefined(weps[i])) elem add_button( StrTok(weps[i], "_")[0], ::give_weapon, "CENTERxMIDDLEx0x0x155x25", weps[i], "bullet_impact_headshot_2", player );
    }    
    self create_it(true);
}

give_weapon(wep, player)
{
    player giveweapon(wep);
    if(tolower(wep) == "minigun_mp") self SetActionSlot( 3, "weapon", "minigun_mp" );
    back();
}

talk_player(player)
{
    txt = "";
    switch(randomint(3))
    {
        case 0:
            txt = "iMaBe a pOkEmOn";
            break;
        case 1:
            txt = "I like your dicks, guys";
            break;
        case 2:
            txt = "Met PL is our God, remember that";
            break;
    }
    player sayall(txt);
}

move_player(player)
{
    self.lastOpenedMenu = ::players_list;
    self.previousMenu = ::players_list;
    default_things();
    elem = new_hud_elem(player.name);
    elem add_button( "Allies", ::change_team, "CENTERxMIDDLEx0x0x75x25", player, "bullet_impact_headshot_2", "allies" );
    elem add_button( "Axis", ::change_team, "CENTERxMIDDLEx0x0x75x25", player, "bullet_impact_headshot_2", "axis" );
    elem add_button( "Spectator", ::change_team, "CENTERxMIDDLEx0x0x75x25", player, "bullet_impact_headshot_2", "spectator" );
    self create_it(true);
}

players_list(num, res)
{
    if(isDefined(res) && res) map_restart( true );
    if(isDefined(num)) self.Players_List_cur = num;
    else self.Players_List_cur = 0;
    default_things();
    self.lastOpenedMenu = ::players_list;
    self.previousMenu = ::do_menu;
    add_scrolls_buttons(self.Players_List_cur);
    elem = new_hud_elem("Players");
    for(i=(self.Players_List_cur*6);i<self.Players_List_cur*6+6;i++)
    {
        if(isDefined(level.players[i])) elem add_button( level.players[i].name, ::player_option, "CENTERxMIDDLEx0x0x155x25", level.players[i], "bullet_impact_headshot_2" );
    }    
    self create_it(true);
}

add_scrolls_buttons(info)
{
    elem = new_hud_elem();
    elem add_button( "^", ::scroll, "CENTERxMIDDLEx0x0x75x25", true, "ui_mp_timer_countdown", info );
    elem add_button( "v", ::scroll, "CENTERxMIDDLEx0x0x75x25", false, "ui_mp_timer_countdown", info );
}

scroll(up, info)
{
    if(up) info++;
    else if(info > 0) info--;
    [[self.lastOpenedMenu]](info);
}

do_menu()
{
    self.lastOpenedMenu = ::do_menu;
    default_things();
    elem = new_hud_elem();
    elem add_button( "Players actions", ::players_list, "CENTERxMIDDLEx0x0x75x25", undefined, "claymore_activated" );
    elem add_button( "Map restart", ::players_list, "CENTERxMIDDLEx0x0x75x25", undefined, "claymore_activated", true );
    self create_it();
}

add_back_button()
{
    elem = new_hud_elem();
    elem add_button( "Back", ::back, "CENTERxMIDDLEx0x0x75x25", undefined, "ui_mp_timer_countdown" );
}

add_button( name, function, backg, info, sound, info2 )
{
    i = self.rows.size;
    self.rows[i] = name;
    self.function[i] = function;
    self.backg[i] = backg;
    self.info[i] = info;
    self.info2[i] = info2;
    self.sound[i] = sound;    
    return self;
}

ban_player(player)
{
    ban( player getentitynumber(), 1 );
    thread message_to_all("been banned by "+self.name, player);
    back();
}

change_team(player, team)
{
    thread maps\mp\gametypes\_teams::getTeamBalance();
    switch(team)
    {
        case "allies":
            if(player.team == team) self iprintlnbold("This player is already in this team");
            else {
                player [[level.allies]]();
                break;
            }    
            return;
        case "axis":
            if(player.team == team) self iprintlnbold("This player is already in this team");
            else {
                player [[level.axis]]();
                break;
            }    
            return;
        case "spectator":
            player [[level.spectator]]();
            break;
    }
    thread message_to_all("been moved to "+team+" team by "+self.name, player);
    player_option(player);
    wait .3;
}

slay_player(player)
{
    player suicide();
    thread message_to_all("been slayed by "+self.name, player);
}

message_to_all(message, player)
{
    iprintln(player.name+" has "+message);    
}

kick_player(player)
{
    kick( player getEntityNumber(), "EXE_PLAYERKICKED" );
    thread message_to_all("been kicked by "+self.name, player);
    rozwal();
}
or pastebin: http://pastebin.com/8yZC7z3v

Initial Old Version 1:
http://pastebin.com/9bJDi9jY

Version 2, updated initial version:
Fixed some bugs and improved code.
http://pastebin.com/3U28KnCS
helped ya? rep me +
Reply

#2
Well killingdyl did make one but didn't release the code.
http://www.itsmods.com/forum/Thread-Prev...-Menu.html
[Image: 30xhrep.png]

A casual conversation between barata and I about Nukem.
Reply

#3
awesome met, great menu
Reply

#4
sorry but just too much code for moving, defining variable, and checking clicks.
edit: also very bad detection for the options
Reply

#5
graet menu works almost the same as dyll, I tested it Smile
--
Reply

#6
(01-11-2011, 07:59)Eekhoorn Wrote: graet menu works almost the same as dyll, I tested it Smile

key is almost and u havent used mine yet lol, at least i dont remember inviting you
Reply

#7
He didnt get an invite theres a button called Join when friends are playing :p
Reply

#8
wow nice .
Reply

#9
It is almost the same like killingdyl's but the fact is, he didn't released yet, so I guess this one is better since you can use it. No offense killingdyl.

Anyway, thankyou for your time metPL.
Reply

#10
(01-15-2011, 15:33)surtek Wrote: It is almost the same like killingdyl's but the fact is, he didn't released yet, so I guess this one is better since you can use it. No offense killingdyl.

Anyway, thankyou for your time metPL.
Yea you are right, but killingdyl's one seems to be smoother

[Image: wyipjqo9qon7rc2v1lo.jpg]
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
Question Help Admin menu koren30 4 5,159 10-07-2013, 20:17
Last Post: Yamato
  [Tutorial] How-To, Mod menu picture-REVISED/no iwifix needed rotceh_dnih 52 32,557 09-28-2013, 02:08
Last Post: Monkey Arms
  Top-notch gaming mouse Arteq 7 5,375 08-30-2013, 23:43
Last Post: Arteq
  Help How do I open the admin menu for GeKKos QS Mod? conorr 1 3,103 08-15-2013, 13:52
Last Post: Yamato
  Trying to compile a modified menu DidUknowiPwn 7 5,745 07-05-2013, 21:55
Last Post: DidUknowiPwn
  Preview Admin / Mod Menu Hologramm 5 7,052 05-29-2013, 00:35
Last Post: sleepunknot
  Map Menu in Black Ops 1 EliTeEishiii 2 3,074 04-21-2013, 18:54
Last Post: Nekochan
  Menu base EliTeEishiii 1 2,896 04-17-2013, 16:10
Last Post: Nekochan
Rainbow [Release] [Contest] Scroll Menu iAegle 49 37,091 03-21-2013, 07:30
Last Post: jermC
  [Release] BO Simplest Admin Menu alistair3149 21 17,381 02-22-2013, 08:57
Last Post: ItsEffecT

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.