SA-MP Forums Archive
TDM Class Choosing Bug - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: TDM Class Choosing Bug (/showthread.php?tid=444705)



TDM Class Choosing Bug - DJ_Shocker - 17.06.2013

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.


Re: TDM Class Choosing Bug - Kirollos - 17.06.2013

change the ">=" into "<="


Re: TDM Class Choosing Bug - feartonyb - 17.06.2013

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;
            }



Re: TDM Class Choosing Bug - DJ_Shocker - 17.06.2013

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!


Respuesta: TDM Class Choosing Bug - Strier - 17.06.2013

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 )


AW: TDM Class Choosing Bug - BigETI - 18.06.2013

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