AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   warnings: loose indentation and tag mismatch (https://forums.alliedmods.net/showthread.php?t=313135)

tolpecek 12-29-2018 12:52

warnings: loose indentation and tag mismatch
 
Hello, i have a question. What causes warnings loose indentation and tag mismatch?

tolpecek 12-29-2018 12:55

Re: warnings: loose indentation and tag mismatch
 
Code:

public ScreenFade_Zariche(id)
{
        print_color(id, "Napisal si zariche")
        new players[32], num
        //get_players(players, num, "ace", "CT")
        get_players(players, num);

        new shakeAmplitude = __FixedUnsigned16(SHAKE_AMPLITUDE, 1<<12)
        new shakeDuration  = __FixedUnsigned16(SHAKE_DURATION, 1<<12)
        new shakeFrequency = __FixedUnsigned16(SHAKE_FREQUENCY, 1<<9)

        for(--num; num>=0; num--)
        {
                message_begin(MSG_ONE, gmsgShake, .player = players[num])
                        {
                                write_short( shakeAmplitude )  // shake amount.
                                write_short( shakeDuration )  // shake lasts this long.
                                write_short( shakeFrequency )  // shake noise frequency.
                        }
                message_end()


                message_begin(MSG_ONE, get_user_msgid("ScreenFade"), {0,0,0}, players[num]);
                        {
                                write_short(4096*10);    // Duration
                                write_short(4);    // Hold time 4096*2
                                write_short(4096);    // Fade type
                                write_byte(0);        // Red
                                write_byte(0);        // Green
                                write_byte(0);        // Blue
                                write_byte(255);    // Alpha
                        }
                message_end()      // here it says loose indentation
                }       
        return PLUGIN_HANDLED
}

this do not work at all

fysiks 12-29-2018 17:14

Re: warnings: loose indentation and tag mismatch
 
Loose indentation is when the indentation of your code is no consistent. This does not affect code execution but it's best if you don't ignore this warning because proper indentation helps make the code more readable and make it easier to find certain mistakes.

Tag mismatch is what is says, it's when two variables used together don't have matching tags. This may or may not affect code execution depending on which tag is mismatched. It usually means that something in the logic of your code is wrong and should be fixed.

P.S. There is no such thing as __FixedUnsigned16() in AMX Mod X so I'm not sure what that is. If you still need help, you need to provide more information i.e. it's best if you attach the whole .sma file to your post and provide the whole compiler output.

tolpecek 12-29-2018 17:22

Re: warnings: loose indentation and tag mismatch
 
Quote:

Originally Posted by fysiks (Post 2631683)
Loose indentation is when the indentation of your code is no consistent. This does not affect code execution but it's best if you don't ignore this warning because proper indentation helps make the code more readable and make it easier to find certain mistakes.

Tag mismatch is what is says, it's when two variables used together don't have matching tags. This may or may not affect code execution depending on which tag is mismatched. It usually means that something in the logic of your code is wrong and should be fixed.

P.S. There is no such thing as __FixedUnsigned16() in AMX Mod X so I'm not sure what that is. If you still need help, you need to provide more information i.e. it's best if you attach the whole .sma file to your post and provide the whole compiler output.

i do not want to show my plugin, but here is a code of __FixedUnsigned16()
Code:

__FixedUnsigned16(Float:flValue, iScale)
{
        new iOutput;

        iOutput = floatround(flValue * iScale)

        if ( iOutput < 0 )
                iOutput = 0

        if ( iOutput > 0xFFFF )
                iOutput = 0xFFFF
       
        return iOutput
}


fysiks 12-29-2018 20:56

Re: warnings: loose indentation and tag mismatch
 
That function seems to be ok. Since you've not posted any more information about the warnings, I can only assume you've fixed everything.

tolpecek 12-30-2018 03:33

Re: warnings: loose indentation and tag mismatch
 
Quote:

Originally Posted by fysiks (Post 2631706)
That function seems to be ok. Since you've not posted any more information about the warnings, I can only assume you've fixed everything.

it does not work
Code:


#define SHAKE_AMPLITUDE    16.0    // max = 16.0
#define SHAKE_DURATION    6.0        // max = 16.0
#define SHAKE_FREQUENCY    100.0    // max = 256.0

Code:

public ScreenFade_Zariche(id)
{
        new players[32], num
        //get_players(players, num, "ace", "CT")
        get_players(players, num);

        new shakeAmplitude = __FixedUnsigned16(SHAKE_AMPLITUDE, 1<<12)
        new shakeDuration  = __FixedUnsigned16(SHAKE_DURATION, 1<<12)
        new shakeFrequency = __FixedUnsigned16(SHAKE_FREQUENCY, 1<<9)

        for(--num; num>=0; num--)
        {
                message_begin(MSG_ONE, gmsgShake, .player = players[num])
                        {
                                write_short( shakeAmplitude )  // shake amount.
                                write_short( shakeDuration )  // shake lasts this long.
                                write_short( shakeFrequency )  // shake noise frequency.
                        }
                message_end()


                message_begin(MSG_ONE, get_user_msgid("ScreenFade"), {0,0,0}, players[num]);
                        {
                                write_short(4096*10);    // Duration
                                write_short(4);    // Hold time 4096*2
                                write_short(4096);    // Fade type
                                write_byte(0);        // Red
                                write_byte(0);        // Green
                                write_byte(0);        // Blue
                                write_byte(255);    // Alpha
                        }
                message_end()
                }       
        return PLUGIN_HANDLED
}

Code:



fysiks 12-30-2018 17:40

Re: warnings: loose indentation and tag mismatch
 
The topic is about loose indentation and a tag warning. Did you fix those? If no, you need to provide more information. If yes, you should start a new thread inquiring about your new topic. However, make sure you make a serious effort to debug your code on your own.

eat1k 12-31-2018 12:27

Re: warnings: loose indentation and tag mismatch
 
for(--num; num>=0; num--) lol, what is this?
->
for(new i; i < num; i++)
Remove the brackets of message_begin and make all write_* at the same level as message_begin. The second bracket of the for() is bad.
That code looks really bad.

tolpecek 12-31-2018 20:55

Re: warnings: loose indentation and tag mismatch
 
Quote:

Originally Posted by eat1k (Post 2632040)
for(--num; num>=0; num--) lol, what is this?
->
for(new i; i < num; i++)
Remove the brackets of message_begin and make all write_* at the same level as message_begin. The second bracket of the for() is bad.
That code looks really bad.


Still doesn´t work..
//edit, it crashes server :) : L 01/01/2019 - 03:05:57: (map "") Host_Error: WriteDest_Parm: not a client

fysiks 12-31-2018 21:02

Re: warnings: loose indentation and tag mismatch
 
Quote:

Originally Posted by fysiks (Post 2631903)
The topic is about loose indentation and a tag warning. Did you fix those? If no, you need to provide more information. If yes, you should start a new thread inquiring about your new topic. However, make sure you make a serious effort to debug your code on your own.



All times are GMT -4. The time now is 07:32.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.