[Help] Malfunction Code
#1

I Writen this code, to choose weapons in the game (with text draws), there's a function to show and hide every TXD that are contained in "if", there's a button to go and back, (MN_BotaoIR[playerid], MN_BotaoVIR[playerid]), but when i start the server, and click in the button, he doesn't work, somebody know why?

pawn Code:
public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid)
{
    if((playertextid == MN_BotaoIR[playerid]) && (Check == 0))
    {
        FecharCruzelion(playerid);
        MostrarPioneer(playerid);
        Check = 1;
    }
    if((playertextid == MN_BotaoVIR[playerid]) && (Check == 0))
    {
        FecharCruzelion(playerid);
        MostrarColt(playerid);
        Check = 6;
    }
    if((playertextid == MN_BotaoIR[playerid]) && (Check == 1))
    {
        FecharPioneer(playerid);
        MostrarHeckler(playerid);
        Check = 2;
    }
    if((playertextid == MN_BotaoVIR[playerid]) && (Check == 1))
    {
        FecharPioneer(playerid);
        MostrarCruzelion(playerid);
        Check = 0;
    }
    if((playertextid == MN_BotaoIR[playerid]) && (Check == 2))
    {
        FecharHeckler(playerid);
        MostrarSten(playerid);
        Check = 3;
    }
    if((playertextid == MN_BotaoVIR[playerid]) && (Check == 2))
    {
        FecharHeckler(playerid);
        MostrarPioneer(playerid);
        Check = 1;
    }
    if((playertextid == MN_BotaoIR[playerid]) && (Check == 3))
    {
        FecharSten(playerid);
        MostrarAccuracy(playerid);
        Check = 4;
    }
    if((playertextid == MN_BotaoVIR[playerid]) && (Check == 3))
    {
        FecharSten(playerid);
        MostrarHeckler(playerid);
        Check = 2;
    }
    if((playertextid == MN_BotaoIR[playerid]) && (Check == 4))
    {
        FecharAccuracy(playerid);
        MostrarColete(playerid);
        Check = 5;
    }
    if((playertextid == MN_BotaoVIR[playerid]) && (Check == 4))
    {
        FecharAccuracy(playerid);
        MostrarSten(playerid);
        Check = 3;
    }
    if((playertextid == MN_BotaoIR[playerid]) && (Check == 5))
    {
        FecharColete(playerid);
        MostrarColt(playerid);
        Check = 6;
    }
    if((playertextid == MN_BotaoVIR[playerid]) && (Check == 5))
    {
        FecharColete(playerid);
        MostrarAccuracy(playerid);
        Check = 4;
    }
    if((playertextid == MN_BotaoIR[playerid]) && (Check == 6))
    {
        FecharColt(playerid);
        MostrarCruzelion(playerid);
        Check = 1;
    }
    if((playertextid == MN_BotaoVIR[playerid]) && (Check == 6))
    {
        FecharColt(playerid);
        MostrarColete(playerid);
        Check = 5;
    }
    if(playertextid == MN_BotaoSAIR[playerid])
    {
        FecharMN_Tudo(playerid);
        CancelSelectTextDraw(playerid);
    }
    return 1;

}
Reply
#2

After your first 'if' statement all the following should be 'else if'. On my phone I'll read it properly soon
Reply
#3

