/changerace help...limiting access to a race

Read log files for errors! If this fails, come here for help

Moderator: Forum Moderator

Post Reply
whosyourdaddy
Spell Breaker
Posts: 398
Joined: Sun Apr 27, 2008 10:11 pm

Re: /changerace help...limiting access to a race

Post by whosyourdaddy » Wed Feb 17, 2010 2:24 am

in menus.inl find

Code: Select all

		// All other cases
		else
		{
			/*
			new iRaceLimit = get_pcvar_num( CVAR_wc3_race_limit );
			new bool:bAllowRace = true;

			if ( iRaceLimit > 0 )
			{
				new iTotal[MAX_RACES];

				// Get how many people are using each race
				new iPlayers[32], iNumPlayers, i, iTarget;
				get_players( iPlayers, iNumPlayers );

				for ( i = 0; i < iNumPlayers; i++ )
				{
					iTarget = iPlayers[i];

					if ( iTarget != id && p_data[iTarget][P_RACE] > 0 && p_data[iTarget][P_RACE] <= get_pcvar_num( CVAR_wc3_races ) )
					{
						iTotal[p_data[iTarget][P_RACE]]++;
					}
				}
				
				// Now if we have more races selected than iRaceLimit provides us with, then we need to increase iRaceLimit
				while ( HLPR_TotalUsingRaces( iTotal ) > iRaceLimit * get_playersnum() )
				{
					iRaceLimit++;
				}

				// Check to see if there was an increase that was necessary
				if ( iRaceLimit > get_pcvar_num( CVAR_wc3_race_limit ) )
				{
					WC3_Log( true, "Error, increase wc3_race_limit to at least %d", iRaceLimit );
				}

				if ( iTotal[i+1] >= iRaceLimit )
				{
					bAllowRace = false;

				}
			}*/

			new bool:bAllowRace = true;

			// Check to see if the user can choose this race (are there too many of this race?)
			if ( bAllowRace )
			{
				pos += formatex( szMenu[pos], 512-pos, "\w%d. %s\y\R%s^n", i + 1, szRaceName[i], ( (get_pcvar_num( CVAR_wc3_save_xp )) ? szXP : " " ) );

				iKeys |= (1<<i);
			}

			// If not, display the race, but don't give them a key to press
			else
			{
				pos += formatex( szMenu[pos], 512-pos, "\d%d. %s\y\R%s^n", i + 1, szRaceName[i], ( (get_pcvar_num( CVAR_wc3_save_xp )) ? szXP : " " ) );
			}
		}
and paste this

Code: Select all

		// All other cases
		else
		{
			new bool:bAllowRace = true;

			if(i == 9 && !(get_user_flags( id ) & ADMIN_LEVEL_Z) )
				bAllowRace = false;

			// Check to see if the user can choose this race (are there too many of this race?)
			if ( bAllowRace )
			{
				pos += formatex( szMenu[pos], 512-pos, "\w%d. %s\y\R%s^n", i + 1-z, szRaceName[i], ( (get_pcvar_num( CVAR_wc3_save_xp )) ? szXP : " " ) );

				iKeys |= (1<<i-z);
			}

			// If not, display the race, but don't give them a key to press
			else
			{
				pos += formatex( szMenu[pos], 512-pos, "\y%d. %s\y\R%s^n", i + 1-z, szRaceName[i], ( (get_pcvar_num( CVAR_wc3_save_xp )) ? szXP : " " ) );
			}
		}
Image

User avatar
YamiKaitou
Forum Moderator
Forum Moderator
Posts: 1925
Joined: Wed Feb 01, 2006 4:33 pm
Contact:

Re: /changerace help...limiting access to a race

Post by YamiKaitou » Wed Feb 17, 2010 9:07 am

The problem with using Z is that EVERYONE except for your admins will have access to it. The default default flag is Z. Also, the define would be ADMIN_USER not ADMIN_LEVEL_Z
Image

No support via PM or Email

User avatar
YamiKaitou
Forum Moderator
Forum Moderator
Posts: 1925
Joined: Wed Feb 01, 2006 4:33 pm
Contact:

Re: /changerace help...limiting access to a race

Post by YamiKaitou » Wed Feb 17, 2010 10:53 am

(get_user_flags( id ) & ADMIN_USER) returns a bool. To use Flag M, use ADMIN_LEVEL_A
Image

No support via PM or Email

User avatar
YamiKaitou
Forum Moderator
Forum Moderator
Posts: 1925
Joined: Wed Feb 01, 2006 4:33 pm
Contact:

Re: /changerace help...limiting access to a race

Post by YamiKaitou » Wed Feb 17, 2010 12:22 pm

if(i == 9 && !(get_user_flags( id ) & ADMIN_LEVEL_A) )
bAllowRace = false;
Image

No support via PM or Email

dancer
Peon
Posts: 4
Joined: Thu Jan 19, 2012 2:47 pm

Re: /changerace help...limiting access to a race

Post by dancer » Thu Jan 19, 2012 3:23 pm

I tested it and it isn't working. When I try to compile war3ft.sma I have errors like that :

Image


And that is my menus.inl ' s part :

Code: Select all

// All other cases
      else
      {
         new bool:bAllowRace = true;

         if(i == 9 && !(get_user_flags( id ) & ADMIN_LEVEL_A) )
         bAllowRace = false;

         // Check to see if the user can choose this race (are there too many of this race?)
         if ( bAllowRace )
         {
            pos += formatex( szMenu[pos], 512-pos, "\w%d. %s\y\R%s^n", i + 1-A, szRaceName[i], ( (get_pcvar_num( CVAR_wc3_save_xp )) ? szXP : " " ) );

            iKeys |= (1<<i-A);
         }

         // If not, display the race, but don't give them a key to press
         else
         {
            pos += formatex( szMenu[pos], 512-pos, "\y%d. %s\y\R%s^n", i + 1-A, szRaceName[i], ( (get_pcvar_num( CVAR_wc3_save_xp )) ? szXP : " " ) );
			}
		}

	}
I just change the Z flag to A flag and z symbol to A symbol.
Am I doing something wrong? Or maybe is there any another way to restrict chameleon only for admin/VIP ?
Please reply.

Post Reply