SA-MP Forums Archive
How to fix this warning - 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: How to fix this warning (/showthread.php?tid=466709)



How to fix this warning - Jizz - 29.09.2013

pawn Код:
if(dialogid == DSB)
    {
        if(response)
        {
        if(PlayerInfo[playerid][pConnectTime] < 2) return SendClientMessage(playerid, COLOR_GRAD2, "You can't use this as you're currently restricted from possessing weapons!");
            switch(listitem) //HERE'S THE WARNING
            {
            case 0: GivePlayerValidWeapon(playerid, 24, 99999);
            case 1: GivePlayerValidWeapon(playerid, 27, 99999);
            case 2: GivePlayerValidWeapon(playerid, 31, 99999);
            case 3: GivePlayerValidWeapon(playerid, 34, 99999);
            case 4: GivePlayerValidWeapon(playerid, 29, 99999);
            case 5: SetPlayerArmourEx(playerid, 100);
            case 6: SetPlayerHealth(playerid, 100);
            }
        }
    }
Quote:

warning 217: loose indentation




Re: How to fix this warning - M0n3y - 29.09.2013

<removed>


Re: How to fix this warning - iZN - 29.09.2013

That's the worse way of doing that. Please indent them with TAB and SHIFT+TAB.


Re: How to fix this warning - xganyx - 29.09.2013

<removed>

or

pawn Код:
if(dialogid == DSB)
    {
        if(response)
        {
            if(PlayerInfo[playerid][pConnectTime] < 2) return SendClientMessage(playerid, COLOR_GRAD2, "You can't use this as you're currently restricted from possessing weapons!");
            switch(listitem)
            {
                case 0: GivePlayerValidWeapon(playerid, 24, 99999);
                case 1: GivePlayerValidWeapon(playerid, 27, 99999);
                case 2: GivePlayerValidWeapon(playerid, 31, 99999);
                case 3: GivePlayerValidWeapon(playerid, 34, 99999);
                case 4: GivePlayerValidWeapon(playerid, 29, 99999);
                case 5: SetPlayerArmourEx(playerid, 100);
                case 6: SetPlayerHealth(playerid, 100);
            }
        }
    }



Re: How to fix this warning - Patrick - 29.09.2013

Pragma tabsize isn't really recommended at all!

How do you fix the problem? Intend your code properly

Intended Code and No need to use <removed>
pawn Код:
if(dialogid == DSB)
{
    if(response)
    {
        if(PlayerInfo[playerid][pConnectTime] < 2) return SendClientMessage(playerid, COLOR_GRAD2, "You can't use this as you're currently restricted from possessing weapons!");
        switch(listitem)
        {
            case 0: GivePlayerValidWeapon(playerid, 24, 99999);
            case 1: GivePlayerValidWeapon(playerid, 27, 99999);
            case 2: GivePlayerValidWeapon(playerid, 31, 99999);
            case 3: GivePlayerValidWeapon(playerid, 34, 99999);
            case 4: GivePlayerValidWeapon(playerid, 29, 99999);
            case 5: SetPlayerArmourEx(playerid, 100);
            case 6: SetPlayerHealth(playerid, 100);
        }
    }
}



Re: How to fix this warning - Jizz - 29.09.2013

Fixed, I have another warning
Quote:

warning 219: local variable "playerid" shadows a variable at a preceding level

pawn Код:
CMD:fixmyvw(playerid, params[])
{
    new string[128], playerid; //Warn here.
    if(IsPlayerConnected(playerid))
    {
        GetPlayerPos(playerid, StopaniFloats[playerid][0], StopaniFloats[playerid][1], StopaniFloats[playerid][2]);
        SetTimerEx("StopaniTimer", 5000, 0, "d", playerid);
        SendClientMessage (playerid, COLOR_YELLOW, "Do not move for 5 seconds to have your VW Fixed!");
        {
        PlayerInfo[playerid][pVW] =  0;
        SetPlayerVirtualWorld(playerid,  0);
        format(string, sizeof(string), "You have fix your virtual world.");
        SendClientMessage(playerid, COLOR_GRAD2, string);
        }
    }
    return 1;
}



Re: How to fix this warning - iZN - 29.09.2013

pawn Код:
new string[128], playerid;
to
pawn Код:
new string[128];
playerid is already defined, can't you see? CMD:fixmyvw(playerid, params[])


Re: How to fix this warning - xganyx - 29.09.2013

Quote:
Originally Posted by pds2012
Посмотреть сообщение
Pragma tabsize isn't really recommended at all!

How do you fix the problem? Intend your code properly

Intended Code and No need to use <removed>
pawn Код:
if(dialogid == DSB)
{
    if(response)
    {
        if(PlayerInfo[playerid][pConnectTime] < 2) return SendClientMessage(playerid, COLOR_GRAD2, "You can't use this as you're currently restricted from possessing weapons!");
        switch(listitem)
        {
            case 0: GivePlayerValidWeapon(playerid, 24, 99999);
            case 1: GivePlayerValidWeapon(playerid, 27, 99999);
            case 2: GivePlayerValidWeapon(playerid, 31, 99999);
            case 3: GivePlayerValidWeapon(playerid, 34, 99999);
            case 4: GivePlayerValidWeapon(playerid, 29, 99999);
            case 5: SetPlayerArmourEx(playerid, 100);
            case 6: SetPlayerHealth(playerid, 100);
        }
    }
}
You see this... The second code...

Quote:
Originally Posted by xganyx
Посмотреть сообщение
<removed>

or

pawn Код:
if(dialogid == DSB)
    {
        if(response)
        {
            if(PlayerInfo[playerid][pConnectTime] < 2) return SendClientMessage(playerid, COLOR_GRAD2, "You can't use this as you're currently restricted from possessing weapons!");
            switch(listitem)
            {
                case 0: GivePlayerValidWeapon(playerid, 24, 99999);
                case 1: GivePlayerValidWeapon(playerid, 27, 99999);
                case 2: GivePlayerValidWeapon(playerid, 31, 99999);
                case 3: GivePlayerValidWeapon(playerid, 34, 99999);
                case 4: GivePlayerValidWeapon(playerid, 29, 99999);
                case 5: SetPlayerArmourEx(playerid, 100);
                case 6: SetPlayerHealth(playerid, 100);
            }
        }
    }
Why do you -rep me... Bitch....


Re: How to fix this warning - Patrick - 29.09.2013

Quote:
Originally Posted by xganyx
Посмотреть сообщение
You see this... The second code...



Why do you -rep me... Bitch....
I didn't -rep you by the way, you could ask the admin, when you -rep me, I don't care it's alright, but you forced me to do it again cuz of your behaviour.