Ok, first of all i just rebuilt the code, and now he are like this:
pawn Code:
public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid)
{
    if(playertextid == MN_BotaoIR[playerid])
    {
        if((Check) == 0)
        {
            FecharCruzelion(playerid);
            MostrarPioneer(playerid);
            Check = 1
        }
        else if((Check) == 1)
        {
            FecharPioneer(playerid);
            MostrarHeckler(playerid);
            Check = 2;
        }
        else if((Check) == 2)
        {
            FecharHeckler(playerid);
            MostrarSten(playerid);
            Check = 3;
        {
        else if((Check) == 3)
        {
            FecharSten(playerid);
            MostrarAccuracy(playerid);
            Check = 4;
        {
        else if((Check) == 4)
        {
            FecharAccuracy(playerid);
            MostrarColete(playerid);
            Check = 5;
        {
        else if((Check) == 5)
        {
            FecharColete(playerid);
            MostrarColt(playerid);
            Check = 6;
        {
        else if((Check) == 6)
        {
            FecharColt(playerid);
            MostrarCruzelion(playerid);
            Check = 1;
        {
    }
    if(playertextid == MN_BotaoVIR[playerid])
    {
        if((Check) == 0)
        {
            FecharCruzelion(playerid);
            MostrarColt(playerid);
            Check = 6
        }
        else if((Check) == 1)
        {
            FecharPioneer(playerid);
            MostrarCruzelion(playerid);
            Check = 0;
        }
        else if((Check) == 2)
        {
            FecharHeckler(playerid);
            MostrarPioneer(playerid);
            Check = 1;
        {
        else if((Check) == 3)
        {
            FecharSten(playerid);
            MostrarHeckler(playerid);
            Check = 2;
        {
        else if((Check) == 4)
        {
            FecharAccuracy(playerid);
            MostrarSten(playerid);
            Check = 3;
        {
        else if((Check) == 5)
        {
            FecharColete(playerid);
            MostrarAccuracy(playerid);
            Check = 4;
        {
        else if((Check) == 6)
        {
            FecharColt(playerid);
            MostrarColete(playerid);
            Check = 5;
        }
    }
    if(playertextid == MN_BotaoSAIR[playerid])
    {
        FecharMN_Tudo(playerid);
        CancelSelectTextDraw(playerid);
    }
    return 1;
}
But now, he don't wanna compile, and show the first error : (error 017: undefined symbol "OnGameModeInit_Setup") and after it, he show a lot of error's that who were not there;
Reply
#4

Somebody can help me? sorry the double post but i do not know what to do
Reply
#5

Hello, do the textdraws get highlighted when you pass with mouse cursor on them?
Reply
#6

Quote:
Originally Posted by v1k1nG
View Post
Hello, do the textdraws get highlighted when you pass with mouse cursor on them?
Yes, they are
Reply
#7

Okay. Try to debug before doing changes, add a print() or SendClientMessage when player clicks the textdraws and see if you get the message sent, if you do

PHP Code:
        FecharCruzelion(playerid);
        
MostrarPioneer(playerid);
        
MostrarHeckler(playerid);
        
MostrarSten(playerid);
        
// etc 
can be the cause of the malfunctioning
Reply
#8

but he dont wanna compile with this code:

pawn Code:
public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid)
{
    if(playertextid == MN_BotaoIR[playerid])
    {
        if((Check) == 0)
        {
            FecharCruzelion(playerid);
            MostrarPioneer(playerid);
            Check = 1;  
        }
        else if((Check) == 1)
        {
            FecharPioneer(playerid);
            MostrarHeckler(playerid);
            Check = 2;
        }
        else if((Check) == 2)
        {
            FecharHeckler(playerid);
            MostrarSten(playerid);
            Check = 3;
        {
        else if((Check) == 3)
        {
            FecharSten(playerid);
            MostrarAccuracy(playerid);
            Check = 4;
        {
        else if((Check) == 4)
        {
            FecharAccuracy(playerid);
            MostrarColete(playerid);
            Check = 5;
        {
        else if((Check) == 5)
        {
            FecharColete(playerid);
            MostrarColt(playerid);
            Check = 6;
        {
        else if((Check) == 6)
        {
            FecharColt(playerid);
            MostrarCruzelion(playerid);
            Check = 1;
        {
    }
    if(playertextid == MN_BotaoVIR[playerid])
    {
        if((Check) == 0)
        {
            FecharCruzelion(playerid);
            MostrarColt(playerid);
            Check = 6;  
        }
        else if((Check) == 1)
        {
            FecharPioneer(playerid);
            MostrarCruzelion(playerid);
            Check = 0;
        }
        else if((Check) == 2)
        {
            FecharHeckler(playerid);
            MostrarPioneer(playerid);
            Check = 1;
        {
        else if((Check) == 3)
        {
            FecharSten(playerid);
            MostrarHeckler(playerid);
            Check = 2;
        {
        else if((Check) == 4)
        {
            FecharAccuracy(playerid);
            MostrarSten(playerid);
            Check = 3;
        {
        else if((Check) == 5)
        {
            FecharColete(playerid);
            MostrarAccuracy(playerid);
            Check = 4;
        {
        else if((Check) == 6)
        {
            FecharColt(playerid);
            MostrarColete(playerid);
            Check = 5;
        }
    }
    if(playertextid == MN_BotaoSAIR[playerid])
    {
        FecharMN_Tudo(playerid);
        CancelSelectTextDraw(playerid);
    }
    return 1;
}
He compile whit that code:

pawn Code:
public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid)
{
    if((playertextid == MN_BotaoIR[playerid]) && (Check == 0))
    {
        FecharCruzelion(playerid);
        MostrarPioneer(playerid);
        Check = 1;
    }
    if((playertextid == MN_BotaoVIR[playerid]) && (Check == 0))
    {
        FecharCruzelion(playerid);
        MostrarColt(playerid);
        Check = 6;
    }
    if((playertextid == MN_BotaoIR[playerid]) && (Check == 1))
    {
        FecharPioneer(playerid);
        MostrarHeckler(playerid);
        Check = 2;
    }
    if((playertextid == MN_BotaoVIR[playerid]) && (Check == 1))
    {
        FecharPioneer(playerid);
        MostrarCruzelion(playerid);
        Check = 0;
    }
    if((playertextid == MN_BotaoIR[playerid]) && (Check == 2))
    {
        FecharHeckler(playerid);
        MostrarSten(playerid);
        Check = 3;
    }
    if((playertextid == MN_BotaoVIR[playerid]) && (Check == 2))
    {
        FecharHeckler(playerid);
        MostrarPioneer(playerid);
        Check = 1;
    }
    if((playertextid == MN_BotaoIR[playerid]) && (Check == 3))
    {
        FecharSten(playerid);
        MostrarAccuracy(playerid);
        Check = 4;
    }
    if((playertextid == MN_BotaoVIR[playerid]) && (Check == 3))
    {
        FecharSten(playerid);
        MostrarHeckler(playerid);
        Check = 2;
    }
    if((playertextid == MN_BotaoIR[playerid]) && (Check == 4))
    {
        FecharAccuracy(playerid);
        MostrarColete(playerid);
        Check = 5;
    }
    if((playertextid == MN_BotaoVIR[playerid]) && (Check == 4))
    {
        FecharAccuracy(playerid);
        MostrarSten(playerid);
        Check = 3;
    }
    if((playertextid == MN_BotaoIR[playerid]) && (Check == 5))
    {
        FecharColete(playerid);
        MostrarColt(playerid);
        Check = 6;
    }
    if((playertextid == MN_BotaoVIR[playerid]) && (Check == 5))
    {
        FecharColete(playerid);
        MostrarAccuracy(playerid);
        Check = 4;
    }
    if((playertextid == MN_BotaoIR[playerid]) && (Check == 6))
    {
        FecharColt(playerid);
        MostrarCruzelion(playerid);
        Check = 1;
    }
    if((playertextid == MN_BotaoVIR[playerid]) && (Check == 6))
    {
        FecharColt(playerid);
        MostrarColete(playerid);
        Check = 5;
    }
    if(playertextid == MN_BotaoSAIR[playerid])
    {
        FecharMN_Tudo(playerid);
        CancelSelectTextDraw(playerid);
    }
    return 1;

}
But the second code, dont work in game, and the first dont compile.
Reply
#9

Do you even check your own code?, you have opening braces instead of closing ones starting at Check equal 2

Here, rewrote your code (just to lazy to exlain that you should be using switch)
PHP Code:
//
    
if(playertextid == MN_BotaoIR[playerid] || playertextid == MN_BotaoVIR[playerid]) {
        switch(
Check) {
            case 
0FecharCruzelion(playerid);
            case 
1FecharPioneer(playerid);
            case 
2FecharHeckler(playerid);
            case 
3FecharSten(playerid);
            case 
4FecharAccuracy(playerid);
            case 
5FecharColete(playerid);
            case 
6FecharColt(playerid);
        }
        if(
playertextid == MN_BotaoIR[playerid]) {
            
Check++;
        } else {
            
Check--;
        }
        switch((
Check %= 7)) {
            case 
0MostrarCruzelion(playerid);
            case 
1MostrarPioneer(playerid);
            case 
2MostrarHeckler(playerid);
            case 
3MostrarSten(playerid);
            case 
4MostrarAccuracy(playerid);
            case 
5MostrarColete(playerid);
            case 
6MostrarColt(playerid);
        }
    } 
Well there are probably several flaws left but this part should compile for now
Reply
#10

Quote:
Originally Posted by Nero_3D
View Post
Do you even check your own code?, you have opening braces instead of closing ones starting at Check equal 2

Here, rewrote your code (just to lazy to exlain that you should be using switch)
PHP Code:
//
    
if(playertextid == MN_BotaoIR[playerid] || playertextid == MN_BotaoVIR[playerid]) {
        switch(
Check) {
            case 
0FecharCruzelion(playerid);
            case 
1FecharPioneer(playerid);
            case 
2FecharHeckler(playerid);
            case 
3FecharSten(playerid);
            case 
4FecharAccuracy(playerid);
            case 
5FecharColete(playerid);
            case 
6FecharColt(playerid);
        }
        if(
playertextid == MN_BotaoIR[playerid]) {
            
Check++;
        } else {
            
Check--;
        }
        switch((
Check %= 7)) {
            case 
0MostrarCruzelion(playerid);
            case 
1MostrarPioneer(playerid);
            case 
2MostrarHeckler(playerid);
            case 
3MostrarSten(playerid);
            case 
4MostrarAccuracy(playerid);
            case 
5MostrarColete(playerid);
            case 
6MostrarColt(playerid);
        }
    } 
Well there are probably several flaws left but this part should compile for now
It worked perfectly, thank you, I owe you one
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)