TDM Class Choosing Bug
#1

Hello. I'm trying to fix a bug in our TDM Script.

Here's the code:

pawn Код:
if(PRESSED(KEY_JUMP)) // LSHIFT
    {
        if(IsPlayerChoosingClass[playerid] == 1)
        {
            if(ClassChoosingStep[playerid] == 0) // ASSAULT
            {
                gClass[playerid] = ASSAULT;
            }
            if(ClassChoosingStep[playerid] == 1) // MEDIC
            {
                if(Rank(playerid) >= 2) return SendClientMessage(playerid, C_WHITE, "Your rank is not high enough!");
                gClass[playerid] = MEDIC;
            }
            if(ClassChoosingStep[playerid] == 2) // ANTI-TANK
            {
                if(Rank(playerid) >= 3) return SendClientMessage(playerid, C_WHITE, "Your rank is not high enough!");
                gClass[playerid] = ANTI-TANK;
            }
            if(ClassChoosingStep[playerid] == 3) // ENGINEER
            {
                if(Rank(playerid) >= 4) return SendClientMessage(playerid, C_WHITE, "Your rank is not high enough!");
                gClass[playerid] = ENGINEER;
            }
            if(ClassChoosingStep[playerid] == 4) // AIRFORCE
            {
                if(Rank(playerid) >= 5) return SendClientMessage(playerid, C_WHITE, "Your rank is not high enough!");
                gClass[playerid] = AIRFORCE;
            }
            if(ClassChoosingStep[playerid] == 5) // SPECICAL-OPS
            {
                if(Rank(playerid) >= 6) return SendClientMessage(playerid, C_WHITE, "Your rank is not high enough!");
                gClass[playerid] = SPEC-OPS;
            }
Now once you start reaching Rank 4 or higher, it won't let you choose anything lower, except Assault.
I'd like some help in fixing this.
Reply
#2

change the ">=" into "<="
Reply
#3

Here you go

Код:
if(PRESSED(KEY_JUMP)) // LSHIFT
    {
        if(IsPlayerChoosingClass[playerid] == 1)
        {
            if(ClassChoosingStep[playerid] == 0) // ASSAULT
            {
                gClass[playerid] = ASSAULT;
            }
            if(ClassChoosingStep[playerid] == 1) // MEDIC
            {
                if(Rank(playerid) < 2) return SendClientMessage(playerid, C_WHITE, "Your rank is not high enough!");
                gClass[playerid] = MEDIC;
            }
            if(ClassChoosingStep[playerid] == 2) // ANTI-TANK
            {
                if(Rank(playerid) < 3) return SendClientMessage(playerid, C_WHITE, "Your rank is not high enough!");
                gClass[playerid] = ANTI-TANK;
            }
            if(ClassChoosingStep[playerid] == 3) // ENGINEER
            {
                if(Rank(playerid) < 4) return SendClientMessage(playerid, C_WHITE, "Your rank is not high enough!");
                gClass[playerid] = ENGINEER;
            }
            if(ClassChoosingStep[playerid] == 4) // AIRFORCE
            {
                if(Rank(playerid) < 5) return SendClientMessage(playerid, C_WHITE, "Your rank is not high enough!");
                gClass[playerid] = AIRFORCE;
            }
            if(ClassChoosingStep[playerid] == 5) // SPECICAL-OPS
            {
                if(Rank(playerid) < 6) return SendClientMessage(playerid, C_WHITE, "Your rank is not high enough!");
                gClass[playerid] = SPEC-OPS;
            }
Reply
#4

Quote:
Originally Posted by feartonyb
Посмотреть сообщение
Here you go

Код:
if(PRESSED(KEY_JUMP)) // LSHIFT
    {
        if(IsPlayerChoosingClass[playerid] == 1)
        {
            if(ClassChoosingStep[playerid] == 0) // ASSAULT
            {
                gClass[playerid] = ASSAULT;
            }
            if(ClassChoosingStep[playerid] == 1) // MEDIC
            {
                if(Rank(playerid) < 2) return SendClientMessage(playerid, C_WHITE, "Your rank is not high enough!");
                gClass[playerid] = MEDIC;
            }
            if(ClassChoosingStep[playerid] == 2) // ANTI-TANK
            {
                if(Rank(playerid) < 3) return SendClientMessage(playerid, C_WHITE, "Your rank is not high enough!");
                gClass[playerid] = ANTI-TANK;
            }
            if(ClassChoosingStep[playerid] == 3) // ENGINEER
            {
                if(Rank(playerid) < 4) return SendClientMessage(playerid, C_WHITE, "Your rank is not high enough!");
                gClass[playerid] = ENGINEER;
            }
            if(ClassChoosingStep[playerid] == 4) // AIRFORCE
            {
                if(Rank(playerid) < 5) return SendClientMessage(playerid, C_WHITE, "Your rank is not high enough!");
                gClass[playerid] = AIRFORCE;
            }
            if(ClassChoosingStep[playerid] == 5) // SPECICAL-OPS
            {
                if(Rank(playerid) < 6) return SendClientMessage(playerid, C_WHITE, "Your rank is not high enough!");
                gClass[playerid] = SPEC-OPS;
            }
This worked! Thanks!!! +Rep!
Reply
#5

Fearton your code wouldn't work as he wants, because with the < operator you're basically saying that the number has to be below the defined number.. for example. if( number 1 < number 2 ) this means number 2 is less than number 1 yea, but this would be number 1 then, the difference between the < and the <= tags is that with the <= it also checks for the second number.

if( number 1 <= number 2 )
Reply
#6

<= just means "smaller than or equals", while < just means "smaller than"...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)