Archived copy of war3source.com, the War3Source forum (2009–2020), rebuilt from the Internet Archive by wc3mods.net. This page was captured on 2012-10-24 (original capture). Forum · All archived topics · Wiki · Bug tracker · Blog
Chat

War3:Source
October 24, 2012, 10:05:26 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Download: http://war3source.com/index.php?board=9.0
What is War3Source?: http://war3source.com/index.php?topic=200.0
Sample Stats: http://war3source.com/war3stats
Steam Community Group: http://steamcommunity.com/groups/war3source
War3Source SVN Checkout: http://ownageclan.com/svn/war3source/
War3Source servers: http://www.game-monitor.com/search.php?vars=war3_version=
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Changerace Menu  (Read 308 times)
Ben
Newbie
*
Posts: 9



View Profile
« on: June 23, 2010, 02:39:05 AM »

changerace menu

I suggest to make non accessible races non-selectable, further to show your current total level in the changerace menu. Just an example:



If you are willing to make it (partial) official or for those who want to change their changerace-menu, here are the changes I made to menu.inc (example):

Code: (sourcepawn)
public War3Source_ChangeRaceMenu(client)
{
if (GetClientTeam(client) > 1)
{
ChangeClientTeam(client, 1);
PrintHintText(client, "You must be Spectator to change race!");
}

if(m_bBeenLoaded[client])
{
new Handle:crMenu=CreateMenu(War3Source_CRMenu_Selected);
SetMenuExitButton(crMenu,true);
// Iteriate through the races and print them out
new Handle:race;
decl String:rbuf[4];
decl String:rname[64];
decl String:rdisp[128];
new vecpos=GetClientVectorPosition(client);
if(vecpos>=0)
{
new total_level=0;
for(new z=1;z<RACE_COUNT;z++)
{
total_level+=GetLevel(vecpos,z);
}
SetMenuTitle(crMenu,"[War3Source] Select your desired race.\n \nSome races require a Minimum of total\nlevel. You get your total level if you add\nall levels from all your races.\n \nYour current total level: %d\n \n", total_level);
for(new x=1;x<RACE_COUNT;x++)
{
race=Race(x);
Format(rbuf,4,"%d",x);
GetArrayString(race,0,rname,64);
Format(rdisp,128,"%s (Level %d)",rname,GetLevel(vecpos,x));
new minlevel=GetConVarInt(GetArrayCell(race,12));
if(minlevel<0) minlevel=0;
if(minlevel>0)
{
Format(rdisp,128,"%s (MinLvl %d)",rdisp,minlevel);
}
if(HasAccess(client,race))
{
if(minlevel>total_level)
{
AddMenuItem(crMenu,rbuf,rdisp,ITEMDRAW_DISABLED);
}
else
{
AddMenuItem(crMenu,rbuf,rdisp);
}
}
}
DisplayMenu(crMenu,client,MENU_TIME_FOREVER);
}
}
}

The problem I still have is to sort the races by Minimum Level. It is not true that sourcemod loads plugins alphabetically. Bailopan said that there is no guaranteed order on any operating system. https://forums.alliedmods.net/showthread.php?t=79391 I'll post a solution as soon as I'll find one ... and if anyone is interested.

Ben
« Last Edit: June 23, 2010, 12:28:52 PM by Ben » Logged
Naris
Jr. Member
**
Posts: 60


View Profile Email
« Reply #1 on: June 23, 2010, 06:43:30 PM »


The problem I still have is to sort the races by Minimum Level.

Create another adt_array to use an index and insert the values into the index array in order, something like this:
Code: (sourcepawn)
new Handle:raceIndex = INVALID_HANDLE;

CreateRace(...)
{
        new Handle:indexHandle, raceLevel;
        decl String:raceName[NAME_STRING_LENGTH];
        new race=0;
        new indexCount=GetArraySize(raceIndex);
        for(;race<indexCount;race++)
        {
            if (race > 0)
            {
                indexHandle = GetRaceIndexHandle(race);
                raceLevel = GetRaceRequiredLevel(indexHandle);
                if (raceLevel < 0)
                    raceLevel = 65535;
                if (required_level <= raceLevel)
                {
                    GetRaceName(indexHandle, raceName, sizeof(raceName));
                    if (required_level < raceLevel || strcmp(name,raceName,false) <= 0)
                    {
                        if (race > 0)
                        {
                            ShiftArrayUp(raceIndex, race);
                            SetArrayCell(raceIndex, race, raceHandle);
                        }
                        else
                            race = -1;
                        break;
                    }
                }
            }
        }

        if (race <= 0 || race >= indexCount)
            PushArrayCell(raceIndex,raceHandle);
}

Then iterate through the index array when displaying the menu.
Logged
Ownz
Developer
Administrator
Hero Member
*****
Posts: 2045



View Profile WWW Email
« Reply #2 on: June 23, 2010, 09:57:09 PM »

ill look into this, but i will keep the (number on ur team:number on enemyteam)

Logged

DarkEnergy
Ownz
Developer
Administrator
Hero Member
*****
Posts: 2045



View Profile WWW Email
« Reply #3 on: June 23, 2010, 10:00:19 PM »

and we keep the naming consistent so that the races will load in intended order
Logged

DarkEnergy
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!